pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rihad <rihad@mail.ru>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general General <pgsql-general@postgresql.org>
Subject: Re: When do vacuumed pages/tuples become available for reuse?
Date: Thu, 11 Apr 2019 20:18:32 +0400
Message-ID: <44a10837-648b-7cc9-d42a-146bc0c83574@mail.ru> (raw)
In-Reply-To: <CAMkU=1z+-o0F5PSsjhN8P98+YrYgg7odTZ+WZvocBObY-LnZLA@mail.gmail.com>
References: <9cd73fcb-511d-ede9-6789-209b7d4eb193@mail.ru>
	<8560.1554990486@sss.pgh.pa.us>
	<0522481c-4cf6-1928-8780-9bfa2d7c6aca@mail.ru>
	<9914.1554992415@sss.pgh.pa.us>
	<17dafb0f-5ab9-390e-96b0-2280d654f790@mail.ru>
	<CAMkU=1wZ1jSDKOqR+KVoDXUT7yprWqMZD-Rv-x__q3i-URkHQw@mail.gmail.com>
	<c7d435c1-a6f6-d570-1698-b8791161d406@mail.ru>
	<CAMkU=1z+-o0F5PSsjhN8P98+YrYgg7odTZ+WZvocBObY-LnZLA@mail.gmail.com>

On 04/11/2019 08:09 PM, Jeff Janes wrote:
> On Thu, Apr 11, 2019 at 11:44 AM rihad <rihad@mail.ru 
> <mailto:rihad@mail.ru>> wrote:
>
>     On 04/11/2019 07:40 PM, Jeff Janes wrote:
>>
>>     The disk usage doesn't reach a steady state after one or two
>>     autovacs?  Or it does, but you are just unhappy about the ratio
>>     between the steady state size and the theoretical fully packed size?
>>
>>     Cheers,
>>
>>     Jeff
>
>
>     Since we dump&restore production DB daily into staging
>     environment, the difference in size (as reported by psql's \l+) is
>     11GB in a freshly restored DB as opposed to 70GB in production.
>
>
> Yeah, that seems like a problem.  Do you have long lived 
> transactions/snapshots that are preventing vacuuming from removing 
> dead tuples?  You can run a manual "vacuum verbose" and see how many 
> dead but nonremovable tuples there were, or 
> set log_autovacuum_min_duration to some non-negative value less than 
> the autovac takes, and do the same.
>
vacuum frees tuples just fine. It's just that by the time each run 
finishes many more accumulate due to table update activity, ad nauseum. 
So this unused space constantly grows. Here's a sample autovacuum run:

2019-04-11 19:39:44.450841500 [] LOG:  automatic vacuum of table 
"foo.public.bar": index scans: 1
2019-04-11 19:39:44.450843500   pages: 0 removed, 472095 remain, 4 
skipped due to pins, 39075 skipped frozen
2019-04-11 19:39:44.450844500   tuples: 19150 removed, 2725811 remain, 
465 are dead but not yet removable
2019-04-11 19:39:44.450845500   buffer usage: 62407557 hits, 6984769 
misses, 116409 dirtied
2019-04-11 19:39:44.450846500   avg read rate: 16.263 MB/s, avg write 
rate: 0.271 MB/s
2019-04-11 19:39:44.450847500   system usage: CPU 59.05s/115.26u sec 
elapsed 3355.28 sec


> (Indeed, those dumps you take daily might be the source of those 
> long-lived snapshots.  How long does a dump take?)

The daily dumps are taken daily from the slave server as part of stock 
FreeBSD postgres port activity.
I don't think it impacts the master server.

>
> Also, what does pg_freespace 
> (https://www.postgresql.org/docs/current/pgfreespacemap.html) show 
> about the available of space in the table?  How about pgstattuple 
> (https://www.postgresql.org/docs/current/pgstattuple.html)
>

Thanks, I'll try those. But as I said freshly restored DB is only 11GB 
in size, not 70 (only public schema is used).

> Cheers,
>
> Jeff

view thread (30+ messages)  latest in thread

Message-ID: <44a10837-648b-7cc9-d42a-146bc0c83574@mail.ru>
Permalink:  ../44a10837-648b-7cc9-d42a-146bc0c83574@mail.ru/
Also on:    postgresql.org/message-id/44a10837-648b-7cc9-d42a-146bc0c83574@mail.ru

 · 

reply

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: rihad@mail.ru, jeff.janes@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: When do vacuumed pages/tuples become available for reuse?
  In-Reply-To: <44a10837-648b-7cc9-d42a-146bc0c83574@mail.ru>
  References: <9cd73fcb-511d-ede9-6789-209b7d4eb193@mail.ru> <8560.1554990486@sss.pgh.pa.us> <0522481c-4cf6-1928-8780-9bfa2d7c6aca@mail.ru> <9914.1554992415@sss.pgh.pa.us> <17dafb0f-5ab9-390e-96b0-2280d654f790@mail.ru> <CAMkU=1wZ1jSDKOqR+KVoDXUT7yprWqMZD-Rv-x__q3i-URkHQw@mail.gmail.com> <c7d435c1-a6f6-d570-1698-b8791161d406@mail.ru> <CAMkU=1z+-o0F5PSsjhN8P98+YrYgg7odTZ+WZvocBObY-LnZLA@mail.gmail.com> <44a10837-648b-7cc9-d42a-146bc0c83574@mail.ru>

* 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