From 9fcbe2af11fb966b30117d8ac3c2971d1be14207 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 22 Sep 2004 19:13:52 +0000 Subject: Arrange for hash join to skip scanning the outer relation if it detects that the inner one is completely empty. Per recent discussion. Also some cosmetic cleanups in nearby code. --- src/include/executor/hashjoin.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/include/executor') diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index 5dd6c5c8fe..8a2eba8e0b 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/hashjoin.h,v 1.32 2004/08/29 04:13:06 momjian Exp $ + * $PostgreSQL: pgsql/src/include/executor/hashjoin.h,v 1.33 2004/09/22 19:13:52 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,7 @@ typedef struct HashJoinTupleData typedef HashJoinTupleData *HashJoinTuple; -typedef struct HashTableData +typedef struct HashJoinTableData { int nbuckets; /* buckets in use during this batch */ int totalbuckets; /* total number of (virtual) buckets */ @@ -57,6 +57,8 @@ typedef struct HashTableData int nbatch; /* number of batches; 0 means 1-pass join */ int curbatch; /* current batch #, or 0 during 1st pass */ + bool hashNonEmpty; /* did inner plan produce any rows? */ + /* * all these arrays are allocated for the life of the hash join, but * only if nbatch > 0: @@ -90,8 +92,8 @@ typedef struct HashTableData MemoryContext hashCxt; /* context for whole-hash-join storage */ MemoryContext batchCxt; /* context for this-batch-only storage */ -} HashTableData; +} HashJoinTableData; -typedef HashTableData *HashJoinTable; +typedef HashJoinTableData *HashJoinTable; #endif /* HASHJOIN_H */ -- cgit v1.2.1