Re: Slow sub-selects, max and count(*) - Mailing list pgsql-sql

From Greg Stark
Subject Re: Slow sub-selects, max and count(*)
Date
Msg-id 87brmhtrcs.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Slow sub-selects, max and count(*)  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Slow sub-selects, max and count(*)  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
Josh Berkus <josh@agliodbs.com> writes:

> Max() and Count() cannot use indexes for technical reasons.   Browse through 
> the archives of SQL, PERFORM, and HACKERS for about 12,000 discussions on the 
> subject.

Please don't confuse the issue by throwing Max() and Count() into the same
basket.

The issue with Min()/Max() is that the result could be generated efficiently
by scanning indexes but it's just hard, especially given generic aggregate
functions, and the work simply hasn't been done, or even started, yet.

The issue with Count() is that people want the result to be cached in a single
per-table counter, but that can't be done as simply as that because of
transactions. People have discussed complex solutions to this but it's a much
more complex problem than it appears.

They're really two entirely separate issues.

-- 
greg



pgsql-sql by date:

Previous
From: Markus Bertheau
Date:
Subject: Re: Invalid Unicode Character Sequence found
Next
From: "Tsoloane Moahloli"
Date:
Subject: Re: date_part stored procs