Re: Making planner skip hard-coded view values?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: François Beausoleil <francois(at)teksol(dot)info>
Cc: Forums postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Making planner skip hard-coded view values?
Date: 2013-03-08 03:28:31
Message-ID: 7898.1362713311@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?iso-8859-1?Q?Fran=E7ois_Beausoleil?= <francois(at)teksol(dot)info> writes:
> I have a view similar to this (regression at end):

> CREATE VIEW published_reports AS
> SELECT true AS aired, *
> FROM published_aired_reports
> UNION ALL
> SELECT false AS aired, *
> FROM published_unaired_reports;

> Given that view definition, I expected a WHERE clause with the hard-coded value to ignore one of the tables:

> SELECT COUNT(*) FROM published_reports WHERE aired;

> This is on 9.1.3, but may have changed later.

Works for me. After a quick glance at the release notes, I think this was
fixed in 9.1.4:

* Fix planning of UNION ALL subqueries with output columns that are not simple variables (Tom Lane)

Planning of such cases got noticeably worse in 9.1 as a result of a misguided fix for "MergeAppend child's targetlist doesn't match MergeAppend" errors. Revert that fix and do it another way.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Guy Rouillier 2013-03-08 03:33:44 Re: selecting for type cast failures
Previous Message David Johnston 2013-03-08 03:16:55 Re: crosstab creating multiple rows for same id