mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +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:
@@ -110,6 +110,7 @@ typedef bool (*aminsert_function) (Relation indexRelation,
|
||||
ItemPointer heap_tid,
|
||||
Relation heapRelation,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
|
||||
/* bulk delete */
|
||||
|
@@ -91,6 +91,7 @@ extern void brinbuildempty(Relation index);
|
||||
extern bool brininsert(Relation idxRel, Datum *values, bool *nulls,
|
||||
ItemPointer heaptid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
|
||||
extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
|
||||
|
@@ -143,6 +143,7 @@ extern bool index_insert(Relation indexRelation,
|
||||
ItemPointer heap_t_ctid,
|
||||
Relation heapRelation,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
|
||||
extern IndexScanDesc index_beginscan(Relation heapRelation,
|
||||
|
@@ -116,6 +116,7 @@ extern void ginbuildempty(Relation index);
|
||||
extern bool gininsert(Relation index, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern void ginEntryInsert(GinState *ginstate,
|
||||
OffsetNumber attnum, Datum key, GinNullCategory category,
|
||||
|
@@ -403,6 +403,7 @@ extern void gistbuildempty(Relation index);
|
||||
extern bool gistinsert(Relation r, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern MemoryContext createTempGistContext(void);
|
||||
extern GISTSTATE *initGISTstate(Relation index);
|
||||
|
@@ -364,6 +364,7 @@ extern void hashbuildempty(Relation index);
|
||||
extern bool hashinsert(Relation rel, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern bool hashgettuple(IndexScanDesc scan, ScanDirection dir);
|
||||
extern int64 hashgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
|
||||
|
@@ -996,6 +996,7 @@ extern void btbuildempty(Relation index);
|
||||
extern bool btinsert(Relation rel, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern IndexScanDesc btbeginscan(Relation rel, int nkeys, int norderbys);
|
||||
extern Size btestimateparallelscan(void);
|
||||
|
@@ -199,6 +199,7 @@ extern void spgbuildempty(Relation index);
|
||||
extern bool spginsert(Relation index, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
|
||||
/* spgscan.c */
|
||||
|
Reference in New Issue
Block a user