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

Commit 0c7efd9

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 26383da commit 0c7efd9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/backend/access/nbtree/nbtsort.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2)
562562
}
563563
#endif /* BTREE_BUILD_STATS */
564564

565+
/* Execute the sort */
565566
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
566567
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
567568
tuplesort_performsort(btspool->sortstate);
@@ -1833,16 +1834,18 @@ _bt_parallel_scan_and_sort(BTSpool *btspool, BTSpool *btspool2,
18331834
true, progress, _bt_build_callback,
18341835
(void *) &buildstate, scan);
18351836

1836-
/*
1837-
* Execute this worker's part of the sort.
1838-
*
1839-
* Unlike leader and serial cases, we cannot avoid calling
1840-
* tuplesort_performsort() for spool2 if it ends up containing no dead
1841-
* tuples (this is disallowed for workers by tuplesort).
1842-
*/
1837+
/* Execute this worker's part of the sort */
1838+
if (progress)
1839+
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
1840+
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
18431841
tuplesort_performsort(btspool->sortstate);
18441842
if (btspool2)
1843+
{
1844+
if (progress)
1845+
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
1846+
PROGRESS_BTREE_PHASE_PERFORMSORT_2);
18451847
tuplesort_performsort(btspool2->sortstate);
1848+
}
18461849

18471850
/*
18481851
* Done. Record ambuild statistics, and whether we encountered a broken

0 commit comments

Comments
 (0)