mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-11 15:16:54 +08:00
Ensure max memory fits into Size for HNSW index scans
This commit is contained in:
@@ -121,6 +121,7 @@ hnswbeginscan(Relation index, int nkeys, int norderbys)
|
|||||||
{
|
{
|
||||||
IndexScanDesc scan;
|
IndexScanDesc scan;
|
||||||
HnswScanOpaque so;
|
HnswScanOpaque so;
|
||||||
|
double maxMemory;
|
||||||
|
|
||||||
scan = RelationGetIndexScan(index, nkeys, norderbys);
|
scan = RelationGetIndexScan(index, nkeys, norderbys);
|
||||||
|
|
||||||
@@ -138,7 +139,9 @@ hnswbeginscan(Relation index, int nkeys, int norderbys)
|
|||||||
/* Set support functions */
|
/* Set support functions */
|
||||||
HnswInitSupport(&so->support, index);
|
HnswInitSupport(&so->support, index);
|
||||||
|
|
||||||
so->maxMemory = (Size) (work_mem * 1024.0 * hnsw_scan_mem_multiplier);
|
/* Calculate max memory */
|
||||||
|
maxMemory = (double) work_mem * hnsw_scan_mem_multiplier * 1024.0;
|
||||||
|
so->maxMemory = Min(maxMemory, (double) SIZE_MAX);
|
||||||
|
|
||||||
scan->opaque = so;
|
scan->opaque = so;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user