12.6.09

Interesting behaviour of SQL Server

Estimation plan in SQL Server :
I happened to do a check on the estimation plan for a very small query

Executed both the query,
Query 1:
select * from [venkat] order by 1 desc -- Query cost is 82%
This query have scanned a little bit on the table and took all the remaining cost for sorting.
Query 2:
select * from [venkat]order by -- Query cost is 18%
(select 1)
desc
The above query has took 100% of its cost to scan the table. It doesn't spend any thing for sorting. Am confused with this behavior of sql server. But too interesting. I think we need to use second query for best performance (Providing, we need to index the table properly :-) )

Let me check with Microsoft team for a very better explanation on this article.


Thanks and Regards,
Venkatesan Prabu .J

1 comment:

  1. It was very interesting for me to read the article. Thanks for it. I like such themes and everything connected to them. I definitely want to read more on that blog soon.

    Sincerely yours

    ReplyDelete