mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +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;
|
||||
HnswScanOpaque so;
|
||||
double maxMemory;
|
||||
|
||||
scan = RelationGetIndexScan(index, nkeys, norderbys);
|
||||
|
||||
@@ -138,7 +139,9 @@ hnswbeginscan(Relation index, int nkeys, int norderbys)
|
||||
/* Set support functions */
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user