SQLite Forum

Min/max and index usage?
Login
> It seems the only difference is that it splits the aggregation functions into two queries.

It's an important difference, because the query planner has optimizations for finding the MIN of an Indexed column (same way you can find the first entry in a phone-book very quick) and same for the MAX of an Indexed column, but it has currently no built-in short-cut case for getting both MIN and MAX in one go... so it needs to scan the entire Index to get the lowest and highest in such a single query.

When the query is split into the two simpler lookups, it can happily apply the cheat-sheet short-cut ways it knows for doing those special cases.