Re: planner missing a trick for foreign tables w/OR conditions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Eric Ridge <e_ridge(at)tcdi(dot)com>
Subject: Re: planner missing a trick for foreign tables w/OR conditions
Date: 2013-12-16 23:59:12
Message-ID: 18548.1387238352@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Mon, Dec 16, 2013 at 2:04 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2013-12-17 00:09:19 Re: Cost estimation problem on seq scan in a loop
Previous Message Jeff Janes 2013-12-16 23:41:18 Cost estimation problem on seq scan in a loop