Re: [PERFORM] Understanding histograms

2008-04-30 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > This is something that needs some serious thought though. In the case of > partitioned tables I've seen someone get badly messed up plans because they > had a couple hundred partitions each of which estimated to return 1 row. In > fact of course they all

Re: [PERFORM] Understanding histograms

2008-04-30 Thread Gregory Stark
"Tom Lane" <[EMAIL PROTECTED]> writes: > Right. As a matter of policy we never estimate less than one matching > row; and I've seriously considered pushing that up to at least two rows > except when we see that the query condition matches a unique constraint. > You can get really bad join plans

Re: [PERFORM] Understanding histograms

2008-04-30 Thread Tom Lane
Jeff Davis <[EMAIL PROTECTED]> writes: > On Wed, 2008-04-30 at 10:43 -0400, Tom Lane wrote: >> Surely that's not very sane? The MCV list plus histogram generally >> don't include every value in the table. > My understanding of Len's question is that, although the MCV list plus > the histogram don

Re: [PERFORM] Understanding histograms

2008-04-30 Thread Jeff Davis
On Wed, 2008-04-30 at 10:43 -0400, Tom Lane wrote: > > Instead I would expect an estimate of "rows=0" for values of const > > that are not in the MCV list and not in the histogram. > > Surely that's not very sane? The MCV list plus histogram generally > don't include every value in the table. II

Re: [PERFORM] Understanding histograms

2008-04-30 Thread Tom Lane
"Len Shapiro" <[EMAIL PROTECTED]> writes: > I asked about n_distinct, whose documentation reads in part "The > negated form is used when ANALYZE believes that the number of distinct > values is likely to increase as the table grows". and I asked about > why ANALYZE believes that the number of dist

Re: [PERFORM] Understanding histograms

2008-04-29 Thread Len Shapiro
Tom, Thank you for your prompt reply. On Tue, Apr 29, 2008 at 10:19 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > Len Shapiro <[EMAIL PROTECTED]> writes: > > 1. Why does Postgres come up with a negative n_distinct? > > It's a fractional representation. Per the docs: > > > stadistinct float4

Re: [PERFORM] Understanding histograms

2008-04-29 Thread Tom Lane
Len Shapiro <[EMAIL PROTECTED]> writes: > 1. Why does Postgres come up with a negative n_distinct? It's a fractional representation. Per the docs: > stadistinct float4 The number of distinct nonnull data values in > the column. A value greater than zero is the actual number of distin

[PERFORM] Understanding histograms

2008-04-29 Thread Len Shapiro
I hope I am posting to the right list. I am running Postgresql 8.1.9 and don't understand the behavior of histograms for data items not in the MVC list. I teach databases and want to use Postgres as an example. I will appreciate any help that anyone can provide. Here is the data I am using. I a