pgvector.git / summary / log / commit / refs
commit 81bba1f37e047bd35d6c92c200ff087d286e182f
Author: Andrew Kane <andrew@ankane.org>
Date: Wed Nov 02 23:41:56 2022 +0000
Improved order of insert operations
src/ivfinsert.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/ivfinsert.c b/src/ivfinsert.c
index e6158e1a..a9583d27 100644
--- a/src/ivfinsert.c
+++ b/src/ivfinsert.c
@@ -113,23 +113,24 @@ InsertTuple(Relation rel, IndexTuple itup, Relation heapRel, Datum *values)
newbuf = IvfflatNewBuffer(rel, MAIN_FORKNUM);
newpage = GenericXLogRegisterBuffer(state, newbuf, GENERIC_XLOG_FULL_IMAGE);
- insertPage = BufferGetBlockNumber(newbuf);
+ /* Init new page */
+ IvfflatInitPage(newbuf, newpage);
/* Update previous buffer */
+ insertPage = BufferGetBlockNumber(newbuf);
IvfflatPageGetOpaque(page)->nextblkno = insertPage;
- /* Init page */
- IvfflatInitPage(newbuf, newpage);
-
/* Commit */
- MarkBufferDirty(buf);
MarkBufferDirty(newbuf);
+ MarkBufferDirty(buf);
GenericXLogFinish(state);
- /* Unlock */
- UnlockReleaseBuffer(buf);
- UnlockReleaseBuffer(newbuf);
+ /* Unlock extend relation lock as early as possible */
UnlockReleaseBuffer(metabuf);
+
+ /* Unlock rest */
+ UnlockReleaseBuffer(newbuf);
+ UnlockReleaseBuffer(buf);
}
}
[parent: 2d8b7e5f8173]