diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-03-26 17:15:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-03-26 17:15:35 +0000 |
commit | f38fbf31f5719bb84b18042a7f415a4f20db2bfa (patch) | |
tree | 9de323400560bd677e4402727b1f6bb3ec9834e9 /src/backend/optimizer/util/pathnode.c | |
parent | ee4c187f6471af5f71fd5dd12021fa8d7c4fce11 (diff) | |
download | postgresql-f38fbf31f5719bb84b18042a7f415a4f20db2bfa.tar.gz postgresql-f38fbf31f5719bb84b18042a7f415a4f20db2bfa.zip |
If we expect a hash join to be performed in multiple batches, suppress
"physical tlist" optimization on the outer relation (ie, force a projection
step to occur in its scan). This avoids storing useless column values when
the outer relation's tuples are written to temporary batch files.
Modified version of a patch by Michael Henderson and Ramon Lawrence.
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 28b2828c2dd..5ba413bb1ad 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.150 2009/02/27 00:06:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.151 2009/03/26 17:15:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1480,9 +1480,20 @@ create_hashjoin_path(PlannerInfo *root, pathnode->jpath.outerjoinpath = outer_path; pathnode->jpath.innerjoinpath = inner_path; pathnode->jpath.joinrestrictinfo = restrict_clauses; - /* A hashjoin never has pathkeys, since its ordering is unpredictable */ + /* + * A hashjoin never has pathkeys, since its output ordering is + * unpredictable due to possible batching. XXX If the inner relation is + * small enough, we could instruct the executor that it must not batch, + * and then we could assume that the output inherits the outer relation's + * ordering, which might save a sort step. However there is considerable + * downside if our estimate of the inner relation size is badly off. + * For the moment we don't risk it. (Note also that if we wanted to take + * this seriously, joinpath.c would have to consider many more paths for + * the outer rel than it does now.) + */ pathnode->jpath.path.pathkeys = NIL; pathnode->path_hashclauses = hashclauses; + /* cost_hashjoin will fill in pathnode->num_batches */ cost_hashjoin(pathnode, root, sjinfo); |