mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Predicate locking in GIN index
Predicate locks are used on per page basis only if fastupdate = off, in opposite case predicate lock on pending list will effectively lock whole index, to reduce locking overhead, just lock a relation. Entry and posting trees are essentially B-tree, so locks are acquired on leaf pages only. Author: Shubham Barai with some editorization by me and Dmitry Ivanov Review by: Alexander Korotkov, Dmitry Ivanov, Fedor Sigaev Discussion: https://www.postgresql.org/message-id/flat/CALxAEPt5sWW+EwTaKUGFL5_XFcZ0MuGBcyJ70oqbWqr42YKR8Q@mail.gmail.com
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "access/xloginsert.h"
|
||||
#include "lib/ilist.h"
|
||||
#include "miscadmin.h"
|
||||
#include "storage/predicate.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
/*
|
||||
@@ -1759,7 +1760,7 @@ leafRepackItems(disassembledLeaf *leaf, ItemPointer remaining)
|
||||
*/
|
||||
BlockNumber
|
||||
createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
|
||||
GinStatsData *buildStats)
|
||||
GinStatsData *buildStats, Buffer entrybuffer)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
Buffer buffer;
|
||||
@@ -1810,6 +1811,12 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
|
||||
page = BufferGetPage(buffer);
|
||||
blkno = BufferGetBlockNumber(buffer);
|
||||
|
||||
/*
|
||||
* Copy a predicate lock from entry tree leaf (containing posting list)
|
||||
* to posting tree.
|
||||
*/
|
||||
PredicateLockPageSplit(index, BufferGetBlockNumber(entrybuffer), blkno);
|
||||
|
||||
START_CRIT_SECTION();
|
||||
|
||||
PageRestoreTempPage(tmppage, page);
|
||||
@@ -1904,6 +1911,7 @@ ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
|
||||
btree.itemptr = insertdata.items[insertdata.curitem];
|
||||
stack = ginFindLeafPage(&btree, false, NULL);
|
||||
|
||||
GinCheckForSerializableConflictIn(btree.index, NULL, stack->buffer);
|
||||
ginInsertValue(&btree, stack, &insertdata, buildStats);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user