Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/hnswbuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "access/xloginsert.h"
#include "catalog/index.h"
#include "catalog/pg_type_d.h"
#include "cdb/cdbvars.h"
#include "commands/progress.h"
#include "hnsw.h"
#include "miscadmin.h"
Expand Down Expand Up @@ -1037,6 +1038,15 @@ ComputeParallelWorkers(Relation heap, Relation index)
{
int parallel_workers;

/*
* Follow index_build(): parallel workers launched on the QD inherit
* QE-only interconnect state (ic_htab_size, numsegmentsFromQD) that is
* unset in a dispatcher backend, so disable parallelism on the QD and
* for AO tables just like the core btree build path does.
*/
if (Gp_role == GP_ROLE_DISPATCH || AMHandlerIsAO(heap->rd_amhandler))
return 0;

/* Make sure it's safe to use parallel workers */
parallel_workers = plan_create_index_workers(RelationGetRelid(heap), RelationGetRelid(index));
if (parallel_workers == 0)
Expand Down
10 changes: 8 additions & 2 deletions src/ivfbuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,14 @@ AssignTuples(IvfflatBuildState * buildstate)

pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_IVFFLAT_PHASE_ASSIGN);

/* Calculate parallel workers */
if (buildstate->heap != NULL)
/*
* Follow index_build(): parallel workers launched on the QD inherit
* QE-only interconnect state (ic_htab_size, numsegmentsFromQD) that is
* unset in a dispatcher backend, so disable parallelism on the QD and
* for AO tables just like the core btree build path does.
*/
if (buildstate->heap != NULL && Gp_role != GP_ROLE_DISPATCH &&
!AMHandlerIsAO(buildstate->heap->rd_amhandler))
parallel_workers = plan_create_index_workers(RelationGetRelid(buildstate->heap), RelationGetRelid(buildstate->index));

/* Attempt to launch parallel worker scan when required */
Expand Down
Loading