Moved FlushPages before HnswEndParallel

This commit is contained in:
Andrew Kane
2024-01-07 17:50:46 -08:00
parent 6132428914
commit 85fdecd79b

View File

@@ -885,7 +885,7 @@ BuildGraph(HnswBuildState * buildstate, ForkNumber forkNum)
UpdateProgress(PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_HNSW_PHASE_LOAD); UpdateProgress(PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_HNSW_PHASE_LOAD);
/* Calculate parallel workers */ /* Calculate parallel workers */
if (hnsw_enable_parallel_build) if (buildstate->heap != NULL && hnsw_enable_parallel_build)
parallel_workers = ComputeParallelWorkers(buildstate->heap, buildstate->index); parallel_workers = ComputeParallelWorkers(buildstate->heap, buildstate->index);
/* Attempt to launch parallel worker scan when required */ /* Attempt to launch parallel worker scan when required */
@@ -896,7 +896,9 @@ BuildGraph(HnswBuildState * buildstate, ForkNumber forkNum)
HnswBeginParallel(buildstate, buildstate->indexInfo->ii_Concurrent, parallel_workers); HnswBeginParallel(buildstate, buildstate->indexInfo->ii_Concurrent, parallel_workers);
} }
/* Add tuples to sort */ /* Add tuples to graph */
if (buildstate->heap != NULL)
{
if (buildstate->hnswleader) if (buildstate->hnswleader)
buildstate->reltuples = ParallelHeapScan(buildstate); buildstate->reltuples = ParallelHeapScan(buildstate);
else else
@@ -909,6 +911,11 @@ BuildGraph(HnswBuildState * buildstate, ForkNumber forkNum)
true, BuildCallback, (void *) buildstate, NULL); true, BuildCallback, (void *) buildstate, NULL);
#endif #endif
} }
}
/* Flush pages */
if (!buildstate->flushed)
FlushPages(buildstate);
/* End parallel build */ /* End parallel build */
if (buildstate->hnswleader) if (buildstate->hnswleader)
@@ -944,12 +951,8 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo,
InitBuildState(buildstate, heap, index, indexInfo, forkNum); InitBuildState(buildstate, heap, index, indexInfo, forkNum);
if (buildstate->heap != NULL)
BuildGraph(buildstate, forkNum); BuildGraph(buildstate, forkNum);
if (!buildstate->flushed)
FlushPages(buildstate);
if (RelationNeedsWAL(index)) if (RelationNeedsWAL(index))
log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocks(index), true); log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocks(index), true);