mirror of
https://github.com/postgres/postgres.git
synced 2025-05-03 22:24:49 +03:00
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
This commit is contained in:
parent
26383da7d4
commit
0c7efd9757
@ -562,6 +562,7 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2)
|
|||||||
}
|
}
|
||||||
#endif /* BTREE_BUILD_STATS */
|
#endif /* BTREE_BUILD_STATS */
|
||||||
|
|
||||||
|
/* Execute the sort */
|
||||||
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
|
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
|
||||||
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
|
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
|
||||||
tuplesort_performsort(btspool->sortstate);
|
tuplesort_performsort(btspool->sortstate);
|
||||||
@ -1833,16 +1834,18 @@ _bt_parallel_scan_and_sort(BTSpool *btspool, BTSpool *btspool2,
|
|||||||
true, progress, _bt_build_callback,
|
true, progress, _bt_build_callback,
|
||||||
(void *) &buildstate, scan);
|
(void *) &buildstate, scan);
|
||||||
|
|
||||||
/*
|
/* Execute this worker's part of the sort */
|
||||||
* Execute this worker's part of the sort.
|
if (progress)
|
||||||
*
|
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
|
||||||
* Unlike leader and serial cases, we cannot avoid calling
|
PROGRESS_BTREE_PHASE_PERFORMSORT_1);
|
||||||
* tuplesort_performsort() for spool2 if it ends up containing no dead
|
|
||||||
* tuples (this is disallowed for workers by tuplesort).
|
|
||||||
*/
|
|
||||||
tuplesort_performsort(btspool->sortstate);
|
tuplesort_performsort(btspool->sortstate);
|
||||||
if (btspool2)
|
if (btspool2)
|
||||||
|
{
|
||||||
|
if (progress)
|
||||||
|
pgstat_progress_update_param(PROGRESS_CREATEIDX_SUBPHASE,
|
||||||
|
PROGRESS_BTREE_PHASE_PERFORMSORT_2);
|
||||||
tuplesort_performsort(btspool2->sortstate);
|
tuplesort_performsort(btspool2->sortstate);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Done. Record ambuild statistics, and whether we encountered a broken
|
* Done. Record ambuild statistics, and whether we encountered a broken
|
||||||
|
Loading…
x
Reference in New Issue
Block a user