The faster of two SQL queries, sort and select top 1, or select MAX
sql, sql-server
Solution
With an index on `order_date`, they are of same performance.
Without an index, `MAX` is a little bit faster, since it will use `Stream Aggregation` rather than `Top N Sort`.
Problem
Which one is faster of the following two queries? 1 ``` SELECT TOP 1 order_date FROM orders WITH (NOLOCK) WHERE customer_id = 9999999 ORDER BY order_date DESC ``` 2 ``` SELECT MAX(order_date) FROM orders WITH (NOLOCK) WHERE customer_id = 9999999 ```