From 4c942c2faae0a4ea9aaf78f2b8e2bf5998763e14 Mon Sep 17 00:00:00 2001 From: Tanu Gupta <121037070+tanugupta30@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:59:32 +0530 Subject: [PATCH 1/3] Updated schema.sql --- schema.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/schema.sql b/schema.sql index fb0a83c..81c13e0 100644 --- a/schema.sql +++ b/schema.sql @@ -1013,4 +1013,5 @@ insert into Orders (CustomerID, OrderDate, ProductID, Quantity) values (1000, '2 -- Write query to create the index that you will create to optimize a query like -- SELECT * FROM Orders WHERE CustomerID = {abc} AND OrderDate > '{abc}'; +create index idx_Orders on Orders (CustomerID,OrderDate); From 8e8cdde5155332924282c2820b4994b36f45f81c Mon Sep 17 00:00:00 2001 From: Tanu Gupta <121037070+tanugupta30@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:10:02 +0530 Subject: [PATCH 2/3] Update schema.sql --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index 81c13e0..af81c0a 100644 --- a/schema.sql +++ b/schema.sql @@ -1013,5 +1013,5 @@ insert into Orders (CustomerID, OrderDate, ProductID, Quantity) values (1000, '2 -- Write query to create the index that you will create to optimize a query like -- SELECT * FROM Orders WHERE CustomerID = {abc} AND OrderDate > '{abc}'; -create index idx_Orders on Orders (CustomerID,OrderDate); +CREATE INDEX idx_CustomerID_OrderDate ON Orders (CustomerID, OrderDate); From 2b8fb791b168d415fbd17dd64144abac03bf1cec Mon Sep 17 00:00:00 2001 From: Tanu Gupta <121037070+tanugupta30@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:14:24 +0530 Subject: [PATCH 3/3] Update schema.sql --- schema.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index af81c0a..f5bc611 100644 --- a/schema.sql +++ b/schema.sql @@ -1013,5 +1013,9 @@ insert into Orders (CustomerID, OrderDate, ProductID, Quantity) values (1000, '2 -- Write query to create the index that you will create to optimize a query like -- SELECT * FROM Orders WHERE CustomerID = {abc} AND OrderDate > '{abc}'; -CREATE INDEX idx_CustomerID_OrderDate ON Orders (CustomerID, OrderDate); +-- we can't be able to search faster by using this reason behind it will sort the data based on customerId and their is no tie betweem customerId, orderDate we couldn't able to make use of orderDate. +--CREATE INDEX idx_CustomerID_OrderDate ON Orders (CustomerID, OrderDate); +-- Better approach we can apply index on customerId it would be much faster in that case. +CREATE INDEX idx_CustomerID_OrderDate ON Orders (CustomerID); +