diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-29 23:05:05 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-29 23:05:05 +0000 |
commit | 835bb975d8d11268582d9dbd26b0eeaa62b60632 (patch) | |
tree | 5d5d3d57acfe7627235aa72c28c37d8c85b210a3 /src/backend/optimizer/util/tlist.c | |
parent | cf883ea95c4bad69910300cbd6c0ef5cb84a9178 (diff) | |
download | postgresql-835bb975d8d11268582d9dbd26b0eeaa62b60632.tar.gz postgresql-835bb975d8d11268582d9dbd26b0eeaa62b60632.zip |
Restructure building of join relation targetlists so that a join plan
node emits only those vars that are actually needed above it in the
plan tree. (There were comments in the code suggesting that this was
done at some point in the dim past, but for a long time we have just
made join nodes emit everything that either input emitted.) Aside from
being marginally more efficient, this fixes the problem noted by Peter
Eisentraut where a join above an IN-implemented-as-join might fail,
because the subplan targetlist constructed in the latter case didn't
meet the expectation of including everything.
Along the way, fix some places that were O(N^2) in the targetlist
length. This is not all the trouble spots for wide queries by any
means, but it's a step forward.
Diffstat (limited to 'src/backend/optimizer/util/tlist.c')
-rw-r--r-- | src/backend/optimizer/util/tlist.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c index 9b10e8e97be..7a4422a3594 100644 --- a/src/backend/optimizer/util/tlist.c +++ b/src/backend/optimizer/util/tlist.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.56 2003/05/06 00:20:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.57 2003/06/29 23:05:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ /***************************************************************************** - * ---------- RELATION node target list routines ---------- + * Target list creation and searching utilities *****************************************************************************/ /* @@ -80,24 +80,6 @@ tlist_member(Node *node, List *targetlist) } /* - * add_var_to_tlist - * Creates a targetlist entry corresponding to the supplied var node - * 'var' and adds the new targetlist entry to the targetlist field of - * 'rel'. No entry is created if 'var' is already in the tlist. - */ -void -add_var_to_tlist(RelOptInfo *rel, Var *var) -{ - if (!tlistentry_member((Node *) var, rel->targetlist)) - { - /* XXX is copyObject necessary here? */ - rel->targetlist = lappend(rel->targetlist, - create_tl_element((Var *) copyObject(var), - length(rel->targetlist) + 1)); - } -} - -/* * create_tl_element * Creates a target list entry node and its associated (resdom var) pair * with its resdom number equal to 'resdomno'. |