Reputation: 787
i have a query like this
SELECT TOP 10
*
FROM NEWS
WHERE newsid > AAA
ORDER BY newsid desc;
this query is very slow for some values of AAA
for example it is fast for 1,000,000 and 1,400,000 but it is slow for 1,355,316
I am confused!!!
Upvotes: 0
Views: 198
Reputation: 6547
If in Sql Server 2008 try with FORCESEEK
hint. You will get predictable results.
Upvotes: 0
Reputation: 58261
My first thought is that it is doing a lot of string comparison, and that maybe in your case where there are 1,355,316 records, either the string values are long, or the table is fragmented.
Is there an index on the table?
To start reading about query optimization, read this and this.
Upvotes: 1