]> granicus.if.org Git - postgresql/commit
Support parameterized TidPaths.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Dec 2018 20:24:28 +0000 (15:24 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Dec 2018 20:24:28 +0000 (15:24 -0500)
commitb5415e3c2187ab304390524f5ae66b4bd2c58279
tree220849a4768866109c2a955b20cf5783b8ad459a
parent6f19a8c41f976236310a272bb646d3411759e18d
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
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/tidpath.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/pathnode.c
src/include/nodes/plannodes.h
src/include/nodes/relation.h
src/test/regress/expected/tidscan.out
src/test/regress/sql/tidscan.sql