mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 22:56:55 +08:00
Removed index page pinning for HNSW
This commit is contained in:
@@ -218,7 +218,6 @@ typedef HnswNeighborTupleData * HnswNeighborTuple;
|
|||||||
typedef struct HnswScanOpaqueData
|
typedef struct HnswScanOpaqueData
|
||||||
{
|
{
|
||||||
bool first;
|
bool first;
|
||||||
Buffer buf;
|
|
||||||
List *w;
|
List *w;
|
||||||
MemoryContext tmpCtx;
|
MemoryContext tmpCtx;
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ hnswbeginscan(Relation index, int nkeys, int norderbys)
|
|||||||
scan = RelationGetIndexScan(index, nkeys, norderbys);
|
scan = RelationGetIndexScan(index, nkeys, norderbys);
|
||||||
|
|
||||||
so = (HnswScanOpaque) palloc(sizeof(HnswScanOpaqueData));
|
so = (HnswScanOpaque) palloc(sizeof(HnswScanOpaqueData));
|
||||||
so->buf = InvalidBuffer;
|
|
||||||
so->first = true;
|
so->first = true;
|
||||||
so->tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
|
so->tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"Hnsw scan temporary context",
|
"Hnsw scan temporary context",
|
||||||
@@ -179,7 +178,6 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
{
|
{
|
||||||
HnswCandidate *hc = llast(so->w);
|
HnswCandidate *hc = llast(so->w);
|
||||||
ItemPointer heaptid;
|
ItemPointer heaptid;
|
||||||
BlockNumber indexblkno;
|
|
||||||
|
|
||||||
/* Move to next element if no valid heap TIDs */
|
/* Move to next element if no valid heap TIDs */
|
||||||
if (list_length(hc->element->heaptids) == 0)
|
if (list_length(hc->element->heaptids) == 0)
|
||||||
@@ -189,7 +187,6 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
heaptid = llast(hc->element->heaptids);
|
heaptid = llast(hc->element->heaptids);
|
||||||
indexblkno = hc->element->blkno;
|
|
||||||
|
|
||||||
hc->element->heaptids = list_delete_last(hc->element->heaptids);
|
hc->element->heaptids = list_delete_last(hc->element->heaptids);
|
||||||
|
|
||||||
@@ -201,17 +198,14 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
scan->xs_ctup.t_self = *heaptid;
|
scan->xs_ctup.t_self = *heaptid;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Unpin buffer */
|
|
||||||
if (BufferIsValid(so->buf))
|
|
||||||
ReleaseBuffer(so->buf);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An index scan must maintain a pin on the index page holding the
|
* Typically, an index scan must maintain a pin on the index page
|
||||||
* item last returned by amgettuple
|
* holding the item last returned by amgettuple. However, this is not
|
||||||
|
* needed with the current vacuum strategy, which ensures scans do not
|
||||||
|
* visit tuples in danger of being marked as deleted.
|
||||||
*
|
*
|
||||||
* https://www.postgresql.org/docs/current/index-locking.html
|
* https://www.postgresql.org/docs/current/index-locking.html
|
||||||
*/
|
*/
|
||||||
so->buf = ReadBuffer(scan->indexRelation, indexblkno);
|
|
||||||
|
|
||||||
scan->xs_recheckorderby = false;
|
scan->xs_recheckorderby = false;
|
||||||
return true;
|
return true;
|
||||||
@@ -229,10 +223,6 @@ hnswendscan(IndexScanDesc scan)
|
|||||||
{
|
{
|
||||||
HnswScanOpaque so = (HnswScanOpaque) scan->opaque;
|
HnswScanOpaque so = (HnswScanOpaque) scan->opaque;
|
||||||
|
|
||||||
/* Release pin */
|
|
||||||
if (BufferIsValid(so->buf))
|
|
||||||
ReleaseBuffer(so->buf);
|
|
||||||
|
|
||||||
/* Release shared lock */
|
/* Release shared lock */
|
||||||
UnlockPage(scan->indexRelation, HNSW_SCAN_LOCK, ShareLock);
|
UnlockPage(scan->indexRelation, HNSW_SCAN_LOCK, ShareLock);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user