Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5cc1cd5

Browse files
committed
Report sort phase progress in parallel btree build
We were already reporting it, but only after the parallel workers were finished, which is visibly much later than what happens in a serial build. With this change we report it when the leader starts its own sort phase when participating in the build (the normal case). Now this might happen a little later than when the workers start their sorting phases, but a) communicating the actual phase start from workers is likely to be a hassle, and b) the sort phase start is pretty fuzzy anyway, since sorting per se is actually initiated by tuplesort.c internally earlier than tuplesort_performsort() is called. Backpatch to pg12, where the progress reporting code for CREATE INDEX went in. Reported-by: Tomas Vondra <tomas.vondra@enterprisedb.com> Author: Matthias van de Meent <boekewurm+postgres@gmail.com> Reviewed-by: Greg Nancarrow <gregn4422@gmail.com> Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/1128176d-1eee-55d4-37ca-e63644422adb
1 parent ab55d74 commit 5cc1cd5

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/backend/access/nbtree/nbtsort.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2)
547547
}
548548
#endif /* BTREE_BUILD_STATS */
549549

550+
/* Execute the sort */
550551
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
551552
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
552553
tuplesort_performsort(btspool->sortstate);
@@ -1971,16 +1972,18 @@ _bt_parallel_scan_and_sort(BTSpool *btspool, BTSpool *btspool2,
19711972
true, progress, _bt_build_callback,
19721973
(void *) &buildstate, scan);
19731974

1974-
/*
1975-
* Execute this worker's part of the sort.
1976-
*
1977-
* Unlike leader and serial cases, we cannot avoid calling
1978-
* tuplesort_performsort() for spool2 if it ends up containing no dead
1979-
* tuples (this is disallowed for workers by tuplesort).
1980-
*/
1975+
/* Execute this worker's part of the sort */
1976+
if (progress)
1977+
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
1978+
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
19811979
tuplesort_performsort(btspool->sortstate);
19821980
if (btspool2)
1981+
{
1982+
if (progress)
1983+
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
1984+
PROGRESS_BTREE_PHASE_PERFORMSORT_2);
19831985
tuplesort_performsort(btspool2->sortstate);
1986+
}
19841987

19851988
/*
19861989
* Done. Record ambuild statistics, and whether we encountered a broken

0 commit comments

Comments
 (0)