parsed.org

Tips by tag: aggregates

Eliminating Aggregates by cygnus on Mar 31, 2005 08:49 AM

If you have a query like this:

SELECT max(some_column) FROM mytable WHERE ...;

and you want to eliminate the sequence scan that kills the query's performance, an alternative is:

SELECT some_column FROM mytable WHERE ... ORDER BY some_column DESC LIMIT 1;

MIN and MAX aggregates can be eliminated this way.

aggregatesmaxminperformancepostgresqlqueriesscansql
RSS