On Tue, Jun 16, 2026 at 12:09:00PM -0500, Baji Shaik wrote:
> v3 attached.

Here is a v4 with an updated commit message and a test case.

-- 
nathan
>From 92922ed7491265e3b2ac375de7d9464a48e0b098 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Tue, 16 Jun 2026 12:14:24 -0500
Subject: [PATCH v4 1/1] vacuumdb: Fix --missing-stats-only for partitioned
 indexes.

The current form of the catalog query picks up partitioned indexes
on expressions that lack statistics.  However, since such indexes
never have statistics, there's no point in analyzing them.  To fix,
adjust the relevant part of the query to skip partitioned indexes.
While at it, remove the nearby stainherit check; entries for index
expressions always have stainherit = false.

Author: Baji Shaik <[email protected]>
Reviewed-by: Corey Huinker <[email protected]>
Discussion: 
https://postgr.es/m/CA%2Bfm-RPE1tEc6CUUPDyRbYTz9tF5Kw47nnk-Zq%3DyYvanbsxyCQ%40mail.gmail.com
Backpatch-through: 18
---
 src/bin/scripts/t/100_vacuumdb.pl | 1 +
 src/bin/scripts/vacuuming.c       | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bin/scripts/t/100_vacuumdb.pl 
b/src/bin/scripts/t/100_vacuumdb.pl
index 5fd55628507..58e38971b3d 100644
--- a/src/bin/scripts/t/100_vacuumdb.pl
+++ b/src/bin/scripts/t/100_vacuumdb.pl
@@ -336,6 +336,7 @@ $node->issues_sql_unlike(
 $node->safe_psql('postgres',
        "CREATE TABLE regression_vacuumdb_parted (a INT) PARTITION BY LIST 
(a);\n"
          . "CREATE TABLE regression_vacuumdb_part1 PARTITION OF 
regression_vacuumdb_parted FOR VALUES IN (1);\n"
+         . "CREATE INDEX ON regression_vacuumdb_parted ((a + 1));\n"
          . "INSERT INTO regression_vacuumdb_parted VALUES (1);\n"
          . "ANALYZE regression_vacuumdb_part1;\n");
 $node->issues_sql_like(
diff --git a/src/bin/scripts/vacuuming.c b/src/bin/scripts/vacuuming.c
index 37608806056..67a7665c5d7 100644
--- a/src/bin/scripts/vacuuming.c
+++ b/src/bin/scripts/vacuuming.c
@@ -738,10 +738,10 @@ retrieve_objects(PGconn *conn, vacuumingOptions *vacopts,
                                                         " AND a.attnum 
OPERATOR(pg_catalog.>) 0::pg_catalog.int2\n"
                                                         " AND NOT 
a.attisdropped\n"
                                                         " AND a.attstattarget 
IS DISTINCT FROM 0::pg_catalog.int2\n"
+                                                        " AND NOT 
p.inherited\n"
                                                         " AND NOT EXISTS 
(SELECT NULL FROM pg_catalog.pg_statistic s\n"
                                                         " WHERE s.starelid 
OPERATOR(pg_catalog.=) a.attrelid\n"
-                                                        " AND s.staattnum 
OPERATOR(pg_catalog.=) a.attnum\n"
-                                                        " AND s.stainherit 
OPERATOR(pg_catalog.=) p.inherited))\n");
+                                                        " AND s.staattnum 
OPERATOR(pg_catalog.=) a.attnum))\n");
 
                /* inheritance and regular stats */
                appendPQExpBufferStr(&catalog_query,
-- 
2.50.1 (Apple Git-155)

Reply via email to