Re: Index not being used in MAX function (7.2.3) - Mailing list pgsql-general

From Tom Lane
Subject Re: Index not being used in MAX function (7.2.3)
Date
Msg-id 21379.1055457311@sss.pgh.pa.us
Whole thread Raw
In response to Re: Index not being used in MAX function (7.2.3)  ("Jim C. Nasby" <jim@nasby.net>)
List pgsql-general
"Jim C. Nasby" <jim@nasby.net> writes:
> Am I just being naive, or couldn't this be solved by adding min/max
> boolean flags to pg_aggregates and the appropriate syntax to CREATE
> AGGREGATE?

I'd prefer to see a direct link to the associated sort operator
('<' for MIN or '>' for MAX).  But yeah, some addition to the system
catalogs seems essential if you don't want the code to be full of
unsupportable assumptions about aggregate and operator names.

> So it seems the ORDER/LIMIT hack doesn't work well at all except in
> limited situations.

No kidding.  This is one reason there hasn't been a huge push to get it
implemented: the actual usefulness of the hack is quite limited.  In
your example, I suspect the presence of the unrelated WHERE clause is
what makes it unhelpful.

            regards, tom lane

pgsql-general by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Index not being used in MAX function (7.2.3)
Next
From: "Octavio Alvarez"
Date:
Subject: Re: LC_COLLATE=es_MX in PgSQL 7.3.2