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.94.2) (envelope-from ) id 1tIVpI-00Enjf-8a for pgsql-general@arkaria.postgresql.org; Tue, 03 Dec 2024 16:32:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tIVpF-00B9Ix-4X for pgsql-general@arkaria.postgresql.org; Tue, 03 Dec 2024 16:32:38 +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.94.2) (envelope-from ) id 1tIVpE-00B9Ij-CY for pgsql-general@lists.postgresql.org; Tue, 03 Dec 2024 16:32:37 +0000 Received: from mx0b-004aa801.pphosted.com ([148.163.140.28]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIVp6-000qse-Bq for pgsql-general@lists.postgresql.org; Tue, 03 Dec 2024 16:32:35 +0000 Received: from pps.filterd (m0204361.ppops.net [127.0.0.1]) by mx0b-004aa801.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B3AmiUZ002447 for ; Tue, 3 Dec 2024 10:32:27 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snapon.com; h= content-type:date:from:message-id:mime-version:subject:to; s= s2048a; bh=44pn4uolCI3gVUlklPkrpTPxp2TZKP5jtuHSkm5HC3w=; b=UwNCg zIHphqYhcPAs1MqcrH2lTaFmmP4yAws5TPY91IrTr88ZXU8mcxQohl29fLMTpW1u anE7EKKsUo9Sz7FxtQiaquNcBloDRIuv6RrachxC6mFk2k1i9fEGP1sFvgC2iJhR te9J1D+F51C/XeqNaIjUaP/5lpLuxdt9+laVUT1koN/vmavC+8GJrE0uDtvt6tnk AHBwgzcGjHPUpgtWs3FjHFo1E6nl3362pD5fmjOeI29RqjPZgY5o495NWASOTdps QmZHnICc6A4VfTY+1MlQvItHwDrGTzxislkBUyD2kKJwqzuPEFotf/5hRVqN9R8Q SyFQF040gJroCE+1Q== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by mx0b-004aa801.pphosted.com (PPS) with ESMTPS id 437yd02a49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Dec 2024 10:32:26 -0600 (CST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k3U2gJkkOpBqLAWOGPRhcXqg1HmC3p+1K/dbIzDGCf9Cw4MEHvAszYHiStDFcdQu5VQbeFnzpfQ/Gv3UCniMw2koRv1WB4L74/KdAMKRDVZcc92l9v3WpT10DWIiSbfN4Wk8dZa2EY3CaPinVukbOl4ML+rlWEijixZy0qj2Q4VbSWun6xOAlyIARghszYjtiAdGiIwSDK+mRNbQFsTdJmWNm2OP/I8no3yWwn5DVQ8pOczxgXL8Iv5EThNmli/dMceBXWF9t80Zpt7nwpXbVvkWfuoBL0sZXVMt2W1+0VbjjN+gcqTg8K8ymGVM+PsYPFfX6tLJ21dHtmFZeN3sMQ== 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=44pn4uolCI3gVUlklPkrpTPxp2TZKP5jtuHSkm5HC3w=; b=AglQcn82zr9NtnYfrcVSSm0U2cuf8XdYG94lrNa273QDAogu50BEu7ErkBlGNfiF3qZ10RyWxVMqDEKm39ORXH5VxZvF3u6RyPkD57Bmprz2YCUjo5hkxKKhbMXmcGJ5yPnAJQMigtIk77g1teEptBW5p9sHCoTofofRHuGKmh88mEjk7NjPDJPPh5Zuv/zGAQ+kZTqDfaR2ralEN0lsKd/JGt9Nt/kYLZ9UapRQx8YnblOWc5tvaFNgMJrCqazIICh/JC8JA7bFhhrgGXD2lksJTgfN8KYV2GdJ+CzR6EF/3h8v56mled3XAiTvqcYOn9q6EDTfeOTIrrs37cca+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=snapon.com; dmarc=pass action=none header.from=snapon.com; dkim=pass header.d=snapon.com; arc=none Received: from BN8PR04MB6289.namprd04.prod.outlook.com (2603:10b6:408:d9::7) by BN0PR04MB8062.namprd04.prod.outlook.com (2603:10b6:408:15d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Tue, 3 Dec 2024 16:32:22 +0000 Received: from BN8PR04MB6289.namprd04.prod.outlook.com ([fe80::63ff:16cf:cb10:259f]) by BN8PR04MB6289.namprd04.prod.outlook.com ([fe80::63ff:16cf:cb10:259f%4]) with mapi id 15.20.8207.014; Tue, 3 Dec 2024 16:32:22 +0000 From: "Tefft, Michael J" To: "pgsql-general@lists.postgresql.org" Subject: Autovacuum and visibility maps Thread-Topic: Autovacuum and visibility maps Thread-Index: AdtFnZrPZttyZEAwRIqDe+1fxv6vqQ== Date: Tue, 3 Dec 2024 16:32:22 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-dg-ref: PG1ldGE+PGF0IGFpPSIwIiBubT0iYm9keS5odG1sIiBwPSJjOlx1c2Vyc1xuajM0MTdcYXBwZGF0YVxyb2FtaW5nXDA5ZDg0OWI2LTMyZDMtNGE0MC04NWVlLTZiODRiYTI5ZTM1Ylxtc2dzXG1zZy0yYTdmYzdlZC1iMTk0LTExZWYtOWQ1Zi03NDNhZjQ2Yjg3OGVcYW1lLXRlc3RcMmE3ZmM3ZWUtYjE5NC0xMWVmLTlkNWYtNzQzYWY0NmI4NzhlYm9keS5odG1sIiBzej0iNzQxMCIgdD0iMTMzNzc3MTcxNDA4NzgzNDk2IiBoPSJGRDdhOXZnTVZJY3Rvc0FScitWOFFxa2RKNUU9IiBpZD0iIiBibD0iMCIgYm89IjEiLz48L21ldGE+ x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN8PR04MB6289:EE_|BN0PR04MB8062:EE_ x-ms-office365-filtering-correlation-id: 33c4a609-81e8-4858-dda0-08dd13b81016 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|376014|8096899003|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?wkkyhBQ7FlrxSqcLxWaVOGqNXz+0MZw+hssTHRUyXq9X5yT3+kKTXhwMtCMs?= =?us-ascii?Q?396X+1jF6Nvfrdea5nEdAE2eEyeQWnup7ws79eDAJyouMZSwK95VEFUS+jw8?= =?us-ascii?Q?efiHCbnRbjlhx6pp62dHTqASGLe1G/paDht2ze0/ygbrbhLBzOvGyd/oF4/x?= =?us-ascii?Q?YAmw4oW7T1CMUj0wiuU3NUcVd09GspF/kT8trQNCRJs6h5zsLdKDYrIT9c7c?= =?us-ascii?Q?pAjuf8YxBTq0f5007yU1+P5X63FKfvf6Z1J5DHr5TbkaF0kilT96/Zo1EUlS?= =?us-ascii?Q?yDALUeMCdYwJE+FOkW9BKw88K8j4nUXgnaTs0c5sjgNlBtkoMMMYR+YUqbdT?= =?us-ascii?Q?nh4LJaHHdKQRxo+hTUtNswXVbmHHGapoIIZB/q400goQr6Nb5Pl3wDo5sg/P?= =?us-ascii?Q?0iFQwRJkdORTN7OHmxvAxtHJkTODEbVXszgGxyQSxjAGTK9TnK8WjDOnBEbM?= =?us-ascii?Q?H6c5FLj9kvtOsuSN9w1s4ubeb+qTPuY7XgxqOeOcDYJ+/MEJ7wTiwMH/SQkR?= =?us-ascii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E+emnqSOrgPg=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR04MB6289.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(8096899003)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?93qKGzNwZwF7y8+T1D3Pm8z1cE8+HWWpJqQpwLy7OBcGsBGFA+sRWAgiPWrU?= =?us-ascii?Q?rV4gWDY/buDZx42Zh6/RvVVMePhrpRWV2IlSIe2sjtXzxXD0yApwfBJzqei5?= =?us-ascii?Q?tC7mHKvhJ3R1V3Z6qN3PqQVRL3dHqGwvOWE22bFIUxp2VYAZjItjfIEtWDVt?= =?us-ascii?Q?fWHFFY2uOQzshXmmaJb+j8rdrNnYKTjM4AYpfngOtSZMmOR1FaP3jPj3Wjwr?= =?us-ascii?Q?6hj0jJwxbpmd95hhfmJ2KOjMJMchcWorZAreVi72d8XNYfaJk3FkntfpbUfK?= =?us-ascii?Q?PPtNs0kdoCFgqnPYqqIxInL7e2ROvH2pUXacGUW/EtIEqmDxaFaso3mR7Ook?= =?us-ascii?Q?yV/JsjGJ0VEMsRdKqe9vAnugxv4uEGPnXGAoMfkj68otpnfQa/rKBdMFpwBq?= =?us-ascii?Q?lO7JHIs8xns59z4hY18lpB5gBnF29hE9LR647WW9bcNRxHoOpKPhAh9hHpvs?= =?us-ascii?Q?clTVKRUReYLNcKrqve/oBaqp94L//25GjQKvbZIYY1sfn5/CjQVOAVV2v+Up?= =?us-ascii?Q?87SUZnLTNWod/tgDSrk5UgaEkx/IZ24L9/cT0wPjQcuqQclVQ2TaKMJBjlLD?= =?us-ascii?Q?Rva3u/fSmXGi6xpAMh0VyQ8f05zWdt5Rkjyzd3nuEzZoPcO2N0p/QUxIwWw4?= =?us-ascii?Q?I/C6d2jbDvxRgTfnSn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q?SpE+dVJN+lkJYfhjZccFpIqFtasab7qS7peZgGDH?= Content-Type: multipart/alternative; boundary="_000_BN8PR04MB6289F7099F7B38E5B08D85B7D0362BN8PR04MB6289namp_" MIME-Version: 1.0 X-OriginatorOrg: snapon.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR04MB6289.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33c4a609-81e8-4858-dda0-08dd13b81016 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2024 16:32:22.0970 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9cbb18c7-7b64-4d6a-953b-09ec023c8c08 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 48JYj6o2AHWE2BeKRPi1bgbKQb/tssusdBSQhmvp9i0/7jht9+y00Ai3/JxHL/DY6A8yTGPsT8oNQCBjZQS5wYMgkI0Q4BbqeL6xC6ZhPv0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR04MB8062 X-Proofpoint-GUID: AoeL4Vexwr_hHq5HwEksQNPgNMiD2Vvf X-Proofpoint-ORIG-GUID: AoeL4Vexwr_hHq5HwEksQNPgNMiD2Vvf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 impostorscore=0 clxscore=1031 mlxlogscore=999 spamscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412030139 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_BN8PR04MB6289F7099F7B38E5B08D85B7D0362BN8PR04MB6289namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable We have some batch queries that had occasionally having degraded runtimes: = from 2 hours degrading to 16 hours, etc. Comparing plans from good and bad runs, we saw that the good plans used ind= ex-only scans on table "x", while the bad plans used index scans. Using the pg_visibility utility, we found that all of the 83 partitions of = table "x" were showing zero blocks where all tuples were visible. We ran a = VACUUM on the table; the visibility maps are now clean and the good plans c= ame back. Our question is: why did autovacuum not spare us from this? We are using default autovacuum parameters for all except log_autovacuum_mi= n_duration=3D5000. These partitions are populated by processes that do a tr= uncate + a single insert-select. We see autovacuum failure (failed to get lock) messages, followed by a succ= ess message, in the log for one of these partitions (the biggest one) but e= ven that partition showed zero blocks with all tuples visible. Are we wrong to expect autovacuum to clean up the visibility map? postgres=3D# select version(); version ---------------------------------------------------------------------------= ------------------------------- PostgreSQL 14.13 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 202105= 14 (Red Hat 8.5.0-22), 64-bit Thank you, Mike Tefft --_000_BN8PR04MB6289F7099F7B38E5B08D85B7D0362BN8PR04MB6289namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

We have some batch queries that had occasionally hav= ing degraded runtimes: from 2 hours degrading to 16 hours, etc.<= /p>

 

Comparing plans from good and bad runs, we saw that = the good plans used index-only scans on table “x”, while the ba= d plans used index scans.

 

Using the pg_visibility utility, we found that all o= f the 83 partitions of table “x” were showing zero blocks where= all tuples were visible. We ran a VACUUM on the table; the visibility maps= are now clean and the good plans came back.

 

Our question is: why did autovacuum not spare us fro= m this?

 

We are using default autovacuum parameters for all e= xcept log_autovacuum_min_duration=3D5000. These partitions are populated by= processes that do a truncate + a single insert-select.

 

We see autovacuum failure (failed to get lock) messa= ges, followed by a success message, in the log for one of these partitions = (the biggest one) but even that partition showed zero blocks with all tuple= s visible.

 

Are we wrong to expect autovacuum to clean up the vi= sibility map?

 

postgres=3D# select version();

        &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;  version

----------------------------------------------------= ------------------------------------------------------

PostgreSQL 14.13 on x86_64-pc-linux-gnu, compiled by= gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit

 

Thank you,

Mike Tefft

--_000_BN8PR04MB6289F7099F7B38E5B08D85B7D0362BN8PR04MB6289namp_--