pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix CREATE INDEX progress reporting for multi-level partitioning
Date: Sat, 25 Mar 2023 19:34:20 +0000
Message-ID: <E1pg9ed-005N7i-Os@gemulon.postgresql.org> (raw)

Fix CREATE INDEX progress reporting for multi-level partitioning.

The "partitions_total" and "partitions_done" fields were updated
as though the current level of partitioning was the only one.
In multi-level cases, not only could partitions_total change
over the course of the command, but partitions_done could go
backwards or exceed the currently-reported partitions_total.

Fix by setting partitions_total to the total number of direct
and indirect children once at command start, and then just
incrementing partitions_done at appropriate points.  Invent
a new progress monitoring function "pgstat_progress_incr_param"
to simplify doing the latter.  We can avoid adding cost for the
former when doing CREATE INDEX, because ProcessUtility already
enumerates the children and it's pretty easy to pass the count
down to DefineIndex.  In principle the same could be done in
ALTER TABLE, but that's structurally difficult; for now, just
eat the cost of an extra find_all_inheritors scan in that case.

Ilya Gladyshev and Justin Pryzby

Discussion: https://postgr.es/m/a15f904a70924ffa4ca25c3c744cff31e0e6e143.camel@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/27f5c712b2c57d1c676fbf110705ac881057b57e

Modified Files
--------------
doc/src/sgml/monitoring.sgml                  | 18 ++++----
src/backend/bootstrap/bootparse.y             |  2 +
src/backend/commands/indexcmds.c              | 64 ++++++++++++++++++++++++---
src/backend/commands/tablecmds.c              |  3 ++
src/backend/tcop/utility.c                    | 11 ++++-
src/backend/utils/activity/backend_progress.c | 21 +++++++++
src/include/commands/defrem.h                 |  1 +
src/include/utils/backend_progress.h          |  1 +
8 files changed, 106 insertions(+), 15 deletions(-)



Message-ID: <E1pg9ed-005N7i-Os@gemulon.postgresql.org>
Permalink:  ../E1pg9ed-005N7i-Os@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pg9ed-005N7i-Os@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix CREATE INDEX progress reporting for multi-level partitioning
  In-Reply-To: <E1pg9ed-005N7i-Os@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox