Re: Bitmap scan is undercosted?

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Bitmap scan is undercosted?
Дата
Msg-id CAMkU=1wkjV3CjWE=Cksp_qSZhNbxTOcyc=dDuwhnDzVxGMu6qQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Bitmap scan is undercosted?  (Vitaliy Garnashevich <vgarnashevich@gmail.com>)
Ответы Re: Bitmap scan is undercosted?  (Vitaliy Garnashevich <vgarnashevich@gmail.com>)
Список pgsql-performance
On Fri, Dec 1, 2017 at 3:54 PM, Vitaliy Garnashevich < vgarnashevich@gmail.com> wrote: > On 02/12/2017 01:11, Justin Pryzby wrote: > >> I tried to reproduce this issue and couldn't, under PG95 and 10.1: >> >> On Fri, Dec 01, 2017 at 12:34:27PM -0600, Justin Pryzby wrote: >> >>> On Fri, Dec 01, 2017 at 07:40:08PM +0200, Vitaliy Garnashevich wrote: >>> >>>> We recently had an issue in production, where a bitmap scan was chosen >>>> instead of an index scan. Despite being 30x slower, the bitmap scan had >>>> about the same cost as the index scan. >>>> drop table if exists aaa; >>>> create table aaa as select (id%100)::int num, (id%10=1)::bool flag from >>>> generate_series(1, 10000000) id; >>>> create index i1 on aaa (num); >>>> create index i2 on aaa (flag); >>>> analyze aaa; >>>> >>> What is: >> effective_io_concurrency >> max_parallel_workers_per_gather (I gather you don't have this) >> > effective_io_concurrency = 0 > max_parallel_workers_per_gather = 0 > > Did you notice random_page_cost = 1.5 ? > For the aaa.num = 39 case, the faster index scan actually does hit 15 times more buffers than the bitmap scan does. While 1.5 is lot lower than 4.0, it is still much higher than the true cost of reading a page from the buffer cache. This why the index scan is getting punished. You could lower random_page_cost and seq_page_cost to 0, to remove those considerations. (I'm not saying you should do this on your production system, but rather you should do it as a way to investigate the issue. But it might make sense on production as well) > For this test I'm using SSD and Windows (if that matters). On production > we also use SSD, hence lower random_page_cost. But with the default > random_page_cost=4.0, the difference in cost between the index scan plan > and the bitmap scan plan is even bigger. Since it is all shared buffers hits, it doesn't matter if you have SSD for this particular test case. Cheers, Jeff

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

Предыдущее
От: Roman Konoval
Дата:
Сообщение: Re: Bad plan for ltree predicate <@
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: Bitmap scan is undercosted?