Thread: pgsql: Support parameterized TidPaths.

pgsql: Support parameterized TidPaths.

From
Tom Lane
Date:
Support parameterized TidPaths.

Up to now we've not worried much about joins where the join key is a
relation's CTID column, reasoning that storing a table's CTIDs in some
other table would be pretty useless.  However, there are use-cases for
this sort of query involving self-joins, so that argument doesn't really
hold water.

This patch allows generating plans for joins on CTID that use a nestloop
with inner TidScan, similar to what we might do with an index on the join
column.  This is the most efficient way to join when the outer side of
the nestloop is expected to yield relatively few rows.

This change requires upgrading tidpath.c and the generated TidPaths
to work with RestrictInfos instead of bare qual clauses, but that's
long-postponed technical debt anyway.

Discussion: https://postgr.es/m/17443.1545435266@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/path/costsize.c   |   9 +-
src/backend/optimizer/path/tidpath.c    | 394 ++++++++++++++++++++++----------
src/backend/optimizer/plan/createplan.c |  67 +++++-
src/backend/optimizer/util/pathnode.c   |   6 +-
src/include/nodes/plannodes.h           |   3 +-
src/include/nodes/relation.h            |   4 +-
src/test/regress/expected/tidscan.out   |  55 +++++
src/test/regress/sql/tidscan.sql        |  17 ++
8 files changed, 415 insertions(+), 140 deletions(-)