diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-07 03:04:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-07 03:04:04 +0000 |
commit | 368df3042783778031ece2b8580324516cd42de1 (patch) | |
tree | dd6f9877cdc12654647a97785c4e7267cc7ac945 /src/backend/optimizer/plan/createplan.c | |
parent | 2d1d96b1cea8f67a095e8f28372af4081605f681 (diff) | |
download | postgresql-368df3042783778031ece2b8580324516cd42de1.tar.gz postgresql-368df3042783778031ece2b8580324516cd42de1.zip |
Support hashing for duplicate-elimination in INTERSECT and EXCEPT queries.
This completes my project of improving usage of hashing for duplicate
elimination (aggregate functions with DISTINCT remain undone, but that's
for some other day).
As with the previous patches, this means we can INTERSECT/EXCEPT on datatypes
that can hash but not sort, and it means that INTERSECT/EXCEPT without ORDER
BY are no longer certain to produce sorted output.
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 80b6ed2edfe..4cf2a5208b1 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.242 2008/08/02 21:32:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.243 2008/08/07 03:04:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3108,8 +3108,9 @@ make_unique(Plan *lefttree, List *distinctList) * already be sorted accordingly. */ SetOp * -make_setop(SetOpCmd cmd, Plan *lefttree, - List *distinctList, AttrNumber flagColIdx) +make_setop(SetOpCmd cmd, SetOpStrategy strategy, Plan *lefttree, + List *distinctList, AttrNumber flagColIdx, long numGroups, + double outputRows) { SetOp *node = makeNode(SetOp); Plan *plan = &node->plan; @@ -3120,20 +3121,13 @@ make_setop(SetOpCmd cmd, Plan *lefttree, ListCell *slitem; copy_plan_costsize(plan, lefttree); + plan->plan_rows = outputRows; /* * Charge one cpu_operator_cost per comparison per input tuple. We assume * all columns get compared at most of the tuples. */ - plan->total_cost += cpu_operator_cost * plan->plan_rows * numCols; - - /* - * We make the unsupported assumption that there will be 10% as many - * tuples out as in. Any way to do better? - */ - plan->plan_rows *= 0.1; - if (plan->plan_rows < 1) - plan->plan_rows = 1; + plan->total_cost += cpu_operator_cost * lefttree->plan_rows * numCols; plan->targetlist = lefttree->targetlist; plan->qual = NIL; @@ -3160,10 +3154,12 @@ make_setop(SetOpCmd cmd, Plan *lefttree, } node->cmd = cmd; + node->strategy = strategy; node->numCols = numCols; node->dupColIdx = dupColIdx; node->dupOperators = dupOperators; node->flagColIdx = flagColIdx; + node->numGroups = numGroups; return node; } |