pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
slow count()
2+ messages / 2 participants
[nested] [flat]

* slow count()
@ 2005-01-28 05:17 Zavier Sheran <zsheran@yahoo.com>
  2005-01-28 05:38 ` Re: slow count() Bruno Wolff III <bruno@wolff.to>
  0 siblings, 1 reply; 2+ messages in thread

From: Zavier Sheran @ 2005-01-28 05:17 UTC (permalink / raw)
  To: pgsql-performance

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.

-Zavier

=====
---
zavier.net - Internet Solutions
---


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: slow count()
  2005-01-28 05:17 slow count() Zavier Sheran <zsheran@yahoo.com>
@ 2005-01-28 05:38 ` Bruno Wolff III <bruno@wolff.to>
  0 siblings, 0 replies; 2+ messages in thread

From: Bruno Wolff III @ 2005-01-28 05:38 UTC (permalink / raw)
  To: Zavier Sheran <zsheran@yahoo.com>; +Cc: pgsql-performance

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.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-01-28 05:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-28 05:17 slow count() Zavier Sheran <zsheran@yahoo.com>
2005-01-28 05:38 ` Bruno Wolff III <bruno@wolff.to>

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