mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
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 <pg@bowt.ie> Reviewed-By: Victor Yegorov <vyegorov@gmail.com> Discussion: https://postgr.es/m/CAH2-Wz=CEKFa74EScx_hFVshCOn6AA5T-ajFASTdzipdkLTNQQ@mail.gmail.com
This commit is contained in:
@@ -151,6 +151,7 @@ bool
|
||||
brininsert(Relation idxRel, Datum *values, bool *nulls,
|
||||
ItemPointer heaptid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
BlockNumber pagesPerRange;
|
||||
|
@@ -328,7 +328,7 @@ toast_save_datum(Relation rel, Datum value,
|
||||
toastrel,
|
||||
toastidxs[i]->rd_index->indisunique ?
|
||||
UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,
|
||||
NULL);
|
||||
false, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -488,6 +488,7 @@ bool
|
||||
gininsert(Relation index, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
GinState *ginstate = (GinState *) indexInfo->ii_AmCache;
|
||||
|
@@ -156,6 +156,7 @@ bool
|
||||
gistinsert(Relation r, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
GISTSTATE *giststate = (GISTSTATE *) indexInfo->ii_AmCache;
|
||||
|
@@ -247,6 +247,7 @@ bool
|
||||
hashinsert(Relation rel, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
Datum index_values[1];
|
||||
|
@@ -1956,6 +1956,7 @@ heapam_index_validate_scan(Relation heapRelation,
|
||||
heapRelation,
|
||||
indexInfo->ii_Unique ?
|
||||
UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,
|
||||
false,
|
||||
indexInfo);
|
||||
|
||||
state->tups_inserted += 1;
|
||||
|
@@ -179,6 +179,7 @@ index_insert(Relation indexRelation,
|
||||
ItemPointer heap_t_ctid,
|
||||
Relation heapRelation,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
RELATION_CHECKS;
|
||||
@@ -191,7 +192,8 @@ index_insert(Relation indexRelation,
|
||||
|
||||
return indexRelation->rd_indam->aminsert(indexRelation, values, isnull,
|
||||
heap_t_ctid, heapRelation,
|
||||
checkUnique, indexInfo);
|
||||
checkUnique, indexUnchanged,
|
||||
indexInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -199,6 +199,7 @@ bool
|
||||
btinsert(Relation rel, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
bool result;
|
||||
|
@@ -207,6 +207,7 @@ bool
|
||||
spginsert(Relation index, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
IndexInfo *indexInfo)
|
||||
{
|
||||
SpGistState spgstate;
|
||||
|
Reference in New Issue
Block a user