Skip site navigation (1) Skip section navigation (2)

pgsql: Rearrange planner to save the whole PlannerInfo (subroot) fora

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rearrange planner to save the whole PlannerInfo (subroot) fora
Date: 2011-09-03 19:36:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Rearrange planner to save the whole PlannerInfo (subroot) for a subquery.

Formerly, set_subquery_pathlist and other creators of plans for subqueries
saved only the rangetable and rowMarks lists from the lower-level
PlannerInfo.  But there's no reason not to remember the whole PlannerInfo,
and indeed this turns out to simplify matters in a number of places.

The immediate reason for doing this was so that the subroot will still be
accessible when we're trying to extract column statistics out of an
already-planned subquery.  But now that I've done it, it seems like a good
code-beautification effort in its own right.

I also chose to get rid of the transient subrtable and subrowmark fields in
SubqueryScan nodes, in favor of having setrefs.c look up the subquery's
RelOptInfo.  That required changing all the APIs in setrefs.c to pass
PlannerInfo not PlannerGlobal, which was a large but quite mechanical

One side-effect not foreseen at the beginning is that this finally broke
inheritance_planner's assumption that replanning the same subquery RTE N
times would necessarily give interchangeable results each time.  That
assumption was always pretty risky, but now we really have to make a
separate RTE for each instance so that there's a place to carry the
separate subroots.



Modified Files
src/backend/executor/nodeSubqueryscan.c |    7 +-
src/backend/nodes/copyfuncs.c           |    2 -
src/backend/nodes/outfuncs.c            |    8 +-
src/backend/optimizer/path/allpaths.c   |    5 +-
src/backend/optimizer/path/costsize.c   |    4 +-
src/backend/optimizer/plan/createplan.c |   10 +-
src/backend/optimizer/plan/planmain.c   |   20 +--
src/backend/optimizer/plan/planner.c    |  198 ++++++++++++++++------
src/backend/optimizer/plan/setrefs.c    |  278 +++++++++++++++---------------
src/backend/optimizer/plan/subselect.c  |   34 ++---
src/backend/optimizer/prep/prepunion.c  |   30 +++-
src/backend/optimizer/util/clauses.c    |   17 +--
src/backend/optimizer/util/relnode.c    |   35 ++++-
src/backend/rewrite/rewriteManip.c      |   16 ++
src/include/nodes/plannodes.h           |    6 -
src/include/nodes/relation.h            |   12 +-
src/include/optimizer/cost.h            |    3 +-
src/include/optimizer/pathnode.h        |    1 +
src/include/optimizer/planmain.h        |   12 +-
19 files changed, 394 insertions(+), 304 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2011-09-03 20:18:27
Subject: pgsql: Fix typo in pg_srand48 (srand48 in older branches).
Previous:From: Bruce MomjianDate: 2011-09-03 14:39:15
Subject: Re: pgsql: Remove "fmgr.h" include in cube contrib --- caused crash on a Ge

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group