From 48f3b7d7896667a7eca755803acfb4371dc534c3 Mon Sep 17 00:00:00 2001 From: Tanu Gupta <121037070+tanugupta30@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:16:38 +0530 Subject: [PATCH 1/2] Update schema.sql --- schema.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/schema.sql b/schema.sql index fb0a83c..e33bb50 100644 --- a/schema.sql +++ b/schema.sql @@ -1013,4 +1013,8 @@ 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}'; +-- 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); From aebb40f24d1e76498e58f96bacebbed68ccc0246 Mon Sep 17 00:00:00 2001 From: Tanu Gupta <121037070+tanugupta30@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:19:13 +0530 Subject: [PATCH 2/2] Update schema.sql --- schema.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index e33bb50..5f0035f 100644 --- a/schema.sql +++ b/schema.sql @@ -1016,5 +1016,6 @@ insert into Orders (CustomerID, OrderDate, ProductID, Quantity) values (1000, '2 -- 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); +CREATE INDEX idx_CustomerID_OrderDate ON Orders(CustomerID); +