Re: Optimizer misses big in 10.4 with BRIN index

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Optimizer misses big in 10.4 with BRIN index
Дата
Msg-id CAKJS1f86rpqPGAxYGndo8zzDM-9xuJM=EBaqQ6QBdxOy8Eg_+w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Optimizer misses big in 10.4 with BRIN index  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Ответы Re: Optimizer misses big in 10.4 with BRIN index  (Emre Hasegeli <emre@hasegeli.com>)
Список pgsql-hackers
On 26 July 2018 at 04:50, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote:
> My guess is this is the root cause - the estimated number of rows is much
> higher than in practice (3377106 vs. 23040), so at the end the seqscan is
> considered to be slightly cheaper and wins. But the actual row count is
> ~150x lower, making the bitmap index scan way faster.

Isn't the 23040 just the totalpages * 10 per `return totalpages * 10;`
in bringetbitmap()?

The BRIN index costing was changed quite dramatically in [1] which
first appears in pg10. Previous to that patch BRIN assumed it would
touch total_pages * pred_selectivity blocks in the bitmap scan.  That
worked well when the table happened to be perfectly ordered by the
column of the BRIN index, but was pretty broken when the order was
random.  That lead to BRIN indexes being used when they really
shouldn't have been.  The patch tried to fix that by using what
information it could. That was basically the correlation statistics
from pg_statistic.   It appeared that the patch was producing more
realistic plans than unpatched, so we went with it, but it's
definitely not perfect; what statistics are?

It would be quite interesting to know the result of:

select stakind3 from pg_Statistic where starelid =
'schema0_lab.data_table'::regclass;

I also see the estimated costs of either plan are very close, so the
chosen plan may well be quite susceptible to changing after different
ANALYZE runs on the table.

[1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=7e534adcdc70866e7be74d626b0ed067c890a251

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


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

Предыдущее
От: Ashutosh Bapat
Дата:
Сообщение: Re: Expression errors with "FOR UPDATE" and postgres_fdw withpartition wise join enabled.
Следующее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: [HACKERS] WAL logging problem in 9.4.3?