Re: convert EXSITS to inner join gotcha and bug
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>,
Teodor Sigaev <teodor@sigaev.ru>,
Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2017-04-30T00:27:29Z
Lists: pgsql-hackers
Attachments
- reduce-semijoins-2.patch (text/x-diff) patch
David Rowley <david.rowley@2ndquadrant.com> writes: > On 29 April 2017 at 15:39, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> I'm kind of strongly tempted to apply the second patch; but it would >> be fair to complain that reduce_unique_semijoins() is new development >> and should wait for v11. Opinions? > My vote is for the non-minimal patch. Of course, I'd be voting for > minimal patch if this was for a minor version release fix, but we're > not even in beta yet for v10. The original patch was intended to fix > cases like this, although I'd failed to realise this particular case. Yeah, I thought we'd discussed doing something more or less like this way back in that thread. After studying the patch some more, I noticed that reduce_unique_semijoins falsifies the assumption in innerrel_is_unique that we only probe inner uniqueness for steadily larger relid sets. If the semijoin LHS is more than one relation, then it'll test inner uniqueness using that LHS, and if the proof fails, that's knowledge that can save individual proof attempts for the individual LHS rels later on during the join search. So in the attached, I've modified reduce_unique_semijoins's API a bit more to allow the caller to override the don't-cache heuristic. Also, this form of the patch is an incremental patch over the minimal fix I posted yesterday. It seems like a good idea to push it as a separate commit, if only for future bisection purposes. If I don't hear objections, I'll push this tomorrow sometime. regards, tom lane
Commits
-
Reduce semijoins with unique inner relations to plain inner joins.
- 92a43e4857d9 10.0 landed
-
Fix mis-optimization of semijoins with more than one LHS relation.
- 2057a58d1629 10.0 landed