pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Zavier Sheran <zsheran@yahoo.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: slow count()
Date: Thu, 27 Jan 2005 23:38:34 -0600
Message-ID: <20050128053834.GA11394@wolff.to> (raw)
In-Reply-To: <20050128051756.54352.qmail@web14424.mail.yahoo.com>
References: <20050128051756.54352.qmail@web14424.mail.yahoo.com>

On Thu, Jan 27, 2005 at 21:17:56 -0800,
  Zavier Sheran <zsheran@yahoo.com> wrote:
> quote from manual:
> --
> Unfortunately, there is no similarly trivial query
> that can be used to improve the performance of count()
> when applied to the entire table
> --
> 
> does count(1) also cause a sequential scan of the
> entire table? It should be able to just use the
> primary keys.

No it can't just use the index file, so that an index scan will be slower
than the sequential scan unless there is a where clause restricting the
number of rows to a small fraction (about 5%) of the table.

Search the archives for if you want to read more about this.



view thread (2+ messages)

Message-ID: <20050128053834.GA11394@wolff.to>
Permalink:  ../20050128053834.GA11394@wolff.to/
Also on:    postgresql.org/message-id/20050128053834.GA11394@wolff.to

 · 

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: bruno@wolff.to, zsheran@yahoo.com
  Subject: Re: slow count()
  In-Reply-To: <20050128053834.GA11394@wolff.to>

* 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