Re: BUG #14107: Major query planner bug regarding subqueries and indices - Mailing list pgsql-bugs

From David Rowley
Subject Re: BUG #14107: Major query planner bug regarding subqueries and indices
Date
Msg-id CAKJS1f_xd0to95CdY7J05PXPzxTKRmXx=PScWyG-e28w6qNeRw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #14107: Major query planner bug regarding subqueries and indices  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On 29 April 2016 at 13:10, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I don't actually see any way to do very much with your second example at
> all:
>
>> SELECT ... FROM a JOIN b ON (...) WHERE a.x = ? OR b.y = ?;
>
> There's no way to push anything down to either the A or B scans from
> that WHERE condition: you can't remove any rows before the join because
> they might join to rows on the other side that satisfy the other half
> of the OR.

I was confused when I read that too. The only way I thought to
transform would be to create a UNION for each condition, which in
theory would be possible providing the SELECT lists contained the PK
columns. Of course, in practice this would be difficult, since UNIONs
are planned later, and having the query execute in that way would have
to be costed, and only used if cheaper.


--
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #14107: Major query planner bug regarding subqueries and indices
Next
From: kayzizz@gmail.com
Date:
Subject: BUG #14120: Documentation suggestion 35.4.2