aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeAgg.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-11-19 23:22:00 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-11-19 23:22:00 +0000
commitb60be3f2f8d094da79e04c6eda888f401b09dc39 (patch)
tree0590e0647deb5041b8dabcabf03770ebef8e8d43 /src/backend/executor/nodeAgg.c
parent54cb1db6cf4d4bf4e44148582bbd2c99684e7dfd (diff)
downloadpostgresql-b60be3f2f8d094da79e04c6eda888f401b09dc39.tar.gz
postgresql-b60be3f2f8d094da79e04c6eda888f401b09dc39.zip
Add an at-least-marginally-plausible method of estimating the number
of groups produced by GROUP BY. This improves the accuracy of planning estimates for grouped subselects, and is needed to check whether a hashed aggregation plan risks memory overflow.
Diffstat (limited to 'src/backend/executor/nodeAgg.c')
-rw-r--r--src/backend/executor/nodeAgg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 5fa82ee9fad..0216f8ebde7 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.95 2002/11/13 00:39:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.96 2002/11/19 23:21:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -619,6 +619,9 @@ lookup_hash_entry(Agg *node, TupleTableSlot *slot)
Datum attr;
bool isNull;
+ /* rotate hashkey left 1 bit at each step */
+ hashkey = (hashkey << 1) | ((hashkey & 0x80000000) ? 1 : 0);
+
attr = heap_getattr(tuple, att, tupdesc, &isNull);
if (isNull)
continue; /* treat nulls as having hash key 0 */