Re: Unnecessarily imprecise stats for very small tables leading to bad plans

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Unnecessarily imprecise stats for very small tables leading to bad plans
Date: 2018-06-06 15:28:13
Message-ID: 9101.1528298893@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de> writes:
> Intuitively, I'd say pg_statistic can represent such a small dataset
> perfectly. But instead, most_common_values only contains one of the two
> distinct values. This seems like a bug to me. I looked at the code for
> why this is the case, but couldn't find an answer right-away. Any
> input?

ANALYZE has a hard-and-fast rule that a value must appear more than once
in the sample in order to possibly be considered an MCV.

Perhaps we could tinker with that if the sample is known to comprise
the entire table, but it feels a bit ad-hoc.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Frits Jalvingh 2018-06-06 16:19:27 Re: BUG #15225: [XX000] ERROR: invalid DSA memory alloc request size 1073741824 / Where: parallel worker
Previous Message Tom Lane 2018-06-06 14:48:09 Re: psql crashes found when executing slash commands