Re: Seqscan in MAX(index_column)

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Seqscan in MAX(index_column)
Date: 2003-09-05 02:20:22
Message-ID: 200309050220.h852KMG17572@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway wrote:
> On Thu, 2003-09-04 at 22:02, Bruce Momjian wrote:
> > My idea is that if a transaction doing a COUNT(*) would first look to
> > see if there already was a visible cached value, and if not, it would do
> > the COUNT(*) and insert into the cache table. Any INSERT/DELETE would
> > remove the value from the cache. As I see it, the commit of the
> > INSERT/DELETE transaction would then auto-invalidate the cache at the
> > exact time the transaction commits. This would allow MVCC visibility of
> > the counts.
>
> But this means that some of the time (indeed, *much* of the time),
> COUNT(*) would require a seqscan of the entire table. Since at many
> sites that will take an enormous amount of time (and disk I/O), that
> makes this solution infeasible IMHO.
>
> In general, I don't think this is worth doing.

It is possible it isn't worth doing. Can the INSERT/DELETE
incrementing/decrementing the cached count work reliabily?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2003-09-05 02:35:41 TODO item: psql tab-completion
Previous Message Neil Conway 2003-09-05 02:16:50 Re: Seqscan in MAX(index_column)