Reduced memory usage for small tables for IVFFlat index builds - resolves #995 and resolves #996

Co-authored-by: Itai Spiegel <itai@mave.com>
This commit is contained in:
Andrew Kane
2026-07-01 11:54:21 -07:00
parent 1d458ad5d7
commit b383e4d191
4 changed files with 54 additions and 0 deletions

View File

@@ -447,6 +447,13 @@ ComputeCenters(IvfflatBuildState * buildstate)
/* Skip samples for unlogged table */
if (buildstate->heap == NULL)
numSamples = 1;
else
{
int64 maxTuples = (int64) RelationGetNumberOfBlocks(buildstate->heap) * MaxHeapTuplesPerPage;
/* Save memory since will not have more than max tuples */
numSamples = Max(Min(numSamples, maxTuples), 1);
}
/* Sample rows */
buildstate->memoryUsed += VECTOR_ARRAY_SIZE(numSamples, buildstate->itemsize);