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 1v0i7i-00HGlr-JK for pgsql-admin@arkaria.postgresql.org; Mon, 22 Sep 2025 15:06:39 +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 1v0i7g-000zI6-Oc for pgsql-admin@arkaria.postgresql.org; Mon, 22 Sep 2025 15:06:36 +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.94.2) (envelope-from ) id 1v0i7g-000zHy-1j for pgsql-admin@lists.postgresql.org; Mon, 22 Sep 2025 15:06:36 +0000 Received: from mail-westusazon11011039.outbound.protection.outlook.com ([52.101.86.39] helo=BY5PR09CU001.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v0i7a-002DFX-1p for pgsql-admin@postgresql.org; Mon, 22 Sep 2025 15:06:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ThKYaXH0niuvJroNFiNTe4BnN4zTB1zxlqQMBfZs2NspvdypHsdG59OVvGBWTpIZGep9uQ388i/W+EPkyhIWgJuhIgIv2k8OXW0a7EcYVDXnl0CaEhiPxga+y2ngFY6kz69fKbqX5aoVcXWFMJchBEpwCgn9Ku/Qjot8qes2Y4tfo0dti5/vbnLDZWaMQbCeY2DtdrO8u4j5bOnD6QYTnbKMeQNbTBvHxixWz5Lun9kB9FA73xiP4DfckOu+qPUwEl2rlQbTHIFq5I0Wz4Mfc54xHnCrAy7gZthZo2BCW9CYBwFE/XQKI0zBwJCIWZiGBP2OStVpHhmS+lGo16ni/g== 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=alxz2EjVu6zOEIqiiIdFGrtUE/gBdGKzxWkzaYYVMnY=; b=Y/c3F3qi3FAX1CkK27qdU/kKEHtWGjVpb4kOgadvgTIVyPOVFlWAOzj2bzAGe3R8fD20uvMu0R5ALAKSy7kF5ePmiJ0dD6/R4NIbTdV90gA1Ad1X1vtsSQZhrjHixJBLr0C8EQBFh86VUejtfDp0+78o7Id/48ZHG+Lmn/uK+AfVWXvaRO8Za2tswaE9ttm6gT9Hb4C9j2Ezdq3hiuTjcQ9UU6s9PjN0QDA2CcTKiHRLLcULrar2zKPSrg+Z/jlk7slwxff5wzrXq3veizDP02WnI59apQ4kAhcui5fUKzA79DHgMpGWxIKRScGzuvwsOE+J+zW8IsOcjQC4wJgCYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fnal.gov; dmarc=pass action=none header.from=fnal.gov; dkim=pass header.d=fnal.gov; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fnal.gov; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=alxz2EjVu6zOEIqiiIdFGrtUE/gBdGKzxWkzaYYVMnY=; b=eebg4LA9glqM8V9elDuLS5NhxXiGsWU9FjeBhxgzVZgKyr8jDbwYCp+D5m3dzrjFti7p3aHku7q6JIoHldXbwLsYusvJvOmkLOFZ2rgDaruUIETIP6urYmWzv9GxvvNKMmgYFRJ3DN7FFnrdKcyDzG+3USLXyY+jcJQXu8c+dzwOgElZyIZlYxWt46YMjJj52GBERdhIvSUUIRJUcfHLLzc30k769YTPJsk1EgNJNV2u7AzJVs9SukP0OhVEdsQn5RPMeez6DdKXQa6cNx+UxLQFG8TGNs2CcZ05rli9UdczW5MXClKq49GJSNSJaj5rJ+AdkzCcipVBez+iZnE26g== Received: from SJ0PR09MB6688.namprd09.prod.outlook.com (2603:10b6:a03:26f::8) by BY5PR09MB5923.namprd09.prod.outlook.com (2603:10b6:a03:244::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9137.20; Mon, 22 Sep 2025 15:06:26 +0000 Received: from SJ0PR09MB6688.namprd09.prod.outlook.com ([fe80::3045:e0d1:57d8:ea0b]) by SJ0PR09MB6688.namprd09.prod.outlook.com ([fe80::3045:e0d1:57d8:ea0b%7]) with mapi id 15.20.9137.018; Mon, 22 Sep 2025 15:06:26 +0000 From: Murthy Nunna To: pgsql-admin Subject: Vacuum Question Thread-Topic: Vacuum Question Thread-Index: Adwrx/R+fs9cwUnnQDGAg7NUd37y4w== Date: Mon, 22 Sep 2025 15:06:26 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=fnal.gov; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR09MB6688:EE_|BY5PR09MB5923:EE_ x-ms-office365-filtering-correlation-id: 65db60cf-8232-4825-216c-08ddf9e99a59 x-fermilab-ob: 1 x-fermilab-sender-location: inside x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|38070700021|8096899003; x-microsoft-antispam-message-info: =?us-ascii?Q?yqGYdeVJUkhUjH6K4P+T6xf7fW5vzCka8mtiqL7H3ZrvCjP86RI1zJkEF8E8?= =?us-ascii?Q?i2Y1P2ro+f29FktSFod1+1qnTmTEYWj8U9fy5MC4IvSJXn7rKIo7dLUfGSNX?= =?us-ascii?Q?01ak2OltWMOFj8fR2ppxTfxyKEsh0k0Sk0pp3TI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yYm9xbTZ9wWHxUheJ08Unch32126tgLkoSODA/+MHExHmjwz+c0LKRFWK8?= =?us-ascii?Q?nI/sWSXZv8I9PIWdXzlaVGtGbOlxJ0SgvuCEeqLsH/CgDNVFWdwU9lLhoakF?= =?us-ascii?Q?NeXACHMbR60R7bumCw/i25iYq+hV+MFaf3dv1Bn9ukt3FDmbbLx1yk5Y+jpH?= =?us-ascii?Q?GdnNhEvEsSAJvKuPXR7DOOg7W/eIsS0rTtZMPxuIemTj4qbvptV6X2u63s4+?= =?us-ascii?Q?fzG85Bppaqb5XT8XKAPrH26b7wihkZ+/DcHiHSbwCiwVxsLKvnGzAsoGG3SA?= =?us-ascii?Q?w1d9GJnTXLPmao8N7WfbvLvLH3kDvqoTBF5/8vUGzDI+Fu3yHcw9aLnjkUyr?= =?us-ascii?Q?ZuBLZgKO+6hz0bslDbGv1rNdfpuiM0Vgx26/s4VlNNBaquU6c6u1NYHYZG+q?= =?us-ascii?Q?fh9aVuLrvzFzXkk8vvGsEfNyIqatct8IEAGEVVbp3022w4cJtBDD2w=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR09MB6688.namprd09.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(38070700021)(8096899003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?37excxjvVnIdIv7GOt8jwOynFv2UxnjaGMUSzlTZ7ydO+56Kbe7lkrwFGu7x?= =?us-ascii?Q?k30NPWxt1lBxekpuqdf58D+DP4jCfQvr51Ay+EZD7vDUtdnaWLFfwQokXbUk?= =?us-ascii?Q?owUkNRBZSRDn4PuxHIoDaCwf3hHseg2ozeR0i0FOzsV8ukGQiU4yRKONJLsL?= =?us-ascii?Q?VYQ1J9wbeqd2BTGTA97BWWztm8EdPIebV1/Sfcd1SFPp3E0igaES7WZi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xB0nfx4F6BjxRb5n+W3BFo+1E4dcAH0PFuP+a1xZyPPS0R?= =?us-ascii?Q?thnDiZmd0h0RjvGL7dNFag3YUMQXA1Dr1futu7bM068Emo04ZF191WndApNx?= =?us-ascii?Q?fH5xdBJz1hry+9hq7b01kBbQfXp1t25C8qWnk1gSlNojhzA1yDPuIGBP+YVj?= =?us-ascii?Q?RhNbcIXshLiRF0BN7dYjHO80ZlpQHjoMN/hsvfQN+uraC6N5ofOpNZwPLMnI?= =?us-ascii?Q?XiS5GxDK980Vs8fct3NwSju2wOykoW1fM2Fq/2JmUcOSv5Zwge32ayNb+6pP?= =?us-ascii?Q?aH4WZZSv24FHMmay1lvBwka+in4fQH8FXdnv0JA9B9PR6J58q+qp+L5VynaY?= =?us-ascii?Q?aJFNwN843t88faRR1RWMbpT63ech/q7hI1l9tNGbwrrH3uvIeCktfebc6Cj8?= =?us-ascii?Q?0QK3qxq6jwtuZXkOnOR/XrK2snNoVTI9LbPazfGNJWVImj/zcewZIVHn2woU?= =?us-ascii?Q?skMMgvPYE0LD9HNg7Tw8e+mFB691bQf2ikU7VjDP?= Content-Type: multipart/alternative; boundary="_000_SJ0PR09MB6688E7136F78DDD70C8D1028B812ASJ0PR09MB6688namp_" MIME-Version: 1.0 X-OriginatorOrg: fnal.gov X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR09MB6688.namprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65db60cf-8232-4825-216c-08ddf9e99a59 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2025 15:06:26.8366 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9d5f83d3-d338-4fd3-b1c9-b7d94d70255a X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR09MB5923 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_SJ0PR09MB6688E7136F78DDD70C8D1028B812ASJ0PR09MB6688namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Version 14.13 I have a large database 22 TB, and it has lot of tables. Most of the tables= do not change (static). But the age(relfrozenxid) of those tables keep inc= reasing because there are some other tables in the database that are update= d. The size of these large static tables are about 200 GB on an average. An= d to prevent transaction ID wrap around, I have been doing manual vacuum ta= ble by table (couple of tables a day due to limited WAL disk space). Each t= able generates WAL size of 90% of the tablesize approx. e.g Tablesize =3D 200 GB. Time takes to run vacuum =3D 1 hour 45 minutes. WAL g= enerated 182 GB I tried VACUUM FREEZE also, but the WAL generated and time it takes is no s= ignificantly different. Following is an example output of a table vacuum: vacuumdb: vacuuming database "large_db" INFO: aggressively vacuuming "public.tab_111" INFO: launched 1 parallel vacuum worker for index cleanup (planned: 1) INFO: table "tab_111": found 0 removable, 527846215 nonremovable row versi= ons in 15396753 out of 15396753 pages DETAIL: 0 dead row versions cannot be removed yet, oldest xmin: 954951860 Skipped 0 pages due to buffer pins, 0 frozen pages. CPU: user: 131.12 s, system: 174.14 s, elapsed: 4111.88 s. INFO: aggressively vacuuming "pg_toast.pg_toast_17386" INFO: table "pg_toast_17386": found 0 removable, 32180684 nonremovable row= versions in 7981550 out of 7981550 pages DETAIL: 0 dead row versions cannot be removed yet, oldest xmin: 955034530 Skipped 0 pages due to buffer pins, 0 frozen pages. CPU: user: 52.96 s, system: 87.86 s, elapsed: 2104.04 s. Is there a way I can minimize WAL generation? My issue is amount of WAL rat= her than time it takes to run. Since it is not locking the table I do not m= ind long run time. I know one way is to pgdump/restore but it takes a long time and further to= that I have to rebuild replicas. Please note, I have autovacuum turned on and it is doing what it is suppose= d to do on tables that change. So, there is no issue there. I very much appreciate any help/advice you can provide. --_000_SJ0PR09MB6688E7136F78DDD70C8D1028B812ASJ0PR09MB6688namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Version 14.13

 

I have a large database 22 TB, and it has lot of tab= les. Most of the tables do not change (static). But the age(relfrozenxid) o= f those tables keep increasing because there are some other tables in the d= atabase that are updated. The size of these large static tables are about 200 GB on an average. And to preven= t transaction ID wrap around, I have been doing manual vacuum table by tabl= e (couple of tables a day due to limited WAL disk space). Each table genera= tes WAL size of 90% of the tablesize approx.

e.g

Tablesize =3D 200 GB. Time takes to run vacuum =3D 1= hour 45 minutes. WAL generated 182 GB

 

I tried VACUUM FREEZE also, but the WAL generated an= d time it takes is no significantly different.

 

Following is an example output of a table vacuum:

 

vacuumdb: vacuuming database "large_db"

INFO:  aggressively vacuuming "public.tab_= 111"

INFO:  launched 1 parallel vacuum worker for in= dex cleanup (planned: 1)

INFO:  table "tab_111": found 0 remov= able, 527846215 nonremovable row versions in 15396753 out of 15396753 pages=

DETAIL:  0 dead row versions cannot be removed = yet, oldest xmin: 954951860

Skipped 0 pages due to buffer pins, 0 frozen pages.<= o:p>

CPU: user: 131.12 s, system: 174.14 s, elapsed: 4111= .88 s.

INFO:  aggressively vacuuming "pg_toast.pg= _toast_17386"

INFO:  table "pg_toast_17386": found = 0 removable, 32180684 nonremovable row versions in 7981550 out of 7981550 p= ages

DETAIL:  0 dead row versions cannot be removed = yet, oldest xmin: 955034530

Skipped 0 pages due to buffer pins, 0 frozen pages.<= o:p>

CPU: user: 52.96 s, system: 87.86 s, elapsed: 2104.0= 4 s.

 

Is there a way I can minimize WAL generation? My iss= ue is amount of WAL rather than time it takes to run. Since it is not locki= ng the table I do not mind long run time.

I know one way is to pgdump/restore but it takes a l= ong time and further to that I have to rebuild replicas.

 

Please note, I have autovacuum turned on and it is d= oing what it is supposed to do on tables that change. So, there is no issue= there.

 

I very much appreciate any help/advice you can provi= de.

--_000_SJ0PR09MB6688E7136F78DDD70C8D1028B812ASJ0PR09MB6688namp_--