File tree Expand file tree Collapse file tree
Open diff view settings
Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change 1+ ## 0.8.5 (unreleased)
2+
3+ - Reduced memory usage for small tables for IVFFlat index builds
4+
15## 0.8.4 (2026-06-30)
26
37- Fixed ` hnsw graph not repaired ` error with HNSW vacuuming
Original file line number Diff line number Diff line change @@ -447,6 +447,13 @@ ComputeCenters(IvfflatBuildState * buildstate)
447447 /* Skip samples for unlogged table */
448448 if (buildstate -> heap == NULL )
449449 numSamples = 1 ;
450+ else
451+ {
452+ int64 maxTuples = (int64 ) RelationGetNumberOfBlocks (buildstate -> heap ) * MaxHeapTuplesPerPage ;
453+
454+ /* Save memory since will not have more than max tuples */
455+ numSamples = Max (Min (numSamples , maxTuples ), 1 );
456+ }
450457
451458 /* Sample rows */
452459 buildstate -> memoryUsed += VECTOR_ARRAY_SIZE (numSamples , buildstate -> itemsize );
Original file line number Diff line number Diff line change @@ -173,3 +173,27 @@ ERROR: 0 is outside the valid range for parameter "ivfflat.max_probes" (1 .. 32
173173SET ivfflat.max_probes = 32769;
174174ERROR: 32769 is outside the valid range for parameter "ivfflat.max_probes" (1 .. 32768)
175175DROP TABLE t;
176+ -- memory
177+ CREATE TABLE t (val vector(2000));
178+ CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 4096);
179+ NOTICE: ivfflat index created with little data
180+ DETAIL: This will cause low recall.
181+ HINT: Drop the index until the table has more data.
182+ DROP TABLE t;
183+ SET maintenance_work_mem = '1MB';
184+ CREATE TABLE t (val vector(2000));
185+ CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
186+ NOTICE: ivfflat index created with little data
187+ DETAIL: This will cause low recall.
188+ HINT: Drop the index until the table has more data.
189+ DROP TABLE t;
190+ RESET maintenance_work_mem;
191+ SET maintenance_work_mem = '5MB';
192+ CREATE TABLE t (val vector(2000));
193+ INSERT INTO t (val) VALUES (array_fill(0, ARRAY[2000]));
194+ CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
195+ NOTICE: ivfflat index created with little data
196+ DETAIL: This will cause low recall.
197+ HINT: Drop the index until the table has more data.
198+ DROP TABLE t;
199+ RESET maintenance_work_mem;
Original file line number Diff line number Diff line change @@ -97,3 +97,22 @@ SET ivfflat.max_probes = 0;
9797SET ivfflat .max_probes = 32769 ;
9898
9999DROP TABLE t;
100+
101+ -- memory
102+
103+ CREATE TABLE t (val vector(2000 ));
104+ CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 4096 );
105+ DROP TABLE t;
106+
107+ SET maintenance_work_mem = ' 1MB' ;
108+ CREATE TABLE t (val vector(2000 ));
109+ CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
110+ DROP TABLE t;
111+ RESET maintenance_work_mem;
112+
113+ SET maintenance_work_mem = ' 5MB' ;
114+ CREATE TABLE t (val vector(2000 ));
115+ INSERT INTO t (val) VALUES (array_fill(0 , ARRAY[2000 ]));
116+ CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
117+ DROP TABLE t;
118+ RESET maintenance_work_mem;
You can’t perform that action at this time.
0 commit comments