Re: Select max(foo) and select count(*) optimization

Поиск
Список
Период
Сортировка
От Mark Kirkwood
Тема Re: Select max(foo) and select count(*) optimization
Дата
Msg-id 3FFB0C6D.9020704@paradise.net.nz
обсуждение исходный текст
Ответ на Re: Select max(foo) and select count(*) optimization  ("D'Arcy J.M. Cain" <darcy@druid.net>)
Список pgsql-performance
if this situation persists after 'analyze certificate', then you need to:

increase the statistics target 'alter table certificate alter column
certificate_id set statistics 100'

or

'vacuum full certificate'

i.e : there are lots of (dead) updated or deleted tuples in the
relation, distributed in such a way as to throw off analyze's estimate.

regards

Mark

D'Arcy J.M. Cain wrote:

>
>Well, I did this:
>
>cert=# select relpages,reltuples from pg_class where relname= 'certificate';
> relpages |  reltuples
>----------+-------------
>   399070 | 2.48587e+07
>(1 row)
>
>Casting seemed to help:
>
>cert=# select relpages,reltuples::bigint from pg_class where relname=
>'certificate';
> relpages | reltuples
>----------+-----------
>   399070 |  24858736
>(1 row)
>
>But:
>
>cert=# select count(*) from certificate;
>[*Crunch* *Crunch* *Crunch*]
>  count
>----------
> 19684668
>(1 row)
>
>Am I missing something?  Max certificate_id is 20569544 btw.
>
>
>


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Inefficient SELECT with OFFSET and LIMIT
Следующее
От: Michael Shapiro
Дата:
Сообщение: PgAdmin startup query VERY slow