Re: Performance improvement for joins where outer side is unique
От | Tom Lane |
---|---|
Тема | Re: Performance improvement for joins where outer side is unique |
Дата | |
Msg-id | 13653.1457731978@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Performance improvement for joins where outer side is unique (David Rowley <david.rowley@2ndquadrant.com>) |
Ответы |
Re: Performance improvement for joins where outer side is unique
Re: Performance improvement for joins where outer side is unique |
Список | pgsql-hackers |
So I started re-reading this thread in preparation for looking at the patch, and this bit in your initial message jumped out at me: > In all of our join algorithms in the executor, if the join type is SEMI, > we skip to the next outer row once we find a matching inner row. This is > because we don't want to allow duplicate rows in the inner side to > duplicate outer rows in the result set. Obviously this is required per SQL > spec. I believe we can also skip to the next outer row in this case when > we've managed to prove that no other row can possibly exist that matches > the current outer row, due to a unique index or group by/distinct clause > (for subqueries). I wondered why, instead of inventing an extra semantics-modifying flag, we couldn't just change the jointype to *be* JOIN_SEMI when we've discovered that the inner side is unique. Now of course this only works if the join type was INNER to start with. If it was a LEFT join, you'd need an "outer semi join" jointype which we haven't got at the moment. But I wonder whether inventing that jointype wouldn't let us arrive at a less messy handling of things in the executor and EXPLAIN. I'm not very enamored of plastering this "match_first_tuple_only" flag on every join, in part because it doesn't appear to have sensible semantics for other jointypes such as JOIN_RIGHT. And I'd really be happier to see the information reflected by join type than a new line in EXPLAIN, also. regards, tom lane
В списке pgsql-hackers по дате отправления: