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 1v0wfZ-002kx5-Nn for pgsql-admin@arkaria.postgresql.org; Tue, 23 Sep 2025 06:38:33 +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 1v0wfX-00434J-4k for pgsql-admin@arkaria.postgresql.org; Tue, 23 Sep 2025 06:38:31 +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 1v0wfW-00434A-Oi for pgsql-admin@lists.postgresql.org; Tue, 23 Sep 2025 06:38:30 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v0wfS-002KPl-1R for pgsql-admin@postgresql.org; Tue, 23 Sep 2025 06:38:30 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-afcb7322da8so947144466b.0 for ; Mon, 22 Sep 2025 23:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1758609505; x=1759214305; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=rWIXAb83H52agNh+F2Ln4uNg4pPPcjc8T2+eVrYPBaM=; b=NxdmQh9dwVhCL2b02XPgn8ZK2XNriGdPn9Wxc1DTuBPeBb/MJ0CZEajC9WbzCRADy4 qVXYwodo4NPTCGqjIpq5yx0Iyqbw68aq0v3fx4S/eqlLiaUT2JQAVA5VjGYopDcONSsr U4CPJyT3IIL5CNZxSxSlSGTIxRO5wbTfPH7m6vwLrmY17MoFRiXL2fZMHhHtFIR9lbAd 71tJGvegAoD+8gfDmrZmCMevdhyCgC0W+N5LKFy4rtXErojWWH/bKGpVRLvutWVvrr2v OJtRVo0hhgq/BTvcIZXUZC4AZnFkMkDfO0lPWSt/S4ZHfVaq2u1uFLPC8q7PU0UXD1rc G6dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758609505; x=1759214305; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rWIXAb83H52agNh+F2Ln4uNg4pPPcjc8T2+eVrYPBaM=; b=c1dGoyP+A1BV09R2fezBK5ewi/Vr2bobrCQYEm7NBGk0y6vqhg4i5Z29obmUJ0OnC7 nAo6G0QOJwONjAgfNcChMFQtUNXziK8tx8c24VNbSR2dpY/43/eQQnnadmBEXag1jcwA Ei3CkJvq53mRMvDz/BFQDpeqN0U5CeRyB/Rgxak/AF7xWoKcAmois4JrztllRP8Cz1zT rE+zMih3e5yIEfwlCSNSkPeCCGoOs0U9YqGL/cqAee3KcY7nJ7lFq+LxAgHeH/p5taYe QollR1aI81Ti/YvwwNCjn2qBlR6RPHsky4RfsTMfFOHg8ppnsFkrY6Gs7MgPQ6I2NwgA RbBQ== X-Forwarded-Encrypted: i=1; AJvYcCVrp/1f/iQS2kQV7VRrqswN60LC+2WRn2OCuNYEkYCQmkE3atfFwNZbXu9mcErfEKZAq+3oe6pMsZM5pg==@postgresql.org X-Gm-Message-State: AOJu0YyB0iQw095dvqGDFS7Ao8nTbCKbp8NMGfiPkIYTmapmeOfRYKwx ARPg2Fa7w3Ebh87gb3kkb/pRLGRp3t/y0wS06Btrh6vWiChGlYsHogEFvw+eH8ZzY4T30ZDky2f 8lH76VpY= X-Gm-Gg: ASbGncuWNJ1e0MUk4dlbGR1eP5UwO13+IY71FPnBWn9CSaU5aIhN4q7q7RzKHjgDO8K bndvpCfRp6vrt2VzXY2scepWxk1kM/E2puRG23Vbop08nnkgnNSIfB76D++q3mjssDPB79GIaeF sILKJ3PhQp0+ATfb8Bqe7UI8yc3l3Uw1EucJjzhBk0iek0dU/aKpXLuw0Dsqa3+7/1TwWVf9kRb 7hY7IouPQ+gYR2B7rwB+1dlPI4UnLKL2ZatpnHn8+wOTiIa3kvVCABkK7pv5S3nWte43HkzioMa mly0Y3joD1myuTmYFyCh3j8QvXXI9rg2CnnuvCMf+WDacfxysIJm5L2bT+92NSqutNXzc148PN8 L83xXLmvfSmuNxQjxWPOiX8H5JJqaLtDS43Vs51y0/MSwApQouw== X-Google-Smtp-Source: AGHT+IHEgTqQz0Q5ezHyjogEglvfDwQ/62D0iELlNTp8OKFYTxsU/NW/hW92Gdw3lo7+CzIhgv+jsw== X-Received: by 2002:a17:907:1c1c:b0:b07:da17:79fd with SMTP id a640c23a62f3a-b3027b539f6mr140455266b.17.1758609505145; Mon, 22 Sep 2025 23:38:25 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([41.66.99.143]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b2a88413acbsm554325566b.24.2025.09.22.23.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 23:38:24 -0700 (PDT) Message-ID: <38219e14d655f5b7955446cb0f4c7dfc73b76bfa.camel@cybertec.at> Subject: Re: Vacuum Question From: Laurenz Albe To: Murthy Nunna , pgsql-admin Date: Tue, 23 Sep 2025 08:38:23 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2025-09-22 at 15:06 +0000, Murthy Nunna wrote: > Version 14.13 > =C2=A0 > I have a large database 22 TB, and it has lot of tables. Most of the tabl= es do not change (static). > But the age(relfrozenxid) of those tables keep increasing because there a= re some other tables in > the database that are updated. The size of these large static tables are = about 200 GB on an > average. And to prevent transaction ID wrap around, I have been doing man= ual vacuum table by table > (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 > =C2=A0 > I tried VACUUM FREEZE also, but the WAL generated and time it takes is no= significantly different. > =C2=A0 > Following is an example output of a table vacuum: > =C2=A0 > vacuumdb: vacuuming database "large_db" > INFO:=C2=A0 aggressively vacuuming "public.tab_111" > INFO:=C2=A0 launched 1 parallel vacuum worker for index cleanup (planned:= 1) > INFO:=C2=A0 table "tab_111": found 0 removable, 527846215 nonremovable ro= w versions in 15396753 out of 15396753 pages > DETAIL:=C2=A0 0 dead row versions cannot be removed yet, oldest xmin: 954= 951860 > Skipped 0 pages due to buffer pins, 0 frozen pages. > CPU: user: 131.12 s, system: 174.14 s, elapsed: 4111.88 s. > INFO:=C2=A0 aggressively vacuuming "pg_toast.pg_toast_17386" > INFO:=C2=A0 table "pg_toast_17386": found 0 removable, 32180684 nonremova= ble row versions in 7981550 out of 7981550 pages > DETAIL:=C2=A0 0 dead row versions cannot be removed yet, oldest xmin: 955= 034530 > Skipped 0 pages due to buffer pins, 0 frozen pages. > CPU: user: 52.96 s, system: 87.86 s, elapsed: 2104.04 s. > =C2=A0 > Is there a way I can minimize WAL generation? If the data won't change any more, run a VACUUM (FREEZE) on the table. Tha= t should freeze all rows, and any subsequent VACUUM will finish very quickly and produce no WAL= . > About a year ago, I did pgdump/restore. But I did not perform vacuum thou= gh. So, may be I > should complete my table by table vacuum at least once then. If you restore a table from a dump, all the rows will be unfrozen. It will take another VACUUM (FREEZE) to freeze the rows. Yours, Laurenz Albe