Strange influence of default_statistics_target

From: Вадим Акбашев <ufaowl(at)gmail(dot)com>
To: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Strange influence of default_statistics_target
Date: 2017-01-18 07:54:43
Message-ID: CALoKji-qHPvXAL7omEoB0n2g5WudFDmqXf3tsMBUwYdtiiQRVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello!
I have encountered a problem with querry plan building:
I'd set default_statistics_target=700, run analyze. Postgres optimize had
chosen plan with hash_join and it took ~1 min for qerry to complete.
Then i set default_statistics_target=500 and the plan was significantly
changed and was using merge_join instead, complition time reduced in
hundreds times, cost reduced drastically.
Now i can't understand why more precise statistics leads to less optimized
plan and what is the right way to use default_statistics_target parameter?
I attach both good and bad querry plans and the querry itself

Attachment Content-Type Size
dst500.txt text/plain 5.3 KB
dst700.txt text/plain 5.8 KB
querry.sql application/sql 4.1 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Joel Sanger 2017-01-18 09:58:06 BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions
Previous Message Michael Paquier 2017-01-18 03:34:51 Re: Bug in Physical Replication Slots (at least 9.5)?