Re: 8.3 planner handling of IS NULL in aggregations - Mailing list pgsql-general

From Tom Lane
Subject Re: 8.3 planner handling of IS NULL in aggregations
Date
Msg-id 24014.1215189468@sss.pgh.pa.us
Whole thread Raw
In response to 8.3 planner handling of IS NULL in aggregations  (Sam Mason <sam@samason.me.uk>)
Responses Re: 8.3 planner handling of IS NULL in aggregations
List pgsql-general
Sam Mason <sam@samason.me.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

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [Postgresql 8.2.3] autovacuum starting up even after disabling ?
Next
From: Sam Mason
Date:
Subject: Re: 8.3 planner handling of IS NULL in aggregations