Re: Performance of count(*)

Поиск
Список
Период
Сортировка
Искать
От
Michael Stone
Тема
Re: Performance of count(*)
Дата
Msg-id
20070322144149.GF11402@mathom.us
Ответ на
Список
Дерево обсуждения
Performance of count(*) Andreas Tille <tillea@rki.de>
Re: Performance of count(*) Andreas Kostyrka <andreas@kostyrka.org>
Re: Performance of count(*) Andreas Tille <tillea@rki.de>
Re: Performance of count(*) Andreas Kostyrka <andreas@kostyrka.org>
Re: Performance of count(*) Michael Fuhr <mike@fuhr.org>
Re: Performance of count(*) Carlos Moreno <moreno_pg@mochima.com>
Re: Performance of count(*) "Luke Lonergan" <llonergan@greenplum.com>
Re: Performance of count(*) Albert Cervera Areny <albert@sedifa.com>
Re: Performance of count(*) ismo.tuononen@solenovo.fi
Re: Performance of count(*) Bill Moran <wmoran@collaborativefusion.com>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) mark@mark.mielke.cc
Re: Performance of count(*) "Craig A. James" <cjames@modgraph-usa.com>
Re: Performance of count(*) Tino Wildenhain <tino@wildenhain.de>
Re: Performance of count(*) "Craig A. James" <cjames@modgraph-usa.com>
Re: Performance of count(*) Steve Atkins <steve@blighty.com>
Re: Performance of count(*) "Craig A. James" <cjames@modgraph-usa.com>
Re: Performance of count(*) Tom Lane <tgl@sss.pgh.pa.us>
Re: Performance of count(*) "Craig A. James" <cjames@modgraph-usa.com>
Re: Performance of count(*) Tom Lane <tgl@sss.pgh.pa.us>
Re: Performance of count(*) Guido Neitzer <lists@event-s.net>
Re: Performance of count(*) Steve Atkins <steve@blighty.com>
Re: Performance of count(*) Tino Wildenhain <tino@wildenhain.de>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) Tino Wildenhain <tino@wildenhain.de>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) Tino Wildenhain <tino@wildenhain.de>
Re: Performance of count(*) "Merlin Moncure" <mmoncure@gmail.com>
Re: Performance of count(*) Tino Wildenhain <tino@wildenhain.de>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) "Craig A. James" <cjames@modgraph-usa.com>
Re: Performance of count(*) Tino Wildenhain <tino@wildenhain.de>
Re: Performance of count(*) Brian Hurt <bhurt@janestcapital.com>
Re: Performance of count(*) "Craig A. James" <cjames@modgraph-usa.com>
Re: Performance of count(*) Mario Weilguni <mweilguni@sime.com>
Re: Performance of count(*) "Merlin Moncure" <mmoncure@gmail.com>
Re: Performance of count(*) Michael Stone <mstone+postgres@mathom.us>
Re: Performance of count(*) "Jonah H. Harris" <jonah.harris@gmail.com>
Re: Performance of count(*) Mario Weilguni <mweilguni@sime.com>
Re: Performance of count(*) Andreas Kostyrka <andreas@kostyrka.org>
Re: Performance of count(*) Mario Weilguni <mweilguni@sime.com>
Re: Performance of count(*) ismo.tuononen@solenovo.fi
On Thu, Mar 22, 2007 at 09:39:18AM -0400, Merlin Moncure wrote:
>You can get the approximate count by selecting reltuples from
>pg_class.  It is valid as of last analyze.

Of course, that only works if you're not using any WHERE clause. 
Here's a (somewhat ugly) example of getting an approximate count based 
off the statistics info, which will work for more complicated queries:
http://archives.postgresql.org/pgsql-sql/2005-08/msg00046.php
The ugliness is that you have to provide the whole query as a 
parameter to the function, instead of using it as a drop-in replacement 
for count. I assume that the TODO item is to provide the latter, but for 
now this method can be useful for UI type stuff where you just want to 
know whether there's "a little" or "a lot".

Mike Stone
В списке pgsql-performance по дате отправления
От: Michael Fuhr
Дата:
Сообщение: Re: Performance of count(*)
От: Luke Lonergan
Дата:
Сообщение: Re: Performance of count(*)
FAQ