Do MAX(col) Scan Table? – SQL in Sixty Seconds #106


 

Query tuning and optimization is my favourite thing when I am working on a Comprehensive Database Performance Health Check. The other day while working with a client, I realized that they have a query where they are using an aggregate function like MIN and MAX. The question I received from my client was – Do MAX(col) Scan Table? Let us learn about that today.

One of the common misconceptions is that as MAX and MIN like operators which are only retrieving only single row use some kind of smart logic or algorithm to get the necessary results. Actually, it is not