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

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

From: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
To: "Kenneth Marshall" <ktm(at)rice(dot)edu>
Cc: "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:30:36
Message-ID: 36e682920705180630y2c28cdc5m14af94d6d62e1daf@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
On 5/18/07, Kenneth Marshall <ktm(at)rice(dot)edu> wrote:
> Make a summary table and select from there instead.

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.

-- 
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation            | fax: 732.331.1301
33 Wood Ave S, 3rd Floor            | jharris(at)enterprisedb(dot)com
Iselin, New Jersey 08830            | http://www.enterprisedb.com/

In response to

Responses

pgsql-admin by date

Next:From: Daniel Cristian CruzDate: 2007-05-18 13:58:59
Subject: Re: select count(*) from a large table is very slow
Previous:From: Jessica RichardDate: 2007-05-18 13:26:17
Subject: cross database references...

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