In the case, I have a simple sql about select, which sorts by date, OrderDate. At the same time, there are 5,000,000 records in the table, Orders. Due to the large amount of data, the SQL speed becomes very slow, about 6 seconds.
1 | SELECT TOP 1000 [Id] |
After running the sql script, the speed of the result was very slow, about 6 seconds.
So to imporve this problem, I add the index, NONCLUSTERED INDEX.
1 | USE OrderDB; |
After running the script, I found the speed has been improved by index, about 0 seconds, and there’re still 5,000,000 records in the table.