Re: Analyze on table creation?

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Analyze on table creation?
Дата
Msg-id 20230626200023.fpu2jeb3qcst4n73@awork3.anarazel.de
обсуждение исходный текст
Ответ на Analyze on table creation?  (James Coleman <jtc331@gmail.com>)
Ответы Re: Analyze on table creation?  (James Coleman <jtc331@gmail.com>)
Список pgsql-hackers
Hi,

On 2023-06-26 13:40:49 -0400, James Coleman wrote:
> Have we ever discussed running an analyze immediately after creating a table?

That doesn't make a whole lot of sense to me - we could just insert the
constants stats we wanted in that case.


> Consider the following:
> 
> create table stats(i int, t text not null);
> explain select * from stats;
>    Seq Scan on stats  (cost=0.00..22.70 rows=1270 width=36
> analyze stats;
> explain select * from stats;
>    Seq Scan on stats  (cost=0.00..0.00 rows=1 width=36)
> 
> Combined with rapidly increasing error margin on row estimates when
> adding joins means that a query joining to a bunch of empty tables
> when a database first starts up can result in some pretty wild plan
> costs.

The issue is that the table stats are likely going to quickly out of date in
that case, even a hand full of inserts (which wouldn't trigger
autovacuum analyzing) would lead to the "0 rows" stats causing very bad plans.

Greetings,

Andres Freund



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Detecting use-after-free bugs using gcc's malloc() attribute
Следующее
От: Mikhail Gribkov
Дата:
Сообщение: Re: Fixing tab-complete for dollar-names