pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add TID Range Scans to support efficient scanning ranges of TIDs
Date: Sat, 27 Feb 2021 10:01:03 +0000
Message-ID: <E1lFwPH-0002fZ-QI@gemulon.postgresql.org> (raw)

Add TID Range Scans to support efficient scanning ranges of TIDs

This adds a new executor node named TID Range Scan.  The query planner
will generate paths for TID Range scans when quals are discovered on base
relations which search for ranges on the table's ctid column.  These
ranges may be open at either end. For example, WHERE ctid >= '(10,0)';
will return all tuples on page 10 and over.

To support this, two new optional callback functions have been added to
table AM.  scan_set_tidrange is used to set the scan range to just the
given range of TIDs.  scan_getnextslot_tidrange fetches the next tuple
in the given range.

For AMs were scanning ranges of TIDs would not make sense, these functions
can be set to NULL in the TableAmRoutine.  The query planner won't
generate TID Range Scan Paths in that case.

Author: Edmund Horner, David Rowley
Reviewed-by: David Rowley, Tomas Vondra, Tom Lane, Andres Freund, Zhihong Yu
Discussion: https://postgr.es/m/CAMyN-kB-nFTkF=VA_JPwFNo08S0d-Yk0F741S2B7LDmYAi8eyA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bb437f995d47405ecd92cf66df71f7f7e40ed460

Modified Files
--------------
src/backend/access/heap/heapam.c           | 147 ++++++++++
src/backend/access/heap/heapam_handler.c   |   3 +
src/backend/commands/explain.c             |  23 ++
src/backend/executor/Makefile              |   1 +
src/backend/executor/execAmi.c             |   6 +
src/backend/executor/execCurrent.c         |   1 +
src/backend/executor/execProcnode.c        |  10 +
src/backend/executor/nodeTidrangescan.c    | 413 +++++++++++++++++++++++++++++
src/backend/nodes/copyfuncs.c              |  24 ++
src/backend/nodes/outfuncs.c               |  14 +
src/backend/optimizer/README               |   1 +
src/backend/optimizer/path/costsize.c      |  95 +++++++
src/backend/optimizer/path/tidpath.c       | 119 ++++++++-
src/backend/optimizer/plan/createplan.c    |  98 +++++++
src/backend/optimizer/plan/setrefs.c       |  16 ++
src/backend/optimizer/plan/subselect.c     |   6 +
src/backend/optimizer/util/pathnode.c      |  29 ++
src/backend/optimizer/util/plancat.c       |   6 +
src/backend/optimizer/util/relnode.c       |   3 +
src/backend/storage/page/itemptr.c         |  59 +++++
src/include/access/heapam.h                |   6 +-
src/include/access/relscan.h               |   4 +
src/include/access/tableam.h               |  97 ++++++-
src/include/catalog/pg_operator.dat        |   6 +-
src/include/executor/nodeTidrangescan.h    |  24 ++
src/include/nodes/execnodes.h              |  18 ++
src/include/nodes/nodes.h                  |   3 +
src/include/nodes/pathnodes.h              |  18 ++
src/include/nodes/plannodes.h              |  13 +
src/include/optimizer/cost.h               |   3 +
src/include/optimizer/pathnode.h           |   4 +
src/include/storage/itemptr.h              |   2 +
src/test/regress/expected/tidrangescan.out | 300 +++++++++++++++++++++
src/test/regress/parallel_schedule         |   2 +-
src/test/regress/serial_schedule           |   1 +
src/test/regress/sql/tidrangescan.sql      | 101 +++++++
36 files changed, 1654 insertions(+), 22 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1lFwPH-0002fZ-QI@gemulon.postgresql.org>
Permalink:  ../E1lFwPH-0002fZ-QI@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lFwPH-0002fZ-QI@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Add TID Range Scans to support efficient scanning ranges of TIDs
  In-Reply-To: <E1lFwPH-0002fZ-QI@gemulon.postgresql.org>
  References: <E1lFwPH-0002fZ-QI@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox