mirror of
https://github.com/postgres/postgres.git
synced 2025-10-19 15:49:24 +03:00
Ignore BRIN indexes when checking for HOT updates
When determining whether an index update may be skipped by using HOT, we can ignore attributes indexed by block summarizing indexes without references to individual tuples that need to be cleaned up. A new type TU_UpdateIndexes provides a signal to the executor to determine which indexes to update - no indexes, all indexes, or only the summarizing indexes. This also removes rd_indexattr list, and replaces it with rd_attrsvalid flag. The list was not used anywhere, and a simple flag is sufficient. This was originally committed as5753d4ee32, but then got reverted bye3fcca0d0dbecause of correctness issues. Original patch by Josef Simanek, various fixes and improvements by Tomas Vondra and me. Authors: Matthias van de Meent, Josef Simanek, Tomas Vondra Reviewed-by: Tomas Vondra, Alvaro Herrera Discussion: https://postgr.es/m/05ebcb44-f383-86e3-4f31-0a97a55634cf@enterprisedb.com Discussion: https://postgr.es/m/CAFp7QwpMRGcDAQumN7onN9HjrJ3u4X3ZRXdGFT0K5G2JWvnbWg%40mail.gmail.com
This commit is contained in:
@@ -244,6 +244,8 @@ typedef struct IndexAmRoutine
|
||||
bool amcaninclude;
|
||||
/* does AM use maintenance_work_mem? */
|
||||
bool amusemaintenanceworkmem;
|
||||
/* does AM store tuple information only at block granularity? */
|
||||
bool amsummarizing;
|
||||
/* OR of parallel vacuum flags. See vacuum.h for flags. */
|
||||
uint8 amparallelvacuumoptions;
|
||||
/* type of data stored in index, or InvalidOid if variable */
|
||||
|
||||
@@ -249,7 +249,8 @@ extern void heap_abort_speculative(Relation relation, ItemPointer tid);
|
||||
extern TM_Result heap_update(Relation relation, ItemPointer otid,
|
||||
HeapTuple newtup,
|
||||
CommandId cid, Snapshot crosscheck, bool wait,
|
||||
struct TM_FailureData *tmfd, LockTupleMode *lockmode);
|
||||
struct TM_FailureData *tmfd, LockTupleMode *lockmode,
|
||||
TU_UpdateIndexes *update_indexes);
|
||||
extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
|
||||
CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy,
|
||||
bool follow_updates,
|
||||
@@ -275,7 +276,7 @@ extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple);
|
||||
extern void simple_heap_insert(Relation relation, HeapTuple tup);
|
||||
extern void simple_heap_delete(Relation relation, ItemPointer tid);
|
||||
extern void simple_heap_update(Relation relation, ItemPointer otid,
|
||||
HeapTuple tup);
|
||||
HeapTuple tup, TU_UpdateIndexes *update_indexes);
|
||||
|
||||
extern TransactionId heap_index_delete_tuples(Relation rel,
|
||||
TM_IndexDeleteOp *delstate);
|
||||
|
||||
@@ -102,6 +102,22 @@ typedef enum TM_Result
|
||||
TM_WouldBlock
|
||||
} TM_Result;
|
||||
|
||||
/*
|
||||
* Result codes for table_update(..., update_indexes*..).
|
||||
* Used to determine which indexes to update.
|
||||
*/
|
||||
typedef enum TU_UpdateIndexes
|
||||
{
|
||||
/* No indexed columns were updated (incl. TID addressing of tuple) */
|
||||
TU_None,
|
||||
|
||||
/* A non-summarizing indexed column was updated, or the TID has changed */
|
||||
TU_All,
|
||||
|
||||
/* Only summarized columns were updated, TID is unchanged */
|
||||
TU_Summarizing
|
||||
} TU_UpdateIndexes;
|
||||
|
||||
/*
|
||||
* When table_tuple_update, table_tuple_delete, or table_tuple_lock fail
|
||||
* because the target tuple is already outdated, they fill in this struct to
|
||||
@@ -526,7 +542,7 @@ typedef struct TableAmRoutine
|
||||
bool wait,
|
||||
TM_FailureData *tmfd,
|
||||
LockTupleMode *lockmode,
|
||||
bool *update_indexes);
|
||||
TU_UpdateIndexes *update_indexes);
|
||||
|
||||
/* see table_tuple_lock() for reference about parameters */
|
||||
TM_Result (*tuple_lock) (Relation rel,
|
||||
@@ -1514,7 +1530,7 @@ static inline TM_Result
|
||||
table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot,
|
||||
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
|
||||
bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode,
|
||||
bool *update_indexes)
|
||||
TU_UpdateIndexes *update_indexes)
|
||||
{
|
||||
return rel->rd_tableam->tuple_update(rel, otid, slot,
|
||||
cid, snapshot, crosscheck,
|
||||
@@ -2038,7 +2054,7 @@ extern void simple_table_tuple_delete(Relation rel, ItemPointer tid,
|
||||
Snapshot snapshot);
|
||||
extern void simple_table_tuple_update(Relation rel, ItemPointer otid,
|
||||
TupleTableSlot *slot, Snapshot snapshot,
|
||||
bool *update_indexes);
|
||||
TU_UpdateIndexes *update_indexes);
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user