pgsql: Rearrange the implementation of index-only scans.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rearrange the implementation of index-only scans.
Date: 2011-10-11 18:22:05
Message-ID: E1RDgxp-0006wg-6V@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Rearrange the implementation of index-only scans.

This commit changes index-only scans so that data is read directly from the
index tuple without first generating a faux heap tuple. The only immediate
benefit is that indexes on system columns (such as OID) can be used in
index-only scans, but this is necessary infrastructure if we are ever to
support index-only scans on expression indexes. The executor is now ready
for that, though the planner still needs substantial work to recognize
the possibility.

To do this, Vars in index-only plan nodes have to refer to index columns
not heap columns. I introduced a new special varno, INDEX_VAR, to mark
such Vars to avoid confusion. (In passing, this commit renames the two
existing special varnos to OUTER_VAR and INNER_VAR.) This allows
ruleutils.c to handle them with logic similar to what we use for subplan
reference Vars.

Since index-only scans are now fundamentally different from regular
indexscans so far as their expression subtrees are concerned, I also chose
to change them to have their own plan node type (and hence, their own
executor source file).

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a0185461dd94c8d31d8d55a7f2839b0d2f172ab9

Modified Files
--------------
src/backend/commands/explain.c | 119 ++++--
src/backend/commands/trigger.c | 8 +-
src/backend/executor/Makefile | 3 +-
src/backend/executor/execAmi.c | 21 +-
src/backend/executor/execCurrent.c | 1 +
src/backend/executor/execProcnode.c | 14 +
src/backend/executor/execQual.c | 24 +-
src/backend/executor/execScan.c | 9 +-
src/backend/executor/execUtils.c | 12 +-
src/backend/executor/nodeAgg.c | 4 +-
src/backend/executor/nodeBitmapIndexscan.c | 1 -
src/backend/executor/nodeHash.c | 4 +-
src/backend/executor/nodeIndexonlyscan.c | 542 ++++++++++++++++++++++++++++
src/backend/executor/nodeIndexscan.c | 142 +-------
src/backend/executor/nodeNestloop.c | 4 +-
src/backend/nodes/copyfuncs.c | 29 ++-
src/backend/nodes/outfuncs.c | 22 +-
src/backend/nodes/print.c | 8 +-
src/backend/optimizer/path/indxpath.c | 23 +-
src/backend/optimizer/path/pathkeys.c | 68 +---
src/backend/optimizer/plan/createplan.c | 138 +++++--
src/backend/optimizer/plan/setrefs.c | 138 ++++++--
src/backend/optimizer/plan/subselect.c | 12 +
src/backend/optimizer/util/pathnode.c | 3 +-
src/backend/optimizer/util/plancat.c | 71 ++++
src/backend/utils/adt/ruleutils.c | 159 ++++++---
src/backend/utils/adt/tid.c | 2 +-
src/include/executor/nodeIndexonlyscan.h | 26 ++
src/include/executor/nodeIndexscan.h | 7 +-
src/include/nodes/execnodes.h | 36 ++-
src/include/nodes/nodes.h | 2 +
src/include/nodes/plannodes.h | 38 ++-
src/include/nodes/primnodes.h | 16 +-
src/include/nodes/relation.h | 27 +-
34 files changed, 1313 insertions(+), 420 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-10-11 19:00:39 pgsql: Consider index-only scans even when there is no matching qual or
Previous Message Robert Haas 2011-10-11 13:24:15 pgsql: Replace hardcoded switch in object_exists() with a lookup table.