pgsql: Support parameterized TidPaths.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Support parameterized TidPaths.
Date: 2018-12-30 20:40:16
Message-ID: E1gdhse-00040M-JJ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2018-12-30 21:24:55 pgsql: Change "checkpoint starting" message to use "wal"
Previous Message Tom Lane 2018-12-30 18:42:11 pgsql: Teach eval_const_expressions to constant-fold LEAST/GREATEST exp