pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Owen Jacobson <ojacobson@osl.com>
To: pgsql-sql@postgresql.org
Subject: Faster count(*)?
Date: Tue, 9 Aug 2005 15:39:33 -0700
Message-ID: <000101c59d33$36a4a560$9b00015a@osl.com> (raw)

Salve.

I understand from various web searches and so on that PostgreSQL's MVCC
mechanism makes it very hard to use indices or table metadata to optimise
count(*).  Is there a better way to guess the "approximate size" of a table?

I'm trying to write a trigger that fires on insert and performs some
maintenance (collapsing overlapping boxes into a single large box,
specifically) as the table grows.  My initial attempt involved count(*) and,
as the number of pages in the table grew, that trigger bogged down the
database.

Any thoughts?

-O




view thread (2+ messages)  latest in thread

Message-ID: <000101c59d33$36a4a560$9b00015a@osl.com>
Permalink:  ../000101c59d33$36a4a560$9b00015a@osl.com/
Also on:    postgresql.org/message-id/000101c59d33$36a4a560$9b00015a@osl.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-sql@postgresql.org
  Cc: ojacobson@osl.com
  Subject: Re: Faster count(*)?
  In-Reply-To: <000101c59d33$36a4a560$9b00015a@osl.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