Re: 8.3 planner handling of IS NULL in aggregations

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: 8.3 planner handling of IS NULL in aggregations
Date: 2008-07-04 16:37:48
Message-ID: 24014.1215189468@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
> I've just noticed that the planner in 8.3.3 doesn't seem to realize the
> difference in the result of the following:
> GROUP BY col;
> GROUP BY col IS NULL;

Yeah, estimate_num_groups doesn't have any special knowledge about IS
NULL -- it just sees this as "an expression involving col". The
general assumption about that is that the expression doesn't reduce
the number of groups (think "col + 1" for example). In general I'd
rather it overestimated the number of groups than underestimated,
so I don't think this heuristic is really wrong.

Putting in a special case for IS NULL seems a bit silly, but maybe
checking for a boolean result type would cover enough real-world
uses to be worth the trouble? Not sure.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2008-07-04 17:22:37 Re: 8.3 planner handling of IS NULL in aggregations
Previous Message Adrian Klaver 2008-07-04 15:23:10 Re: [Postgresql 8.2.3] autovacuum starting up even after disabling ?