Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group