From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Vacuum and freeing dead rows
Date: Fri, 5 Jul 2019 08:52:35 -0500
Message-ID: <a3736853-13f3-ebaa-0c8f-aa6d03520826@gmail.com> (raw)
In-Reply-To: <CAKYm0co_f4T5aQd9exmUuBxqdde2Le3F1cW40UnKtOW8SR4qfw@mail.gmail.com>
References: <CAKYm0co_f4T5aQd9exmUuBxqdde2Le3F1cW40UnKtOW8SR4qfw@mail.gmail.com>
On 7/5/19 3:16 AM, Simon T wrote:
> Hi,
>
> I have a very heavily updated table in a Postgres 9.6.10 database with
> lots of disk bloat. Every row is updated about once a minute, and
> little to no inserts. Approx 18k rows total. The table has bloated
> from ~1700 KB to about 6 GB over a few weeks time. I'm trying to
> understand why vacuum hasn't made dead rows available for re-use.
>
[snip]
> And in case it is relevant:
>
> appdb=# SELECT pid, datname, usename, state, backend_xmin
> appdb-# FROM pg_stat_activity
> appdb-# WHERE backend_xmin IS NOT NULL
> appdb-# ORDER BY age(backend_xmin) DESC;
> pid | datname | usename | state | backend_xmin
> -------+---------------+----------+---------------------+--------------
> 10921 | appdb | app | idle*in transaction* | 3501305052
"idle IN TRANSACTION" is never good. Transactions should always be as short
as possible.
> 10919 | appdb | app | idle in transaction | 3501305052
> 10916 | appdb | app | idle in transaction | 3501305052
> 27935 | appdb | app | idle in transaction | 3501305052
> 24500 | appdb | postgres | active | 3501305052
> 10914 | appdb | app | active | 3501305052
> 20671 | appdb | postgres | active | 3501305052
> 11817 | appdb | app | active | 3501305052
> 1988 | appdb | app | active | 3501305052
> 15041 | appdb | postgres | active | 3501305052
> 9916 | appdb | postgres | active | 3501305052
> 10912 | appdb | app | idle in transaction | 3501305052
> 10909 | appdb | app | idle in transaction | 3501305052
> (13 rows)
Add backend_start to that query. I'd kill any idle transactions are more
than 30 minutes old. (Of course, since they're "idle IN TRANSACTION", you'd
lose stuff.
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Vacuum and freeing dead rows
In-Reply-To: <a3736853-13f3-ebaa-0c8f-aa6d03520826@gmail.com>
References: <CAKYm0co_f4T5aQd9exmUuBxqdde2Le3F1cW40UnKtOW8SR4qfw@mail.gmail.com> <a3736853-13f3-ebaa-0c8f-aa6d03520826@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox