pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] PR #866: docs: Add Windows warning about maintenance_work_mem limitation
2+ messages / 1 participants
[nested] [flat]
* [pgvector/pgvector] PR #866: docs: Add Windows warning about maintenance_work_mem limitation
@ 2025-07-02 19:45 "ysys143 (@ysys143)" <noreply+ysys143@github.com>
0 siblings, 0 replies; 2+ messages in thread
From: ysys143 (@ysys143) @ 2025-07-02 19:45 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
This PR addresses issue #667 by adding a warning note for Windows users about the maintenance_work_mem limitation.
## Problem
Windows users experience extremely slow index builds for large vector stores due to a 2GB limitation on `maintenance_work_mem` (up to PostgreSQL 16). As reported in #667, building an index for 37 million vectors can take over 65 hours with minimal progress.
## Solution
Added a prominent warning note at the beginning of the Windows installation section to inform users about this limitation before they attempt to build large indices.
## Changes
- Added a note warning in the Windows section of README.md
- Warning clearly states the 2GB limit and potential impact on large vector stores
Fixes #667
inline patch 1: README.md, src/hnsw.h, test/expected/hnsw_sparsevec.out and 1 more (+24/-9 lines) download inline-1.patch
diff --git a/README.md b/README.md
index 43c0430d2..828b14a74 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,8 @@ You can also install it with [Docker](#docker), [Homebrew](#homebrew), [PGXN](#p
### Windows
+> **Note:** On Windows, `maintenance_work_mem` is currently limited to 2,024MB at most (up to and including PostgreSQL 16). It might therefore take a prohibitively long time to build indices for large vector stores.
+
Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-...) is installed and run `x64 Native Tools Command Prompt for VS [version]` as administrator. Then use `nmake` to build:
```cmd
diff --git a/src/hnsw.h b/src/hnsw.h
index 5102bfb5a..9306e8530 100644
--- a/src/hnsw.h
+++ b/src/hnsw.h
@@ -13,7 +13,7 @@
#include "vector.h"
#define HNSW_MAX_DIM 2000
-#define HNSW_MAX_NNZ 1000
+#define HNSW_MAX_NNZ 1200
/* Support functions */
#define HNSW_DISTANCE_PROC 1
diff --git a/test/expected/hnsw_sparsevec.out b/test/expected/hnsw_sparsevec.out
index 2a6fe7c90..a9b5042d9 100644
--- a/test/expected/hnsw_sparsevec.out
+++ b/test/expected/hnsw_sparsevec.out
@@ -101,12 +101,18 @@ SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <+> (SELECT NULL::sparsevec))
DROP TABLE t;
-- non-zero elements
-CREATE TABLE t (val sparsevec(1001));
-INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1001])::vector::sparsevec);
+-- Test at the new limit (1200 elements should work)
+CREATE TABLE t (val sparsevec(1200));
+INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1200])::vector::sparsevec);
CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops);
-ERROR: sparsevec cannot have more than 1000 non-zero elements for hnsw index
+DROP TABLE t;
+-- Test over the new limit (1201 elements should fail)
+CREATE TABLE t (val sparsevec(1201));
+INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1201])::vector::sparsevec);
+CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops);
+ERROR: sparsevec cannot have more than 1200 non-zero elements for hnsw index
TRUNCATE t;
CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops);
-INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1001])::vector::sparsevec);
-ERROR: sparsevec cannot have more than 1000 non-zero elements for hnsw index
+INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1201])::vector::sparsevec);
+ERROR: sparsevec cannot have more than 1200 non-zero elements for hnsw index
DROP TABLE t;
diff --git a/test/sql/hnsw_sparsevec.sql b/test/sql/hnsw_sparsevec.sql
index 4ec07025f..562fe7df4 100644
--- a/test/sql/hnsw_sparsevec.sql
+++ b/test/sql/hnsw_sparsevec.sql
@@ -59,10 +59,17 @@ DROP TABLE t;
-- non-zero elements
-CREATE TABLE t (val sparsevec(1001));
-INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1001])::vector::sparsevec);
+-- Test at the new limit (1200 elements should work)
+CREATE TABLE t (val sparsevec(1200));
+INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1200])::vector::sparsevec);
+CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops);
+DROP TABLE t;
+
+-- Test over the new limit (1201 elements should fail)
+CREATE TABLE t (val sparsevec(1201));
+INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1201])::vector::sparsevec);
CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops);
TRUNCATE t;
CREATE INDEX ON t USING hnsw (val sparsevec_l2_ops);
-INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1001])::vector::sparsevec);
+INSERT INTO t (val) VALUES (array_fill(1, ARRAY[1201])::vector::sparsevec);
DROP TABLE t;
^ permalink raw [nested|flat] 2+ messages in thread
* Re: [pgvector/pgvector] PR #866: docs: Add Windows warning about maintenance_work_mem limitation
@ 2025-07-02 20:55 "ysys143 (@ysys143)" <noreply+ysys143@github.com>
0 siblings, 0 replies; 2+ messages in thread
From: ysys143 (@ysys143) @ 2025-07-02 20:55 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ysys143 closed this.
^ permalink raw [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-07-02 20:55 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-07-02 19:45 [pgvector/pgvector] PR #866: docs: Add Windows warning about maintenance_work_mem limitation "ysys143 (@ysys143)" <noreply+ysys143@github.com>
2025-07-02 20:55 Re: [pgvector/pgvector] PR #866: docs: Add Windows warning about maintenance_work_mem limitation "ysys143 (@ysys143)" <noreply+ysys143@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox