Re: Speedier count(*)
| От | Gavin Sherry |
|---|---|
| Тема | Re: Speedier count(*) |
| Дата | |
| Msg-id | Pine.LNX.4.58.0508112035580.1719@linuxworld.com.au обсуждение |
| Ответ на | Re: Speedier count(*) (Tino Wildenhain <tino@wildenhain.de>) |
| Ответы |
Re: Speedier count(*)
|
| Список | pgsql-performance |
On Thu, 11 Aug 2005, Tino Wildenhain wrote:
> Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner:
> > Here's a trigger I wrote to perform essentially the same purpose. The nice
> > thing about this is it keeps the number up to date for you, but you do incur
> > slight overhead.
> ...
> >
> > CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON test FOR EACH ROW EXECUTE
> > PROCEDURE del_rowcount();
> > CREATE TRIGGER add_rowcount_tr BEFORE INSERT ON test FOR EACH ROW EXECUTE
> > PROCEDURE add_rowcount();
> >
> > INSERT INTO rowcount (tablename) VALUES ('test');
> ...
>
> beware of problems with concurrency and even what happens
> if transactions roll back. Maybe you can "fix" it a bit
> by regulary correcting the count via cronjob or so.
What problems? MVCC takes care of this.
Gavin
В списке pgsql-performance по дате отправления: