pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
To: Postgres Performance <pgsql-performance@postgresql.org>
Subject: Re: select count(*)  very slow on an already vacuumed table.
Date: Wed, 14 Apr 2004 20:08:58 +0100
Message-ID: <200404142008.58533.dev@archonet.com> (raw)
In-Reply-To: <407D7A89.60508@trade-india.com>
References: <407D7A89.60508@trade-india.com>

On Wednesday 14 April 2004 18:53, Rajesh Kumar Mallah wrote:
> Hi
> I have .5 million rows in a table. My problem is select count(*) takes
> ages. VACUUM FULL does not help. can anyone please tell me
> how to i enhance the performance of the setup.

> SELECT count(*) from eyp_rfi;

If this is the actual query you're running, and you need a guaranteed accurate 
result, then you only have one option: write a trigger function to update a 
table_count table with every insert/delete to eyp_rfi.

There is loads of info on this (and why it isn't as simple as you might think) 
in the archives. First though:
1. Is this the actual query, or just a representation?
2. Do you need an accurate figure or just something "near enough"?

-- 
  Richard Huxton
  Archonet Ltd



view thread (7+ messages)  latest in thread

Message-ID: <200404142008.58533.dev@archonet.com>
Permalink:  ../200404142008.58533.dev@archonet.com/
Also on:    postgresql.org/message-id/200404142008.58533.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, mallah@trade-india.com
  Subject: Re: select count(*)  very slow on an already vacuumed table.
  In-Reply-To: <200404142008.58533.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox