Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wewnr-0059dI-2C for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Jul 2026 15:24:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wewnq-00EYDG-1W for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Jul 2026 15:24:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wewnq-00EYD5-0W for pgsql-hackers@lists.postgresql.org; Wed, 01 Jul 2026 15:24:42 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wewnn-00000001DTK-2iDZ for pgsql-hackers@lists.postgresql.org; Wed, 01 Jul 2026 15:24:41 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-475417f010dso533667f8f.2 for ; Wed, 01 Jul 2026 08:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1782919478; x=1783524278; darn=lists.postgresql.org; h=message-id:date:content-id:mime-version:comments:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mckWAKZG/isUthDHVcScQ4iWUJqGzYSRqDJw5rCgaUY=; b=NTrkljIqGSpzVk1S5eSwwW/ugIisy6F+6HYmu2evuR0Ivc+EyaBDjlJbBAqx/E5FX1 a/gUhhffJLF2eZu531HeVib3pw6hgwnwSZYKZ04EpJEdBTvHvBxJ3oNzkzt/GOVu7eDa QPn3DKjW7WcSa8oqKO4jsFW0T6KXptwF/5LEPD1QvDvUJfjDy5ypwtUp2DawGycNK4B/ LGx1PWVp4V7Q88DZ83kzbkaGjNS+7vhWuDPxNhxM0X4kU/8awT6QT6nz0wX6gaoyO3fJ k+15A/rIq0un/9gRJKZVeY+S6jL85MvvzcVadseGZVla9i8bsjUMZP/aqP0h3sgl/Y7g 8HuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782919478; x=1783524278; h=message-id:date:content-id:mime-version:comments:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=mckWAKZG/isUthDHVcScQ4iWUJqGzYSRqDJw5rCgaUY=; b=HMUJ6sj0Iewxx/tJqvBOlo1xA6wNA1vOpZCrobQA8Txf+TZlmIVjokdGF1Cb2/ibow cMF3+TEJrxY0HAkiHr/PDYYWNQp54VqYnCO1jNyAkEJ427YNQ3Dssc4ARTTDlRI56uhq Io5qssA2TfZxkySmpH/m2zWU9DKZq/9RDGbgA7TlWvcGYDeVYdLz/7W0EzbEuDpUl0rN nPwSMwRPDBE6fJ0guwOer6b0ebsWZSIZ1BGwgr8DGfSpsJAnKGBEfcLlcEgusgq99SB6 CKl5DwWm9LSXX/8t4aLZuv/pQ9NZAzA3DoBBrE73f6s+x4g9wk2LdD64h8KIzuBfjE0Q s03A== X-Gm-Message-State: AOJu0YzJP8ZE4/rjOm/VUlv5wA8lPMjl2b//9SQB7wv5g/pStcCGzD34 pxN8jgRflY3M6Y/zTiEoqHd7L/5DdbugL/tVAq19U2vmPHQONlQrfTOuoQpqouDoKig= X-Gm-Gg: AfdE7cmmEPhcvZYLofLnlj7y2TudIqje1OCdxV++QYyJXnRad1WGDfco38bHPYz+PnQ w68P3HN1LqSsBcQLqa1F5NsgYwjgxmTPagAdQ/fg10Mnp9NJGo8bllsvAp7axiQn2/+UORD5I7x l0awBqpq6xiDqj5H5s2b7hYiOLTDrHDvZ+kCQ+q9sl47yhal0dXgdq7xJRWYvrkuhGeKKt4Vzft DBxXTC9ndQMTuTkvgNC4qHkk2uvwK4y+0AF9ldOQj/7v2NO6s7fK1raq71IqWNiSv6RZCAIemi3 I5Dt0H2z8AzEE6LFaebZ9Nr/2mH7egeJOFr5+aiMLCoZj9hLd3lthrq/C1kfYLpSyEsZ9x1+Pgy RMPwXMfAWmcGNGaY/lk75N6YuY4d2cCl3f8L90GDnJfnDWVuTld9fhVRSOcZyCZ4zUNvVbcjCJw bh8f/43WUdWaFkd2dootKFVA+gag== X-Received: by 2002:a05:600c:6d8c:b0:492:68f5:6b30 with SMTP id 5b1f17b1804b1-493c2b57006mr22118915e9.17.1782919478496; Wed, 01 Jul 2026 08:24:38 -0700 (PDT) Received: from localhost (109-81-168-148.rct.o2.cz. [109.81.168.148]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493be82fd71sm121152985e9.15.2026.07.01.08.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 08:24:38 -0700 (PDT) From: Antonin Houska To: Rahila Syed cc: pgsql-hackers@lists.postgresql.org, bharath.rupireddyforpostgres@gmail.com, mihailnikalayeu@gmail.com, adam8157@gmail.com Subject: Re: Allow progress tracking of sub-commands In-reply-to: References: <106920.1782734246@localhost> Comments: In-reply-to Rahila Syed message dated "Tue, 30 Jun 2026 00:03:02 +0800." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <69362.1782919477.1@localhost> Date: Wed, 01 Jul 2026 17:24:37 +0200 Message-ID: <69363.1782919477@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Rahila Syed wrote: > Thanks for suggesting enhancements to the progress reporting framework. > > I have comments on the solution's approach. Thanks. > /* > + * Some commands have a sub-command, e.g. REPACK (re)builds indexes. The > + * target can be different, e.g. when the sub-command builds an index on > + * TOAST relation. > + */ > + ProgressCommandType st_progress_command2; > + Oid st_progress_command_target2; > + int64 st_progress_param2[PGSTAT_NUM_PROGRESS_PARAM]; > > This approach only works for a nesting depth of 2, not for 3 or more > levels of subcommands, for instance. > I am not aware of a concrete example of such a command but I think we should > keep the design generic enough to accommodate this. I thought about all the current command types typedef enum ProgressCommandType { PROGRESS_COMMAND_INVALID, PROGRESS_COMMAND_VACUUM, PROGRESS_COMMAND_ANALYZE, PROGRESS_COMMAND_CREATE_INDEX, PROGRESS_COMMAND_BASEBACKUP, PROGRESS_COMMAND_COPY, PROGRESS_COMMAND_REPACK, } ProgressCommandType; The typical problem occurs when REPACK performs reindexing (CREATE_INDEX). I could only think of one case where the depth would be more than 2: an index function (executed during the build) running another monitored command. In a development build (with my patch applied), such a case would fire an assertion in pgstat_progress_start_command(), while in a production build that innermost command would only overwrite the status of the CREATE INDEX command. I don't consider such a crazy case worth more effort. > Shall we consider reporting the progress counters of a sub-command as > additional parameters > in the existing st_progress_param[] array? A top level command can > define the progress parameters > based on the number and type of sub-commands it expects to see. This > way we can even restrict or alter the counters we would like to report > for a sub-command. This also avoids changing PgBackendStatus every > time we encounter a command requiring deeper nesting levels. It might be possible to make sure in some cases that parameter numbers not used by the main command are used by the sub-command, but I think it would make coding quite tricky. And if you wanted to be sure that there are no collisions of parameter numbers, you'd need st_progress_param[] to be twice as large as the maximum number of parameters per command anyway. So this approach wouldn't help as long as you're concerned of memory consumption. -- Antonin Houska Web: https://www.cybertec-postgresql.com