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 1wCCJ2-001kk9-1m for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 08:06:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCCJ0-005O1B-2R for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 08:06:03 +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 1wCCJ0-005O11-0y for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 08:06:03 +0000 Received: from mail-japaneastazon11021117.outbound.protection.outlook.com ([52.101.125.117] helo=TYVP286CU001.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wCCIy-00000000ngx-0IF5 for pgsql-hackers@postgresql.org; Mon, 13 Apr 2026 08:06:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eRaMM1CY3oqU/e3vMxxjFEAF2V8b04F/AO6Vlh3YzIDLqZKNK2txvaIVxfHFVuE9wDMYjAgRKJZdeKdw/5yEw/nbbYOWxI/2/A47yioDtPEyDsY6+MnP+0FYMx0n8bSchbZWuNpsOOBfNgF0d/sKJfwIpAhAvwZ3dGsGnTIP6tFyvAbzR/zldFnIKUJM5KrH++GBg5EQi0Bi5kCwUxR4QoD7SEnG5x0maTwnPkyY2cYmN3DBtcFg8AY8snKfx//bt7OI63l0uPOD546TuDPPu0QAyQoVBLdqOX5w0Wac0XfxObGfVnrtOZ85v4UaSX4VnQ5CMT8Jx8o1sI1gAgDcVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5f54uJSamFfvzDytTmEHmb0tzuRNwwAp1yCd8dsHHyQ=; b=IvSHpz3deUMSBNo7z4ySUWXAjKn25woELl2GLy5NxXtEs31IlVgrtrrBqf/bFAOLEFCKpo912sbBICvaavH8c//lJEsnGsQ085JW1TMheD65skpmjoWfgiiob9n1lbWNK0U7uUBWeit397hd5jNn8DgddlwydpATS2jCox1mogNRvwJ3gGPgYOsABDkM/U0mrICMjhhXU6r3GFTdG1jSo+R/D9VrJHbNne4q4mxfpsdzt7csAhwKVZkir1TcDhP8PsFFkrN5XwoyNZPAX5lElNIMtwYU5SVpt0AazvffCZgp1BuKtlXiLwYD7cAFAgSfKcHIuynISj1hd7NLpe3HpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sraoss.co.jp; dmarc=pass action=none header.from=sraoss.co.jp; dkim=pass header.d=sraoss.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sraoss.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5f54uJSamFfvzDytTmEHmb0tzuRNwwAp1yCd8dsHHyQ=; b=dH5FnVbAPCubzvKWNGvmsvwacbhmTqPrtmoT19L+HywyroFxpaJBcbf4nId7VHFLpVBpJazErIkbRqOF9hy/e5Y6lQO3VibQZv/mESc2p7l1vGTsGrwl2GQgy4/NyiwuXsHUxIfPZfm5vEmorjNqNHcYg3vSx4YIbxbammK1yUtoWxrQHga45G/nOqTOzTSZWrpiouf/QY3+JJSCGJeVszYvUhKhQHwWVGEFRC1cSqV40ulpDfzpl6yyB6OgrkgEdLCROZXd3yYne7BwFyui2Ig3qO9oIH1U9AbkgjVLElBB1poo4yZbkBLQYuXubWQNa32RBdofJSd12i/sMz2clA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=sraoss.co.jp; Received: from OSZP286MB2160.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:189::12) by OS7P286MB6522.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Mon, 13 Apr 2026 08:05:53 +0000 Received: from OSZP286MB2160.JPNP286.PROD.OUTLOOK.COM ([fe80::406d:15ce:1e21:6f81]) by OSZP286MB2160.JPNP286.PROD.OUTLOOK.COM ([fe80::406d:15ce:1e21:6f81%4]) with mapi id 15.20.9769.046; Mon, 13 Apr 2026 08:05:53 +0000 Date: Mon, 13 Apr 2026 17:05:51 +0900 From: Yugo Nagata To: Yugo Nagata Cc: Sami Imseih , Michael Paquier , Pgsql Hackers Subject: Re: Track skipped tables during autovacuum and autoanalyze Message-Id: <20260413170551.5ec43ba5a2c848f0d46c6a0b@sraoss.co.jp> In-Reply-To: <20260328161802.f35b5a3e739566ffd7c1053b@sraoss.co.jp> References: <20260324151133.7940a5c1f2ebd594d54da481@sraoss.co.jp> <20260325012847.e026ba1860c07288efe3e97d@sraoss.co.jp> <20260326192203.e6dbb8d80f8d27dc15ceee59@sraoss.co.jp> <20260327163549.b5df519c0099970ddbb3412d@sraoss.co.jp> <20260328161802.f35b5a3e739566ffd7c1053b@sraoss.co.jp> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Content-Type: multipart/mixed; boundary="Multipart=_Mon__13_Apr_2026_17_05_51_+0900_T4n8olu8FNI1Va/O" X-ClientProxiedBy: TYCP286CA0347.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:7c::7) To OSZP286MB2160.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:189::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OSZP286MB2160:EE_|OS7P286MB6522:EE_ X-MS-Office365-Filtering-Correlation-Id: 387d627f-832b-4b67-0b0f-08de99337ba4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|6049299003|366016|1800799024|4053099003|4013099003|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: kaNaVwcF2onoqPbefeBWhj/RNR16Him2J0Y811HauQ07KsFhf9GtTA7q1/kK/Yx/vTBDg6RQmdK1p8Ak1kwp52vvxWoAPxbjqHCNh3JXQeyvhwmafTGFTCe94xbwUv2k5XUEvbbrRnF+ZspSF7jBZ6qBSFNhpQB0rdjFLL08kFhWVxjy522+sIs6dbI0mgPfYqdrktkqsA809g6AOrIdEWB3cVgv/XnGYbXFubnH7ZoiV0Ly7PJFpgROVEe+NwS6LVcvmwwCdO1jy0nUS+Ah3F8eCi/pQYoMH+dEC7nVGia6/Fqoc3IlAo2TEy6lIHXWVR5w6l/Q3Jz/Ch+G/0MY53nvBVKnyTu9WFzvo+qLLUk17u8Uk/Z6M5UnFGKSPm2T1Ir+ELUPkt8iZWztjGTdZCL/pwEB2su+08+dLYvRyuGM9sq8RtPxO/fjoFbT/HF7SZTL30Mm2OYb6tUqf8+P1yTVm7s9lwecOP6iaFGODSznqYweMBGfx1l/j5u/Ml2AqAlvMK+VZ+Z3YXrRbF76bRDceXd4DT1ZaXvX0dJ5i1eoR7M0B2tLzC4BI3r+jY1rMKGoDSaJ3bi1RYF5fLQRbwzAUYFlhPr0PpisfaWt5zPPiYS15m9VoEVf4qWT4fCmtYaPLZih6kEuIha/MFUDphWgIB7yGN11JQIm4DBQ0Tv/urqQqBYr3RTwgAu78tmiQWCHSHCbf2uI7IELS3LG0eGzsOod4W37CXKX3gv5Kg4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OSZP286MB2160.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(6049299003)(366016)(1800799024)(4053099003)(4013099003)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JTE0rkwqgJ4R0yq0sUs8RlpM1Zuh+bPkEbWM9JPW43+JesgwEOKlAphQzwd4?= =?us-ascii?Q?AmhbWbCUF1l0Oqo30KCc+ggGaT8aldx+mRJIX+0VpmoCjon/r2CpjJJuGgog?= =?us-ascii?Q?yOSHej6+FDSiy/QP+vWsCVBNfGIo9CwTi+CZQ9uS683WZFGUYYFrA17IZ8F2?= =?us-ascii?Q?QzXjNK4xm+jfXtH5XFP1rj0gyXlVoAOacBw65FgFSOfsr+PnIWQrOzO5jFWT?= =?us-ascii?Q?DNUXZdbIAqEdxJCYd61Mi+4deecTumsusGUVsuJPFtGQWoQZsxqUu3zA2U9K?= =?us-ascii?Q?ZTgoYtNuEnm+voeu4KMyxNVxqqlpV+4k1lEaQel/P74MPM8I8GuqoIYPmrs1?= =?us-ascii?Q?yLhFRoUKLnQ9K4Ws6jDguKjSd0rqiMRNrSg104JF62j0XbnYNNIP8OoMBW5d?= =?us-ascii?Q?4LfnTQOHgswoNVjycplQr/Yz9o2LjxO5CmKgYB5mUXSlXNk4d8Trrq8+9/9j?= =?us-ascii?Q?twGNw6EGXj3L4biLcxf2nWjYxQXqACiRy1U34Z7gSc3OFVicFho7jHMQrQ/Y?= =?us-ascii?Q?KfVuD9SHmvCehvFiloPbZ8wqQ42BMpONYEU3R3exQzj8yZUMrvIspzUt/LGM?= =?us-ascii?Q?btx7jXiOSlizl0sREXGbBam4gKfSwswaQCM3aL4h1/jOwovtbYwCFTz+6iNu?= =?us-ascii?Q?Pp+J9Vt/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KZqAwzJ9O5XhPwP498IyG?= =?us-ascii?Q?Eq4kOHWtxhHimnuNPt1DAtwNjzgMtmb9lfClhnPmBFP8xJS0+mCTh3T5M0G/?= =?us-ascii?Q?Q3wShoWGP9SbxI0u+1+rI7ArlTCiLxpH+6yKeQLhwEDZmHuZKVjytu6QCc9b?= =?us-ascii?Q?TvCWGZN3izPj+X7s01tl2RTpBkJvAYQH5sEcfhAS27hhi30H9Pzo/3ZAITqw?= =?us-ascii?Q?ePsRa5hds4LyOliWYmKtryXb7ocQy8xoqqn68gQOhkaJ3qZmWjRGVk4VcBlU?= X-MS-Exchange-AntiSpam-MessageData-1: E/g9NUJW10NzFg== X-OriginatorOrg: sraoss.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 387d627f-832b-4b67-0b0f-08de99337ba4 X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB2160.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2026 08:05:53.2882 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 75db6c32-352e-4063-ae79-cafb8623f6db X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CWwWrVe3/IpT/wI1cOGhW2pf8aC+NyECTfqVY+tr0a3Ib0bXLkn/pb7xIe+Zv9PmgMf1Cpyrkjrz2vdrJzQfRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS7P286MB6522 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Multipart=_Mon__13_Apr_2026_17_05_51_+0900_T4n8olu8FNI1Va/O Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello Sami Imseih, On Sat, 28 Mar 2026 16:18:02 +0900 Yugo Nagata wrote: > On Fri, 27 Mar 2026 11:48:27 -0500 > Sami Imseih wrote: > > > > I've attached a revised patch reflecting this change, and it also includes > > > the documentation. > > > > Thanks fo the update! > > > > I have some comments: > > > > 1/ > > +pgstat_report_skipped_vacuum_analyze(Oid relid, bits8 flags) > > > > using bit8 is fine here, but I would have just used int. For this > > case, it's just a matter of prefernace. > > That makes sense, since using int for flags seems common in other > places in the code. I'm not sure how much it affects performance, > though. > > > 2/ > > +/* flags for pgstat_flush_backend() */ > > +#define PGSTAT_REPORT_SKIPPED_VACUUM (1 << 0) /* vacuum is skipped */ > > +#define PGSTAT_REPORT_SKIPPED_ANALYZE (1 << 1) /* analyze is skipped */ > > +#define PGSTAT_REPORT_SKIPPED_AUTOVAC (1 << 2) /* skipped > > during autovacuum/autoanalyze */ > > +#define PGSTAT_REPORT_SKIPPED_ANY (PGSTAT_REPORT_SKIPPED_VACUUM | > > PGSTAT_REPORT_SKIPPED_ANALYZE) > > > > can we just have 4 flags, SKIPPED_VACUUM, SKIPPED_ANALYZE, > > SKIPPED_AUTOVACUUM, SKIPPED_AUTOANALYZE, > > which can then remove the nested if/else and makes the mapping more obvious > > I am fine with that. In that case, the nested logic would move to the > caller side. > > > 3/ > > For the sake of consistency, can we rename the fields from > > > > skipped_vacuum_count to vacuum_skipped_count, etc. ? to be similar > > to fields like vacuum_count > > Hmm, I think skipped_vacuum_count is more consistent with > fields like last_vacuum and total_vacuum_time, where the modifier > comes before vacuum/analyze. What do you think about that? > > > 4/ > > field documentation could be a bit better to match existing phrasing > > > > For example, the timestamp fields: > > > > - Last time a manual vacuum on this table was attempted but skipped due to > > - lock unavailability (not counting VACUUM FULL) > > + The time of the last manual vacuum on this table that was skipped > > + due to lock unavailability (not counting VACUUM FULL) > > I intended to keep consistency with the existing last_vacuum: > > Last time at which this table was manually vacuumed (not counting VACUUM FULL) > > although "at which" was accidentally omitted. Your suggestion seems > simpler and more natural to me. Should we prioritize that over consistency? > > > and the counter fields > > > > - Number of times vacuums on this table have been attempted but skipped > > + Number of times a manual vacuum on this table has been skipped > > The "a munual" was also accidentally omitted, so I'll fix it. > > > 5/ > > Partitioned table asymmetry between vacuum_count and vacuum_skipped_count. > > > > vacuum_count never increments on a the parenttable, because the parent is never > > pocessed. On the other hand, if the manual VACUUM/ANALYZE is on the > > parent table, > > then we will skip all the children. So, we should still report the skip on the > > parent table, but we should add a Notes section in the docs perhaps to > > document this caveat? > > Yeah, we cannot report skips on the children when a manual > vacuum/analyze on the parent table is skipped. (It might be possible > to obtain child information with NoLock, but that would not be safe.) > > Therefore, I agree that the best we can do here is to add a note to the > documentation of last_skipped_vacuum/analyze and skipped_vacuum/analyze_count. > > For example: > > When a manual vacuum or analyze on a parent table in an inheritance > or partitioning hierarchy is skipped, the statistics are recorded > only for the parent table, not for its children. > > > 6/ > > It would be nice to add a test for this, but this requires concurrency and I'm > > not sure it's woth it. > > I'm not sure what meaningful tests we could add for these statistics. > I couldn't find any existing tests for fields like last_vacuum. I've attached a patch reflecting your comments on items 1, 2, and 5. As for items 3, 4, and 6, I am waiting for your comments, so the patch is left unchanged for now. Regards, Yugo Nagata -- Yugo Nagata --Multipart=_Mon__13_Apr_2026_17_05_51_+0900_T4n8olu8FNI1Va/O Content-Type: text/x-diff; name="v4-0001-Track-skipped-vacuum-and-analyze-activity-per-rel.patch" Content-Disposition: attachment; filename="v4-0001-Track-skipped-vacuum-and-analyze-activity-per-rel.patch" Content-Transfer-Encoding: 7bit