Report sort phase progress in parallel btree build
authorAlvaro Herrera
Fri, 11 Jun 2021 23:07:32 +0000 (19:07 -0400)
committerAlvaro Herrera
Fri, 11 Jun 2021 23:07:32 +0000 (19:07 -0400)
commit065ce069ae4fe5f59251435ebfe13e14a2d5874c
treec0bf93446ef0d0d981e096d68cb3075efb16fd3a
parentb270713fd44b1378cebc3177e092add0155b55b6
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
Author: Matthias van de Meent 
Reviewed-by: Greg Nancarrow
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/1128176d-1eee-55d4-37ca-e63644422adb
src/backend/access/nbtree/nbtsort.c