From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Christopher Browne <cbbrowne(at)acm(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Seqscan in MAX(index_column) |
Date: | 2003-09-05 04:28:25 |
Message-ID: | 200309050428.h854SPk03147@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Christopher Browne wrote:
> Wouldn't this more or less be the same thing as having a trigger that
> does, upon each insert/delete "update pg_counts set count = count + 1
> where reltable = 45232;"? (... where 1 would be -1 for deletes, and where
> 45232 is the OID of the table...)
>
> Technically, it seems _feasible_, albeit with the problem that it
> turns pg_counts into a pretty horrid bottleneck. If lots of backends
> are updating that table, then row 45232 in pg_counts becomes
> troublesome because all those processes have to serialize around
> updating it.
>
> And if I have tables where I insert lots of data, but couldn't care
> less how many rows they have, this effort is wasted.
>
> When I was curious as to how COUNT might be maintained, I was pretty
> sure that this wouldn't be the preferred method...
See my later idea of the trigger doing +/-1 rather than locking the
value during the transaction.
If we don't do it this way, I can't think of another way that would
honor MVCC visibility.
--
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
From | Date | Subject | |
---|---|---|---|
Next Message | Dennis Bjorklund | 2003-09-05 05:18:43 | Re: Seqscan in MAX(index_column) |
Previous Message | Bruce Momjian | 2003-09-05 04:01:17 | Re: Warning for missing createlang |