Forum OpenACS Development: Re: Re: Best way to get name of last modified content item?

Posted by Don Baccus on
In general, in Postgres, the ORDER BY/LIMIT trick Jeff's using is the recommended way (by the PG people) to get around their poor implementation of max().

It's not really so much that the implementation is poor, as that it is implemented by a generalized, extensible aggregate function API that can not be optimized. However ... it's a bit surprising that they haven't special-cased max() and min(), transforming it to ORDER BY/LIMIT at least in cases that the optimizer could analyze and confirm that the query's equivalent.

In Oracle, max() is much less spendy because Oracle will scan the index itself and ignore the underlying table unless it needs to grab additional info from the table to satisfy the query ...