Do MAX Function Scan Table? – Interview Question of the Week #289


Question: Do MAX Function Scan Table to retrieve the data?

Answer: Yes, if there are no indexes to help retrieve data.

I personally hate answers which are ambiguous and I also do not like to say it depends as well. Let me say in simple possible words what I have seen in the real world.

When you retrieve data from a column and if there is no index on the column (or if SQL Server thinks scan is faster) it will do the table scan. If the SQL Server engine finds the index which can help you query to retrieve the data faster,