mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 08:36:54 +08:00
Moved logic for calculating number of samples [skip ci]
This commit is contained in:
@@ -438,12 +438,6 @@ ComputeCenters(IvfflatBuildState * buildstate)
|
|||||||
|
|
||||||
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_IVFFLAT_PHASE_KMEANS);
|
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_IVFFLAT_PHASE_KMEANS);
|
||||||
|
|
||||||
/* Target 50 samples per list, with at least 10000 samples */
|
|
||||||
/* The number of samples has a large effect on index build time */
|
|
||||||
numSamples = buildstate->lists * 50;
|
|
||||||
if (numSamples < 10000)
|
|
||||||
numSamples = 10000;
|
|
||||||
|
|
||||||
/* Skip samples for unlogged table */
|
/* Skip samples for unlogged table */
|
||||||
if (buildstate->heap == NULL)
|
if (buildstate->heap == NULL)
|
||||||
numSamples = 1;
|
numSamples = 1;
|
||||||
@@ -451,6 +445,12 @@ ComputeCenters(IvfflatBuildState * buildstate)
|
|||||||
{
|
{
|
||||||
int64 maxTuples = (int64) RelationGetNumberOfBlocks(buildstate->heap) * MaxHeapTuplesPerPage;
|
int64 maxTuples = (int64) RelationGetNumberOfBlocks(buildstate->heap) * MaxHeapTuplesPerPage;
|
||||||
|
|
||||||
|
/* Target 50 samples per list, with at least 10000 samples */
|
||||||
|
/* The number of samples has a large effect on index build time */
|
||||||
|
numSamples = buildstate->lists * 50;
|
||||||
|
if (numSamples < 10000)
|
||||||
|
numSamples = 10000;
|
||||||
|
|
||||||
/* Save memory since will not have more than max tuples */
|
/* Save memory since will not have more than max tuples */
|
||||||
numSamples = Max(Min(numSamples, maxTuples), 1);
|
numSamples = Max(Min(numSamples, maxTuples), 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user