Re: count(*) performance improvement ideas - Mailing list pgsql-hackers

From Tom Lane
Subject Re: count(*) performance improvement ideas
Date
Msg-id 21266.1205897206@sss.pgh.pa.us
Whole thread Raw
In response to Re: count(*) performance improvement ideas  ("Stephen Denne" <Stephen.Denne@datamail.co.nz>)
List pgsql-hackers
"Stephen Denne" <Stephen.Denne@datamail.co.nz> writes:
> Tom Lane wrote
>> Umm ... AFAICS there is no need for an UPDATE to touch the count table
>> at all.  You'd only need ON INSERT and ON DELETE triggers.

> I'm not referring to updates of my base table... the single row inserted was referring to the delta row...

> I'm trying to group together a large number of +1 or -1 deltas into a single delta per transaction.

Oh.  You can't realistically do that from the level of individual ON
INSERT/DELETE triggers --- as you've found out, you end up with about
the same number of dead rows anyway.  Collapsing a transaction's changes
into a single row would require keeping some intra-transaction state,
which is do-able at the C-code level but not from plpgsql.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Stephen Denne"
Date:
Subject: Re: count(*) performance improvement ideas
Next
From: Tom Lane
Date:
Subject: Re: count(*) performance improvement ideas