Re: Bad cost estimate with FALSE filter condition - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Bad cost estimate with FALSE filter condition
Date
Msg-id 55072B0F.5090104@agliodbs.com
Whole thread Raw
In response to Bad cost estimate with FALSE filter condition  (Josh Berkus <josh@agliodbs.com>)
List pgsql-performance
On 03/16/2015 11:26 AM, Tom Lane wrote:
> Josh Berkus <josh@agliodbs.com> writes:
>> So ... should I assume my diagnosis is correct?  Haven't heard any other
>> suggestions.
>
> I don't see any reason to think this is worth worrying about, or worth
> spending planner cycles on to produce a cosmetically nicer cost estimate.

I wouldn't say it's critical, but there's two issues:

1) users are confused when they see the plan, especially if it's chosen
in preference to a lower-cost plan.  It's counter-intuitive for EXPLAIN
to not display the "real" estimated cost.

2) Tools which attempt to do some kind of useful aggregation or event
handling around estimated plan cost have to write special workarounds
for these cases.

Is there anything *useful* about the existing behavior such that we'd
like to preserve it?  Or is it just a matter of Nobody's Submitted A
Patch Yet?

I ask because I'm thinking about a patch, so if changing this will break
a lot of stuff, that's a good thing to know.

> One-time filters always apply at the top plan level so they're unlikely
> to change any planner choices.  Moreover, for any case other than the
> not-terribly-interesting constant FALSE case, we're better off assuming
> that the filter condition will be true (and so there's nothing to adjust).

Except that we *don't* get back the same estimate for a TRUE filter
condition.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


pgsql-performance by date:

Previous
From: Vivekanand Joshi
Date:
Subject: Re: Performance issues
Next
From: Jim Nasby
Date:
Subject: Re: EXPLAIN (no ANALYZE) taking an hour for INSERT FROM SELECT