From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: Scott Cain <cain@cshl.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: OR vs UNION
Date: Thu, 17 Jul 2003 15:24:59 -0400
Message-ID: <6219.1058469899@sss.pgh.pa.us> (raw)
In-Reply-To: <200307171200.18626.josh@agliodbs.com>
References: <1058465506.3345.15.camel@localhost.localdomain>
<200307171200.18626.josh@agliodbs.com>
Josh Berkus <josh@agliodbs.com> writes:
> Certainly a query of the above form would not benefit from being a union.
Actually we used to have code in the planner that would automatically
transform an OR query to a UNION ALL construct (the old "ksqo" option).
It fell into disfavor, partly because it didn't really preserve
semantics exactly --- IIRC, should you mention the same field value more
than once in the OR, the UNION ALL version would generate duplicate
output rows. At the time it was put in, it offered significant
performance wins, but subsequent planner improvements narrowed the gap
to nearly nothing, and we eventually took it out. I'm not sure whether
there's any possible win given the current state of the planner.
If you dig for "ksqo" in the archives you can find all the details
(at least on days when the search engine is working ;-)).
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, cain@cshl.org
Subject: Re: OR vs UNION
In-Reply-To: <6219.1058469899@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox