pgsql: Pass down "logically unchanged index" hint.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

pgsql: Pass down "logically unchanged index" hint.

Peter Geoghegan-4
Pass down "logically unchanged index" hint.

Add an executor aminsert() hint mechanism that informs index AMs that
the incoming index tuple (the tuple that accompanies the hint) is not
being inserted by execution of an SQL statement that logically modifies
any of the index's key columns.

The hint is received by indexes when an UPDATE takes place that does not
apply an optimization like heapam's HOT (though only for indexes where
all key columns are logically unchanged).  Any index tuple that receives
the hint on insert is expected to be a duplicate of at least one
existing older version that is needed for the same logical row.  Related
versions will typically be stored on the same index page, at least
within index AMs that apply the hint.

Recognizing the difference between MVCC version churn duplicates and
true logical row duplicates at the index AM level can help with cleanup
of garbage index tuples.  Cleanup can intelligently target tuples that
are likely to be garbage, without wasting too many cycles on less
promising tuples/pages (index pages with little or no version churn).

This is infrastructure for an upcoming commit that will teach nbtree to
perform bottom-up index deletion.  No index AM actually applies the hint
just yet.

Author: Peter Geoghegan <[hidden email]>
Reviewed-By: Victor Yegorov <[hidden email]>
Discussion: https://postgr.es/m/CAH2-Wz=CEKFa74EScx_hFVshCOn6AA5T-ajFASTdzipdkLTNQQ@...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9dc718bdf2b1a574481a45624d42b674332e2903

Modified Files
--------------
contrib/bloom/blinsert.c                         |   1 +
contrib/bloom/bloom.h                            |   1 +
doc/src/sgml/indexam.sgml                        |  15 +++
src/backend/access/brin/brin.c                   |   1 +
src/backend/access/common/toast_internals.c      |   2 +-
src/backend/access/gin/gininsert.c               |   1 +
src/backend/access/gist/gist.c                   |   1 +
src/backend/access/hash/hash.c                   |   1 +
src/backend/access/heap/heapam_handler.c         |   1 +
src/backend/access/index/indexam.c               |   4 +-
src/backend/access/nbtree/nbtree.c               |   1 +
src/backend/access/spgist/spginsert.c            |   1 +
src/backend/catalog/indexing.c                   |   1 +
src/backend/commands/constraint.c                |   2 +-
src/backend/commands/copyfrom.c                  |   5 +-
src/backend/commands/trigger.c                   |   6 +-
src/backend/executor/execIndexing.c              | 160 ++++++++++++++++++++++-
src/backend/executor/execMain.c                  |   8 +-
src/backend/executor/execReplication.c           |   8 +-
src/backend/executor/nodeModifyTable.c           |   6 +-
src/backend/replication/logical/worker.c         |   3 +-
src/include/access/amapi.h                       |   1 +
src/include/access/brin_internal.h               |   1 +
src/include/access/genam.h                       |   1 +
src/include/access/gin_private.h                 |   1 +
src/include/access/gist_private.h                |   1 +
src/include/access/hash.h                        |   1 +
src/include/access/nbtree.h                      |   1 +
src/include/access/spgist.h                      |   1 +
src/include/executor/executor.h                  |   1 +
src/test/modules/dummy_index_am/dummy_index_am.c |   1 +
31 files changed, 214 insertions(+), 25 deletions(-)