SQL Server 2008: Ordering by datetime is too slow

Viewed 26870

My table (SQL Server 2008) has 1 million+ records, when I try to order records by datetime, it takes 1 second, but when I order by ID (int), it only takes about 0.1 second.

Is there any way to improve the efficiency? (I already added the datetime column to the index)

8 Answers

In some cases you can set datetime as cluster index, if your table’s primary key is not important, for example a user logs table, you can set primary key not cluster, and then set times and user id as combine index and set cluster true.

Related