Re: row estimate for partial index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: row estimate for partial index
Дата
Msg-id 1860907.1673881178@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: row estimate for partial index  (Harmen <harmen@lijzij.de>)
Ответы Re: row estimate for partial index  (Harmen <harmen@lijzij.de>)
Список pgsql-general
Harmen <harmen@lijzij.de> writes:
> On Sat, Jan 14, 2023 at 11:23:07AM -0500, Tom Lane wrote:
>> If you are running a reasonably recent PG version you should be able to
>> fix that by setting up "extended statistics" on that pair of columns:

>   CREATE STATISTICS dist4 (ndistinct) ON deleted, org_id FROM contactsbool;
>   CREATE STATISTICS dist4b (ndistinct) ON org_id, deleted FROM contactsbool;

1. ndistinct is not the correct stats type for this problem.
(I think dependencies is, but generally speaking, it's not worth
trying to be smarter than the system about which ones you need.
Just create 'em all.)

2. Per the CREATE STATISTICS man page, the order of the columns is
not significant, so you're just doubling the amount of work for
ANALYZE without gaining anything.

I think you will find that

CREATE STATISTICS stats1 ON deleted, org_id FROM contactsbool;

is enough to fix this.  It improved the estimate for me in
v14 and HEAD, anyway.

            regards, tom lane



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

Предыдущее
От: HECTOR INGERTO
Дата:
Сообщение: RE: Are ZFS snapshots unsafe when PGSQL is spreading through multiple zpools?
Следующее
От: Joe Conway
Дата:
Сообщение: Re: glibc initdb options vs icu compatibility questions (PG15)