Archive for November 11th, 2009
SQL Server: clustered index and ordering
From Stack Overflow:
My table (SQL Server 2008) has more than 1 million records.
When I try to order records by
datetime
, it takes 1 second, but when I order byid
(integer), it only takes about 0.1 second.Is there any way to improve the efficiency?
The obvious answer would be create an index on
datetime
However, everything's not so simple.
Let's create a sample table and see why:
Read the rest of this entry »