From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Performance improvement for joins where outer side is unique |
Date: | 2017-01-27 19:00:35 |
Message-ID: | 4237.1485543635@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 Fri, Jan 27, 2017 at 1:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Um ... what's that got to do with the point at hand?
> So I assumed from that that the issue was that you'd have to wait for
> the first time the irrelevant-joinqual got satisfied before the
> optimization kicked in.
No, the problem is that that needs to happen for *each* outer row,
and there's only one chance for it to happen. Given the previous
example,
select ... from t1 left join t2 on t1.x = t2.x and t1.y < t2.y
once we've found an x match for a given outer row, there aren't going to
be any more and we should move on to the next outer row. But as the patch
stands, we only recognize that if t1.y < t2.y happens to be true for that
particular row pair. Otherwise we'll keep searching and we'll never find
another match for that outer row. So if the y condition is, say, 50%
selective then the optimization only wins for 50% of the outer rows
(that have an x partner in the first place).
Now certainly that's better than a sharp stick in the eye, and
maybe we should just press forward anyway. But it feels like
this is leaving a lot more on the table than I originally thought.
Especially for the inner-join case, where *all* the WHERE conditions
get a chance to break the optimization this way.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-01-27 19:29:17 | Re: Performance improvement for joins where outer side is unique |
Previous Message | Tom Lane | 2017-01-27 18:47:47 | Re: pg_hba_file_settings view patch |