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

Re: select count(*) from a large table is very slow

From: "Daniel Cristian Cruz" <danielcristian(at)gmail(dot)com>
To: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
Cc: "Kenneth Marshall" <ktm(at)rice(dot)edu>, "Jessica Richard" <rjessil(at)yahoo(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: select count(*) from a large table is very slow
Date: 2007-05-18 13:58:59
Message-ID: 48d0cacb0705180658n1ce65297xa9f28d56dd4f8426@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
2007/5/18, Jonah H. Harris <jonah(dot)harris(at)gmail(dot)com>:
> Yes, a summary table updated by triggers is the only way to have
> correct numbers... but you also pay the overhead of maintaining those
> numbers on every INSERT/UPDATE statement.  If you just need
> *reasonable* guesstimates, use reltuples in pg_class after an analyze.

Oops... INSERT or DELETE... :)

And remember that if using TRUNCATE, it will not run your trigger and
you will need to reset the counter manually.

Regards...
-- 
Daniel Cristian Cruz

In response to

Responses

pgsql-admin by date

Next:From: Jonah H. HarrisDate: 2007-05-18 14:00:01
Subject: Re: select count(*) from a large table is very slow
Previous:From: Jonah H. HarrisDate: 2007-05-18 13:30:36
Subject: Re: select count(*) from a large table is very slow

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