From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Claus Stadler <cstadler(at)informatik(dot)uni-leipzig(dot)de>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: ...WHERE TRUE" condition in union results in bad query pla |
Date: | 2012-04-03 14:57:43 |
Message-ID: | CA+TgmoY0rAmQ1W4WsixQajmFpKBAV4i9m4rnN3F2R=2qR+R2zw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Sat, Mar 3, 2012 at 10:03 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Claus Stadler <cstadler(at)informatik(dot)uni-leipzig(dot)de> writes:
>> Query optimizer glitch: "...WHERE TRUE" condition in union results in
>> bad query plan ...
>
> Yeah, this is because a nonempty WHERE clause defeats simplifying the
> UNION ALL into a simple "append relation" (cf is_safe_append_member()).
> The planner will eventually figure out that WHERE TRUE is a no-op,
> but that doesn't happen till later (and there are good reasons to do
> things in that order).
>
> Sooner or later I'd like to relax the restriction that appendrel members
> can't have extra WHERE clauses, but don't hold your breath waiting...
Does this comment need updating?
* Note: the data structure assumes that append-rel members are single
* baserels. This is OK for inheritance, but it prevents us from pulling
* up a UNION ALL member subquery if it contains a join. While that could
* be fixed with a more complex data structure, at present there's not much
* point because no improvement in the plan could result.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Istvan Endredy | 2012-04-03 15:11:55 | bad planning with 75% effective_cache_size |
Previous Message | Andrew Dunstan | 2012-04-03 14:30:00 | Re: Performance of SQL Function versus View |