I have simple query which is taking around 7-8 seconds for to retreive the data from database which I want to fine tune further to 2-3 seconds.
Table :
UpdateDateTime | field1 | field2 |..... FieldN.
Query is :
Select *
from Table with (nolock)
where UpdateDateTime Between D1 and D2
Order By UpdateDateTIme
I have created Clustered Index On UpdateDateTime
What could be done further to increase its Efficiency?
Reduce the number of columns returned is the obvious answer, then create a covering (nonclustered) index on
UpdateDateTImeandINCLUDEthe other selected columns.Ref.
[Note: It’s not ideal to create a wide covering index that includes all the columns in the table.]
A lot depends on how selective your
WHEREclause is. If it returns (approximately) greater than 10% of the number of rows in the table, then the optimiser will probably just scan the clustered index anyway.That’s pretty much it. Beyond you need to take a look at your hardware, and how much data you are pulling across the wire.