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