Re: Rules and Views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Curt Sampson <cjs(at)cynic(dot)net>
Cc: Zeugswetter Andreas SB SD <ZeugswetterA(at)spardat(dot)at>, Hannu Krosing <hannu(at)tm(dot)ee>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Rules and Views
Date: 2002-08-01 04:44:16
Message-ID: 4508.1028177056@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Curt Sampson <cjs(at)cynic(dot)net> writes:
> On Thu, 1 Aug 2002, Tom Lane wrote:
>> Curt Sampson <cjs(at)cynic(dot)net> writes:
> You want to be careful with this sort of stuff, since the query planner
> sometimes won't do the view as efficiently as it would do the fully
> specified equivalant query. I've posted about this here before.
>>
>> Please provide an example. AFAIK a view is a query macro, and nothing
>> else.

> I already did provide an example, and you even replied to it. :-)

But that isn't an "equivalent query". You've manually transformed
SELECT * FROM (SELECT something UNION SELECT somethingelse) WHERE foo;
into
(SELECT something WHERE foo) UNION (SELECT somethingelse WHERE foo);
As has been pointed out repeatedly, it's not entirely obvious whether
this is a valid transformation in the general case. (The knee-jerk
reaction that it's obviously right should be held in check, since SQL's
three-valued notion of boolean logic tends to trip up the intuition.)
If you can provide a proof that it's always safe, or that it's safe
under such-and-such conditions, I'll see what I can do about making it
happen.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-08-01 04:52:58 Re: Another quick question...
Previous Message Stephen Deasey 2002-08-01 04:42:17 Re: Open 7.3 items