• hi_abhay78 (6/18/2009)


    SELECT TOP 1* FROM TicketActivity

    SELECT MIN(TicketId) FROM TicketActivity

    The above 2 queries are different.

    But you can also run the min query as below :

    select top 1 ticketid from TicketActivity order by ticketid

    Check the sub-tree cost of bot the queries and see which one is more beneficial.Most probably the cost would be same but i am confident that in any case the query with orderby clause would not be using Stream Aggregates and should be a better choice .

    HTH

    Just a note, sub-tree costs are estimated values. They don't accurately represent performance. Better to compare the scans, reads and actual execution times of the two queries to determine which is faster.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning