From e006a24ad152b3faec748afe8c1ff0829699b2e6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 14 Aug 2008 18:48:00 +0000 Subject: Implement SEMI and ANTI joins in the planner and executor. (Semijoins replace the old JOIN_IN code, but antijoins are new functionality.) Teach the planner to convert appropriate EXISTS and NOT EXISTS subqueries into semi and anti joins respectively. Also, LEFT JOINs with suitable upper-level IS NULL filters are recognized as being anti joins. Unify the InClauseInfo and OuterJoinInfo infrastructure into "SpecialJoinInfo". With that change, it becomes possible to associate a SpecialJoinInfo with every join attempt, which permits some cleanup of join selectivity estimation. That needs to be taken much further than this patch does, but the next step is to change the API for oprjoin selectivity functions, which seems like material for a separate patch. So for the moment the output size estimates for semi and especially anti joins are quite bogus. --- src/backend/commands/explain.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/backend/commands/explain.c') diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 1fd6f0cb33..d0033f4366 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.176 2008/08/07 03:04:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.177 2008/08/14 18:47:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -450,8 +450,11 @@ explain_outNode(StringInfo str, case JOIN_RIGHT: pname = "Nested Loop Right Join"; break; - case JOIN_IN: - pname = "Nested Loop IN Join"; + case JOIN_SEMI: + pname = "Nested Loop Semi Join"; + break; + case JOIN_ANTI: + pname = "Nested Loop Anti Join"; break; default: pname = "Nested Loop ??? Join"; @@ -473,8 +476,11 @@ explain_outNode(StringInfo str, case JOIN_RIGHT: pname = "Merge Right Join"; break; - case JOIN_IN: - pname = "Merge IN Join"; + case JOIN_SEMI: + pname = "Merge Semi Join"; + break; + case JOIN_ANTI: + pname = "Merge Anti Join"; break; default: pname = "Merge ??? Join"; @@ -496,8 +502,11 @@ explain_outNode(StringInfo str, case JOIN_RIGHT: pname = "Hash Right Join"; break; - case JOIN_IN: - pname = "Hash IN Join"; + case JOIN_SEMI: + pname = "Hash Semi Join"; + break; + case JOIN_ANTI: + pname = "Hash Anti Join"; break; default: pname = "Hash ??? Join"; -- cgit v1.2.1