From f9d627c9a95ce0a32388afa3e9bb6296077a1943 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Oct 2024 21:05:04 -0700 Subject: [PATCH] Updated default value of hnsw.scan_mem_multiplier [skip ci] --- README.md | 6 +++--- src/hnsw.c | 2 +- test/expected/hnsw_vector.out | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b09d98f..12303de 100644 --- a/README.md +++ b/README.md @@ -505,10 +505,10 @@ SET hnsw.max_scan_tuples = 20000; Note: This is approximate and does not apply to the initial scan -When increasing this, you may also need to increase the max amount of memory an iterative scan can use, which is a multiple of `work_mem` (2 by default) +When increasing this, you may also need to increase the max amount of memory an iterative scan can use, which is a multiple of `work_mem` (1 by default) ```sql -SET hnsw.scan_mem_multiplier = 4; +SET hnsw.scan_mem_multiplier = 2; ``` You can see when this is needed by enabling debug messages @@ -520,7 +520,7 @@ SET client_min_messages = debug1; which will show when a scan reaches the memory limit ```text -DEBUG: hnsw index scan reached memory limit after 40000 tuples +DEBUG: hnsw index scan reached memory limit after 20000 tuples HINT: Increase hnsw.scan_mem_multiplier to scan more tuples. ``` diff --git a/src/hnsw.c b/src/hnsw.c index 2451994..08ded06 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -91,7 +91,7 @@ HnswInit(void) /* Same range and default as hash_mem_multiplier */ DefineCustomRealVariable("hnsw.scan_mem_multiplier", "Sets the multiple of work_mem to use for iterative scans", NULL, &hnsw_scan_mem_multiplier, - 2, 1, 1000, PGC_USERSET, 0, NULL, NULL, NULL); + 1, 1, 1000, PGC_USERSET, 0, NULL, NULL, NULL); MarkGUCPrefixReserved("hnsw"); } diff --git a/test/expected/hnsw_vector.out b/test/expected/hnsw_vector.out index 86b27f5..a1012fa 100644 --- a/test/expected/hnsw_vector.out +++ b/test/expected/hnsw_vector.out @@ -185,7 +185,7 @@ ERROR: 0 is outside the valid range for parameter "hnsw.max_scan_tuples" (1 .. SHOW hnsw.scan_mem_multiplier; hnsw.scan_mem_multiplier -------------------------- - 2 + 1 (1 row) SET hnsw.scan_mem_multiplier = 0;