diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-03-04 12:59:10 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-03-04 12:59:10 -0500 |
commit | df4685fb0cad1c75970b6e8d0aacca4d03545e04 (patch) | |
tree | 88691c5fd5004e2099bd2d0725fe7143cd7aa2ca /src/backend/access/transam/parallel.c | |
parent | 546cd0d7664ee0f120ef3b267d4303190bdfdb94 (diff) | |
download | postgresql-df4685fb0cad1c75970b6e8d0aacca4d03545e04.tar.gz postgresql-df4685fb0cad1c75970b6e8d0aacca4d03545e04.zip |
Minor optimizations based on ParallelContext having nworkers_launched.
Originally, we didn't have nworkers_launched, so code that used parallel
contexts had to be preprared for the possibility that not all of the
workers requested actually got launched. But now we can count on knowing
the number of workers that were successfully launched, which can shave
off a few cycles and simplify some code slightly.
Amit Kapila, reviewed by Haribabu Kommi, per a suggestion from Peter
Geoghegan.
Diffstat (limited to 'src/backend/access/transam/parallel.c')
-rw-r--r-- | src/backend/access/transam/parallel.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c index 4f91cd0265d..0bba9a7dbda 100644 --- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -520,7 +520,7 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt) */ CHECK_FOR_INTERRUPTS(); - for (i = 0; i < pcxt->nworkers; ++i) + for (i = 0; i < pcxt->nworkers_launched; ++i) { if (pcxt->worker[i].error_mqh != NULL) { @@ -560,7 +560,7 @@ WaitForParallelWorkersToExit(ParallelContext *pcxt) int i; /* Wait until the workers actually die. */ - for (i = 0; i < pcxt->nworkers; ++i) + for (i = 0; i < pcxt->nworkers_launched; ++i) { BgwHandleStatus status; @@ -610,7 +610,7 @@ DestroyParallelContext(ParallelContext *pcxt) /* Kill each worker in turn, and forget their error queues. */ if (pcxt->worker != NULL) { - for (i = 0; i < pcxt->nworkers; ++i) + for (i = 0; i < pcxt->nworkers_launched; ++i) { if (pcxt->worker[i].error_mqh != NULL) { @@ -708,7 +708,7 @@ HandleParallelMessages(void) if (pcxt->worker == NULL) continue; - for (i = 0; i < pcxt->nworkers; ++i) + for (i = 0; i < pcxt->nworkers_launched; ++i) { /* * Read as many messages as we can from each worker, but stop when |