Re: Slow sub-selects, max and count(*)

From: Greg Stark <gsstark(at)mit(dot)edu>
To: josh(at)agliodbs(dot)com
Cc: "Richard Sydney-Smith" <richard(at)ibisaustralia(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slow sub-selects, max and count(*)
Date: 2004-03-28 06:31:31
Message-ID: 87brmhtrcs.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Josh Berkus <josh(at)agliodbs(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tsoloane Moahloli 2004-03-29 07:30:46 Re: date_part stored procs
Previous Message Markus Bertheau 2004-03-27 10:02:27 Re: Invalid Unicode Character Sequence found