sql - Which Select query will run faster -
this question has answer here:
- sql performance max() 4 answers
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
Post a Comment