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 1wJlJ1-000EhY-2c for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 04:53:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wJlJ0-005aKR-1f for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 04:53:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wJlIz-005aKA-2p for pgsql-hackers@lists.postgresql.org; Mon, 04 May 2026 04:53:18 +0000 Received: from mail-vk1-xa33.google.com ([2607:f8b0:4864:20::a33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wJlIx-000000005sh-1ED4 for pgsql-hackers@lists.postgresql.org; Mon, 04 May 2026 04:53:16 +0000 Received: by mail-vk1-xa33.google.com with SMTP id 71dfb90a1353d-56a86f0a23bso3869811e0c.0 for ; Sun, 03 May 2026 21:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777870395; cv=none; d=google.com; s=arc-20240605; b=QPPAu5kUf+72SE0+AoB6ONctR6InomZcSWS3AWQS//Iqt03Cdxto+/FpvYstqQdvq/ F4g2LwdbRIYDag7BzIbv3lCj5qPKWwrdtaWjNYx/AvA3n3QT/HTw/JJHu7Et94TfWs57 FKGlN50ftfsrkrlGp5nOkmRMPapY3qV9Bs2QaEUFc4RY4uFZfpr36UjgUNA0sf0TcrgX 6WjhQd5KKeQJyO91PyHM9SlNwITyRAUgoge1/EBR+7GFN6g8SRU3nsZI/N/2Utv3Zf0M IuqIH9pFgXRdRyQ7hcNy4NHKsmLUIlGFIKabK0odQiaaXM1QyZTUukfKlEV1K5YoMyXb YeqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=SYPGfbjh6+3lQXnmaAPCi/b0pX7YGnu5D8FwkQX9ycU=; fh=rxy+4R5RAfz27w/g7ZsxrTiDybElymesvHD6KaufTT8=; b=Bva20j8Upp2RxL/T2mSD5gvb+N65gVcfVNsyEu6slgW908hvKZm7QC2wwi6UZSHG3d gMm5k6qHV5frLuU2Hc1KUM7NtAO2KepXW5Bd5UeePqUQQIgmgj+RNyD2FVTG0hLZyTv2 aw8nOhV7Hntbsp2lzYpxRMqCL95xost3QcPPEoOaIi1imIWkvtfVdcfICXlBP76kezMW u6d9COizyXOstjDY2pCFHtzEq5yMzsxbMDZAih+IxjUg6gjep0f0n6cHYYdznuUem1BX j77Etv39FA48zgRTPWBK+ZiJGL1KWHlmsaoaTOI650zArQwbXY/OV2IjKh4xZ3CKNJiu 5KBw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777870395; x=1778475195; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SYPGfbjh6+3lQXnmaAPCi/b0pX7YGnu5D8FwkQX9ycU=; b=josARv8tsrMutGpaPh4tZ0E+hTi0MuXyx6wJp7fcAGx55P4J8GBmqBjXjefbMA6hYf R6Bdif8y2TLcIfG2F87TsTReBr3W3hRuvDeFPjANAWXtQ+lkrWODhzb5vsbohxtwruNn tKTVecNK+7Ajp9C9qEGVaNUrMUNaFDrB6sxgrx4YhOfEW7gaeXi3rTYo9kBCOko20CdH R3+8GP2bH/VyrDvMUHb6ejleT9bk1QysSP8yZMhJQKCs1kB4B7mebGBZHqUR7CxG88AW +rnnCBh+9r0D4Ob6upea2hvGfVVf2qI7acY7fEh4VOBD0rV/zNOxhlvrOpOMZSlc0/c8 xUJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777870395; x=1778475195; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SYPGfbjh6+3lQXnmaAPCi/b0pX7YGnu5D8FwkQX9ycU=; b=iSCww7W2EHl1A3hMPb2TmhrBsiNZSVrSStv3R244dXOFAogKcBPnjz4a3/gUdZ6Dvm mYqT5+dZZ8A3fSc6dnucO3rgk10Cf7BbWYha+Tm0FOH5FahjMETytDm5mtBJUksElOFH mIMQ+hnw/LwoJ0RAFzfjrh2yf+vGYAVNSUsGu5BSKjsuLtAftMWqMuDz6gFhvvZ8Y3mY rP+iuriThEe+zEaUh26uVY4CpW3Fm2jkxSoKvbhafjCHLQCR8YlKilFvkfW+eD+/OF3s OyWGk3pd+lTrDMQ1d0oFNFQ4/2bzze4OUtuw8XgpPEKHIVTpA34Uaw8dkAnCHV4M2rIz 2JvQ== X-Gm-Message-State: AOJu0Yz9OG0nLooSD0oHgxu3cgvQ4KbGop5DxcZe4CWIiAL9XHXFzqmN eurJr/v0Ls4naNSj4/5/dk8TDv6J+2zKO7tDzx7+LQZKnQyyrnyNtiyzL6o3yA4W7gr+MeNDHwe M3Dui8Qu9Euztgym2hkQ69ajecb9lR84= X-Gm-Gg: AeBDiev4D1eRHhcwsx1VbPVsUsyhQtu50KinN8fFDy2ZAeY01La+OaQQbXJhBFRDWkG z35GFG8mhvFlK/5yyXd2TSZMJdDBye1rp61/QOsISDCGT1ePFOeOIaGctZM7oEljT+WZg7ejNFe 6nh3GKbADjZOTri5vphgyiqf+Avke5x9N/R27Kr+n7BUvN5ES3xKLNFHmM4EHBVORI9C2DVDvbC P3012/bY54aoWBJDQVSGIrxECPWJosAE5JumDI6AbNdhgO8XrH9HOzHAUKLrQjDpCWE9yiDuhB1 nKfb1maUfoaGKLFSJIwSaGvjh9Be X-Received: by 2002:a05:6122:1307:b0:56d:31e1:2c9c with SMTP id 71dfb90a1353d-5750c466fe8mr3309888e0c.3.1777870395019; Sun, 03 May 2026 21:53:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: SATYANARAYANA NARLAPURAM Date: Sun, 3 May 2026 21:53:04 -0700 X-Gm-Features: AVHnY4IDuksYe33s7c8ClTZxtRNSNevT-J3IsVG6RzQ-irGkTi7FdUUmpHkIgFw Message-ID: Subject: Re: Report index currently being vacuumed in pg_stat_progress_vacuum To: Bharath Rupireddy Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="0000000000005a14fd0650f6b556" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005a14fd0650f6b556 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Sun, May 3, 2026 at 7:01=E2=80=AFPM Bharath Rupireddy < bharath.rupireddyforpostgres@gmail.com> wrote: > Hi, > > When VACUUM is in the "vacuuming indexes" or "cleaning up indexes" phase, > there is currently no easy way to tell which specific index is being > processed. The progress report view shows indexes_total and > indexes_processed counters, but not which index is actively being worked = on. > > This makes it difficult to debug slow or stuck autovacuum workers on > tables with multiple indexes of different types (btree, GIN, GiST, BRIN, > HNSW, etc.), since one cannot determine which index type or which specifi= c > index is causing the delay. > > Please find the attached patch adds a new column current_index_relid to > pg_stat_progress_vacuum that reports the OID of the index currently being > vacuumed or cleaned up. The column is reported for both the "vacuuming > indexes" phase and the "cleaning up indexes" phase. > > When indexes are being vacuumed in parallel, each parallel worker emits > its own row in pg_stat_progress_vacuum with current_index_relid set to th= e > index it is currently processing, and leader_pid pointing to the leader > process. > > Appreciate any feedback. Thank you! > > [1] Example output: > > pid | datname | relid | table_name | phase | started_by | > current_index_relid | index_name | leader_pid > > ------+----------+-------+------------+-------------------+------------+-= --------------------+---------------+------------ > 1420 | postgres | 16395 | vac_test | vacuuming indexes | autovacuum | > 16398 | vac_test_idx1 | > 1421 | postgres | 16395 | vac_test | vacuuming indexes | | > 16399 | vac_test_idx2 | 1420 > 1423 | postgres | 16395 | vac_test | vacuuming indexes | | > 16400 | vac_test_idx3 | 1420 > (3 rows) > > pid | datname | relid | table_name | phase | started_by | > current_index_relid | index_name | leader_pid > > ------+----------+-------+------------+-------------------+------------+-= --------------------+---------------+------------ > 1346 | postgres | 16395 | vac_test | vacuuming indexes | manual | > 16398 | vac_test_idx1 | > (1 row) > > [2] > SELECT v.pid, v.datname, v.relid, c.relname AS table_name, > v.phase, v.started_by, v.current_index_relid, > COALESCE(ic.relname, '') AS index_name, v.leader_pid > FROM pg_stat_progress_vacuum v > JOIN pg_class c > ON c.oid =3D v.relid > LEFT JOIN pg_class ic > ON ic.oid =3D v.current_index_relid > WHERE v.relid =3D $tbl_oid > ORDER BY > v.leader_pid, > v.pid; > Bharath, thanks for the patch! A few comments: (1) Do we need a global API? Can we add a leader_pid field in PVShared? +pid_t +GetParallelLeaderPid(void) +{ + return ParallelLeaderPid; +} (2): Looks like current_index_relid is not cleared when we leave the index phases.As a result, once any index has been processed, pg_stat_progress_vacuum.current_index_relid keeps reporting that relid through vacuuming heap, truncating heap, cleaning up indexes. This will be confusing to the user. Something like below: 1795819|vacuuming heap|0/0|16392|t1_pkey|LEADER (3) leader_pid type should be integer type similar to pg_Stat_activity? Thanks, Satya --0000000000005a14fd0650f6b556 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Sun, May 3, 2= 026 at 7:01=E2=80=AFPM Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> = wrote:
Hi,

When VACUUM is in the= "vacuuming indexes" or "cleaning up indexes" phase, th= ere is currently no easy way to tell which specific index is being processe= d. The progress report view shows indexes_total and indexes_processed count= ers, but not which index is actively being worked on.

This makes it = difficult to debug slow or stuck autovacuum workers on tables with multiple= indexes of different types (btree, GIN, GiST, BRIN, HNSW, etc.), since one= cannot determine which index type or which specific index is causing the d= elay.

Please find the attached patch adds a new column current_index= _relid to pg_stat_progress_vacuum that reports the OID of the index current= ly being vacuumed or cleaned up. The column is reported for both the "= vacuuming indexes" phase and the "cleaning up indexes" phase= .

When indexes are being vacuumed in parallel, each parallel worker = emits its own row in pg_stat_progress_vacuum with current_index_relid set t= o the index it is currently processing, and leader_pid pointing to the lead= er process.

Appreciate any feedback. Thank you!

[1] Example o= utput:

=C2=A0pid =C2=A0| datname =C2=A0| re= lid | table_name | =C2=A0 =C2=A0 =C2=A0 phase =C2=A0 =C2=A0 =C2=A0 | starte= d_by | current_index_relid | =C2=A0index_name =C2=A0 | leader_pid
-----= -+----------+-------+------------+-------------------+------------+--------= -------------+---------------+------------
=C2=A01420 | postgres | 16395= | vac_test =C2=A0 | vacuuming indexes | autovacuum | =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 16398 | vac_test_idx1 | =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0
=C2=A01421 | postgres | 16395 | vac_test =C2=A0 | vacuumin= g indexes | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 16399 | vac_test_idx2 | =C2=A0 =C2=A0 =C2=A0 1= 420
=C2=A01423 | postgres | 16395 | vac_test =C2=A0 | vacuuming indexes = | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 16400 | vac_test_idx3 | =C2=A0 =C2=A0 =C2=A0 1420
(= 3 rows)

=C2=A0pid =C2=A0| datname = =C2=A0| relid | table_name | =C2=A0 =C2=A0 =C2=A0 phase =C2=A0 =C2=A0 =C2= =A0 | started_by | current_index_relid | =C2=A0index_name =C2=A0 | leader_p= id
------+----------+-------+------------+-------------------+---------= ---+---------------------+---------------+------------
=C2=A01346 | post= gres | 16395 | vac_test =C2=A0 | vacuuming indexes | manual =C2=A0 =C2=A0 |= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 16398 | vac_test_idx1 | = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
(1 row)


[2]
SELECT v.pid, v.datname, v.relid, c.relname AS table_name,=
=C2=A0 =C2=A0 =C2=A0 =C2=A0v.phase, v.started_by, v.current_index_relid= ,
=C2=A0 =C2=A0 =C2=A0 =C2=A0COALESCE(ic.relname, '') AS index_n= ame, v.leader_pid
FROM pg_stat_progress_vacuum v
JOIN pg_class c
= =C2=A0 =C2=A0 ON c.oid =3D v.relid
LEFT JOIN pg_class ic
=C2=A0 =C2= =A0 ON ic.oid =3D v.current_index_relid
WHERE v.relid =3D $tbl_oid
OR= DER BY
=C2=A0 =C2=A0 v.leader_pid,
=C2=A0 =C2=A0 v.pid;
<= /div>

Bharath, thanks for the patch! = A few comments:

=C2=A0(1) Do we need a global API?= Can we add a leader_pid field in PVShared?

+pid_t=
+GetParallelLeaderPid(void)
+{
+ return ParallelLeaderPid;
+}<= /div>

(2):=C2=A0 Looks like current_index_relid is not c= leared when we leave the index phases.As a result, once any index has been = processed,=C2=A0
pg_stat_progress_vacuum.current_index_relid keep= s reporting that relid through vacuuming heap, truncating heap, cleaning up= indexes.=C2=A0
This will be confusing to the user. Something lik= e below:

1795819|vacuuming heap|0/0|16392|t1_pkey|= LEADER

(3)=C2=A0leader_pid type should be integer = type similar to pg_Stat_activity?

Thanks,
Satya
--0000000000005a14fd0650f6b556--