Re: Counting all rows

Поиск
Список
Период
Сортировка
От Stefan Arentz
Тема Re: Counting all rows
Дата
Msg-id adf34c300706230615j4763748dn9e1dae2cb5c2524c@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Counting all rows  (Andreas Kretschmer <akretschmer@spamfence.net>)
Список pgsql-sql
On 6/23/07, Andreas Kretschmer <akretschmer@spamfence.net> wrote:
> Stefan Arentz <stefan.arentz@gmail.com> schrieb:
>
> > I need to get statistics from a bunch of tables. Simply the number of
> > records in them.
> >
> > The query plan looks like this:
> >
> > => explain select count(id) from stuff;
> >                             QUERY PLAN
> > -------------------------------------------------------------------
> >  Aggregate  (cost=1629.69..1629.70 rows=1 width=8)
> >    ->  Seq Scan on stuff  (cost=0.00..1517.75 rows=44775 width=8)
> >
> > The sequential scan kind of worries me. Is there a better/faster way to do
> > this?
>
> Yes.
>
> A "select count(*) from foo;" enforces a seq. scan. Solutions for this
> are discussed here: http://www.varlena.com/GeneralBits/120.php

Thank you Andreas. That is exactly what I was looking for.
S.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Ragnar
Дата:
Сообщение: Re: join problem
Следующее
От: manchicken
Дата:
Сообщение: Re: Counting all rows