I'm attempting to query data from a rather large table, approximately 98 million rows, using datetime columns in the WHERE clause. It takes approximately 12 minutes to complete - which is obviously not acceptable. The query is simple:
SELECT ID, DateTime1, DateTime2, Value1, Value2
FROM dataTable
WHERE DateTime1 >= '2017-05-15 09:00' AND
DateTime1 <= '2017-05-15 09:30'
The table has the following structure:
Column Name | DataType
-------------------------
ID | float
DateTime1 | datetime
DateTime2 | datetime
Value1 | float
Value2 | varchar(20)
The table has the following index:
Nonclustered: DateTime1, DateTime2, ID, Value2
Value1into the index. - Gordon Linoff