2016-12-21 0:01 GMT+01:00 Tom Lane <t...@sss.pgh.pa.us>:
> Pavel Stehule <pavel.steh...@gmail.com> writes:
> > I am trying to fix slow query on PostgreSQL 9.5.4.
> > The data are almost in RAM
> If it's all in RAM, you'd likely be well-served to lower random_page_cost.
> It looks to me like the planner is estimating pretty accurately how many
> heap fetches will be eliminated by using the extra index; where it's off
> seems to be in the cost of those heap fetches relative to the index work.
When I decrease random page cost, then the cost of bitmapscan was decreased
https://explain.depesz.com/s/7CAJ .. random page cost 2
https://explain.depesz.com/s/iEBW .. random page cost 2, bitmapscan off
https://explain.depesz.com/s/W4zw .. random page cost 2
https://explain.depesz.com/s/Gar .. random page cost 1, bitmapscan off
I played with other costs, but without any success, the cost of bitmapscan
is significantly cheaper then index scan.
> regards, tom lane