sql - Which Select query will run faster -


this question has answer here:

hi trying maximum id table has approx 1 million records. please suggest me on of these query execute faster.

option 1:

select top 1 surveyuserresponseid surveyuserresponse order surveyuserresponseid desc 

option 2:

select max(surveyuserresponseid) surveyuserresponse 

as per actual execution plan both query took same time execute.

you can try yourself. run query time statistics. so:

set statistics time on; select top 1 surveyuserresponseid surveyuserresponse order surveyuserresponseid desc set statistics time off; 

and see on "messages" tab how long took execute each query.


Comments

Popular posts from this blog

Prolog - Listing -

orchardcms - change base url in local copy in Orchard CMS -

python - More Issues with overlapping labels in Tkinter -