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 1wEpmo-004SlK-2r for pgsql-performance@arkaria.postgresql.org; Mon, 20 Apr 2026 14:39:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEpmo-003Luy-05 for pgsql-performance@arkaria.postgresql.org; Mon, 20 Apr 2026 14:39:42 +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.96) (envelope-from ) id 1wEpmn-003Luj-1w for pgsql-performance@lists.postgresql.org; Mon, 20 Apr 2026 14:39:41 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wEpml-00000001w9e-1916 for pgsql-performance@lists.postgresql.org; Mon, 20 Apr 2026 14:39:40 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-671c24f23b1so4700259a12.0 for ; Mon, 20 Apr 2026 07:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776695976; cv=none; d=google.com; s=arc-20240605; b=dbtwERfE6N7rUDAHYFQ+4Iu+/0IL4RtKqXf4Wv0IhVG9DnKi15rQta12tKQXMJS8tL RFCYr4ZzJZhNzgpPThTNz/RWktS2mwujXQHQdLv86fV5DYymPnqhpCaGEx/xjTy4KQ+F +W/aTf/zNcFW0YsTp6mKoqi+QRLK266NvzYdbRV2JbX/6DPbzhj0FPDytVNl3QYhyb8u ZFMOLagdrKGaptPmRE6dIuYdyI0JeluEY+e93IHv082WNQ1aVqifh1gxr/eRs4F2/fS4 7bOa8M+zJwpZpp52qw4w7KujJJYFWxTgiLqoYpWo6CMgW61XECf4vqrqaHxrQz0pAsWz eO3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=/GkzkBPLw3zp3oqOTscMlHhzw/SKwZIfMYSxwzm2VMM=; fh=IP1FxZaAZLLWns5XPk8hQeN7tGvaspbCj1V68xHj2ek=; b=Co9Fo6wsNQ4adDO5WQKs9GdiDPFTHX63+LaoQuDG1Ku9NAuMtwWW75NgHOjSBFD6CN mMW9Qwq2Z+MieC1J36uw3zy8FPnLYjj7IPOS8vzpr/t9bHT65bP5CAi4GYgu1PTLrO6Y Y9YhuzarO18oS8hT/VpUmqCbjemSNOkNhAUIBex807Q8+2CNb+6VhmmYI7QDlEV1YZud egX3G2bGPJTn3LdzP+EbZOlPC4iZeJiikiaMbI64aM3i7QnbdajK+4AHMtWhJHWiz7rD rdr6EZahTvxJYH+saFGyVDSIVzWhc3Ta8Ox6sRLYjvMAJKhDseTY9fz7p774pu+NZx5r bBPQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776695976; x=1777300776; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/GkzkBPLw3zp3oqOTscMlHhzw/SKwZIfMYSxwzm2VMM=; b=Qji0rrCa83DZGpg+8ImgQ6GO4VvQkCZ76kHCBTo4kF218nsmBkNZXESSyZ1MFI4Flc 2t4zvvZaKqKE07vUXiVpIlCOm6Kn9vDnaGzYG/MMhj/NDDtlmEDUkzAZ+/sKkX+Y0/6Q Hg5L1Vf/AJSweWMAhuU/G0Gll9w5kLvHWV9Vi4ix9Zz0tQRIALqrkR5UaY5Ww+lJX4YE Y6TD4s3egIvbKNQXweWMvI7bFfgPRpm9wssBi5OMj2RslZnbJ/NDzbPjo8pYRELO51L/ mC4rt1j3bSe5TklZ5HHg154XSlAjHFpGJS+xnxTPyjMj/VvTuC9bTOEd88Kabn7KeMUu wcFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776695976; x=1777300776; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/GkzkBPLw3zp3oqOTscMlHhzw/SKwZIfMYSxwzm2VMM=; b=n9wf6b7geb+l7UIu0sCdia+2XHGGfg4tOAbcGqxCm1FjmJqdRDKYGEC6lp810J1VBn zhzRkLSEYDjfVlwjAYnGpx4U8wDXZy8uno4gS06F05GxQ+cur9ezQy5V+sRES7ykCOga YaA1Q5TUGd/bvCR+6wJRw5N6+d0y++qYyGNCwRTT0WK2GOeupLExlpVMTLWe+nuGj8PU xlehub9Rv3zI9orxeezHh+4XL+AzYzxwV/zWbdXn0ZiuJi87ybLdbMaNBdK2tqSEEZ+y OCqXB72BlNgYiZk5NroHJ/bE9vKi3pdd/BcWiIbX+S6lOHvyr2HLo/a2C/DVDP/yt8UJ u9Ng== X-Forwarded-Encrypted: i=1; AFNElJ/WqhyMU9jlgpWkZceR2FoRIojARCqaKr7jyamYmKF93GUB36cZdsKC5WxxGcyUrdL/jkTptFatYeWPXkojPBNvsA==@lists.postgresql.org X-Gm-Message-State: AOJu0YyJAbzKBEx7I5OYzNxPebezyXPKArXHLN1UucEaBBiSJrrcH35X O99qRxoVkWsb88i2Li27cHEuxBQJMawDrm+xP7csgvrNjY2QY9CZ9ECpmr3u7PPK5F9/4Mc1YGK Dim9l8GeoN/pU5MVxNzIKjKktIZiYjcI= X-Gm-Gg: AeBDiet0UKTQHUa4q/JX20Za4PLuPTKVCgRG1HZup9qr5pkj/CVfwXIrhTtB6xs0/3c fZ5RRpGRF6ANoHE/Rr50JhUZ8aHDdYWtc3nC9N4avsY7bkCEXAdApzaMdbtJv5JSzaUAGrAJH1Z Uo8DzTztRQuywiK5fBvnijdZmOadRRFYK/MjEJ8BIxAgsk/W3CwsZDuniO0V9pEBXmUVPkLvUnX RLMrwPcR48p9zL7GXTFULUKpFGGS2MvlnxThgObOi53ZIMrBbSomZ1T/4V+6rmnE0su+CIhNnUA z2IGW31DK58R65H/VF6I0ht4NG/llg/uOdzoGuHZTDNXy3Lj3YLd X-Received: by 2002:a17:907:6d29:b0:ba6:2c73:47dd with SMTP id a640c23a62f3a-ba62c734e53mr366829666b.5.1776695976093; Mon, 20 Apr 2026 07:39:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rick Otten Date: Mon, 20 Apr 2026 10:39:24 -0400 X-Gm-Features: AQROBzC3jEB8JsACHvd95MGi_MpZWxlQB_Xw8giU5pqOH_-B_uBPhyhFYoTHy0o Message-ID: Subject: Re: table bloat very fast and free space can not be reused To: Kristjan Mustkivi Cc: James Pang , pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000876beb064fe5449a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000876beb064fe5449a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Apr 19, 2026 at 7:44=E2=80=AFAM Kristjan Mustkivi wrote: > On Sun, Apr 19, 2026 at 4:28=E2=80=AFAM James Pang wrote: > > > > experts: > > source database v14 , pglogical extension 2.4.5 replication to ne= w > 17, source table very frequent UPDATEs /DELETES /INSERTS and has two text > and jsonb. in source database, application update/delete/insert through > SQL, table size did not increased quickly. but in target pg v17 , by > pglogical apply, we found table increased very quickly , table size got > doubled in days. > > Vacuum analyze did not help , only vacuum full can help. pgstattupl= e > show most of space are free space , that much more than source. it looks > like these replicate DML always asking new pages instead of reuse existin= g > freespace. > > Hi, > > We have had the exact same problem in the past - a large json column > getting very frequent updates (hundreds even thousand per minute) on > the source and the replica side table bloating up. No amount of tuning > attempts made any difference (conversion of json to text, different > table specific autovacuum settings etc). Eventually, the table was > taken out of the replication and later on made UNLOGGED which also > freed up a giant swathes of storage from WAL written. Such design was > then called an antipattern and has not been allowed since. > Which design is an antipattern? Using json for volatile data sets or unlogging the table? Does `pg_repack` help? I know it probably isn't practical to run it every couple of days. It also can sometimes causes headaches when repacking a table with a ton of logical replication activity, but it might be a tool to consider if you haven't already. If you can partition the table with the crazy amount of json changes, you don't have to repack all the partitions, you might be able to repack just the older ones with the worst bloat. --000000000000876beb064fe5449a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Apr 19,= 2026 at 7:44=E2=80=AFAM Kristjan Mustkivi <sonicmonkey@gmail.com> wrote:
On Sun, Apr 19, 2026 at 4:28=E2=80=AFAM J= ames Pang <j= amespang886@gmail.com> wrote:
>
> experts:
>=C2=A0 =C2=A0 =C2=A0 source database v14 ,=C2=A0 pglogical extension 2.= 4.5 replication to new 17, source table very frequent UPDATEs /DELETES /INS= ERTS and has two text and jsonb. in source database, application update/del= ete/insert through SQL, table size did not increased quickly. but in target= pg v17 , by pglogical apply, we found table increased very quickly , table= size got doubled in days.
>=C2=A0 =C2=A0 =C2=A0Vacuum analyze did not help , only vacuum full can = help. pgstattuple show most of space are free space , that much more than s= ource.=C2=A0 it looks like these replicate DML always asking new pages inst= ead of reuse existing freespace.

Hi,

We have had the exact same problem in the past - a large json column
getting very frequent updates (hundreds even thousand per minute) on
the source and the replica side table bloating up. No amount of tuning
attempts made any difference (conversion of json to text, different
table specific autovacuum settings etc). Eventually, the table was
taken out of the replication and later on made UNLOGGED which also
freed up a giant swathes of storage from WAL written. Such design was
then called an antipattern and has not been allowed since.
=

=C2=A0Which design is an antipattern?=C2=A0 Using json = for volatile data sets or unlogging the table?

Doe= s `pg_repack` help?=C2=A0 I know it probably isn't practical to run it = every couple of days.=C2=A0 It also can sometimes causes headaches when rep= acking a table with a ton of logical replication activity, but it might be = a tool to consider if you haven't already.=C2=A0 =C2=A0If you can parti= tion the table with the crazy amount of json changes, you don't have to= repack all the partitions, you might be able to repack just the older ones= with the worst bloat.

--000000000000876beb064fe5449a--