Re: OR vs UNION - Mailing list pgsql-sql

From Tom Lane
Subject Re: OR vs UNION
Date
Msg-id 6219.1058469899@sss.pgh.pa.us
Whole thread Raw
In response to Re: OR vs UNION  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "Girish Bajaj"
Date:
Subject: Re: Table Partitioning and Rules
Next
From: Josh Berkus
Date:
Subject: Re: Table Partitioning and Rules