On Thu, 1 Aug 2002, Tom Lane wrote:
> 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);
Right.
> As has been pointed out repeatedly, it's not entirely obvious whether
> this is a valid transformation in the general case.
Right. And I agreed that it as soon as you first pointed it out.
And still do.
But the message I was replying to was a similar union query, and I was
thinking that that person might be having a similar initial intuitive
reaction, "well, it looks kinda the same." I just wanted to note that
you need to check this stuff with explain, rather than blindly assuming
you know what's going on.
> 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.
It's on my list of things to do, but not high enough that it's
likely I'll ever get to it. :-)
BTW, if anybody can think of a way to make a view that really does
represent my original query, I'd appreciate a hint.
cjs
--
Curt Sampson <cjs@cynic.net> +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're
alllight. --XTC