Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 which query is better acc to performance wise?

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2009-12-17 : 00:35:57
hi,

i had two queries, i want to know which query is better acc to performance wise though these are simpel queries.

one :

select top 1 resultsid from results with(tablockx) where status = 1 order by resultsid

two :

select min(resultsid) from results with(tablockx) where status = 1

how can i know which query is better.

how can i know performance diff b/w two objects which can be used for same requirement?

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-17 : 02:07:54
Set the execution plan and see
It should be better to use the second option

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -