Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Dec 16, 2013 at 2:04 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The problem is that that optimization is a crock; see the comments
>> for create_or_index_quals(). We can't just turn it loose to CNF-ify
>> every OR it might find. The case that we support at the moment is
>> to CNF-ify whichever single OR condition looks like the best win,
>> and it's hard to see how to do that without any index knowledge.
> Could we get by without actually converting to CNF?
The hard part is not extracting the partial qual. The hard part is
trying to make sure that adding this entirely-redundant scan qual doesn't
catastrophically degrade join size estimates. The hack of making an
inverse adjustment to the original OR clause's selectivity works, more or
less, for a single join OR condition. I don't think it works if there's
several modified OR conditions (possibly covering different sets of
relations).
regards, tom lane