Re: Bad cost estimate with FALSE filter condition

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Bad cost estimate with FALSE filter condition
Date: 2015-03-16 19:12:15
Message-ID: 55072B0F.5090104@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 03/16/2015 11:26 AM, Tom Lane wrote:
> Josh Berkus <josh(at)agliodbs(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jim Nasby 2015-03-16 19:23:11 Re: EXPLAIN (no ANALYZE) taking an hour for INSERT FROM SELECT
Previous Message Vivekanand Joshi 2015-03-16 18:32:19 Re: Performance issues