From: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
To: Keith Fiske <keith.fiske@crunchydata.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: RE: How can i be certain autovacuum is causing reuse if table still grows
Date: Mon, 27 Jul 2020 22:48:59 +0000
Message-ID: <CP2PR80MB0707549C2C142538ACDB975C8C720@CP2PR80MB0707.lamprd80.prod.outlook.com> (raw)
In-Reply-To: <CAODZiv7xdCkqqn3OjK_17ZQg-ZXtMvMOvBLQ=8RRHB+FU19SzA@mail.gmail.com>
References: <FR1PR80MB071069E71B2758BB9D187EC18C770@FR1PR80MB0710.lamprd80.prod.outlook.com>
<CP2PR80MB0707AE54D878CA370750BE908C720@CP2PR80MB0707.lamprd80.prod.outlook.com>
<CAKFQuwYRfH0JMfubcKL=U6oo1cXrtb44H5O+ywXyuKDKg96_KA@mail.gmail.com>
<CP2PR80MB0707312D852432398C61BDD08C720@CP2PR80MB0707.lamprd80.prod.outlook.com>
<CAODZiv5PeT90z6Ou4pgj9s39oBoYbB6STy_azMSekeDHUCHAEQ@mail.gmail.com>
<CP2PR80MB0707395805CE22D89FEB3D278C720@CP2PR80MB0707.lamprd80.prod.outlook.com>
<CAODZiv7MrqtzMAZ2vZs5gS1Rv935zjggdZmKAyAVZB6a5H1AJQ@mail.gmail.com>
<CAODZiv7xdCkqqn3OjK_17ZQg-ZXtMvMOvBLQ=8RRHB+FU19SzA@mail.gmail.com>
Thank you for the explanation Keith.
Pgstattuple runs for 8 hours approximately before printing its result.
and pg_freespace runs for "only" 16 minutes so we presumed really that pgstattuple scans the relation and brings more accurate information.
The strange fact is that pg_freespace result is changing from day to day, even without vacuum or analyze finishing.
At day one we start monitoring it was saying it has 108GB and kept changing each day.
And the worse fact is the different values for free space: pgstattupple with 2.3TB free VS pg_freespace with 96GB.
But i just killed autovacuum and started a manual vacuum verbose.
and 20 seconds later a autovacuum started.
it seems they are both running together.
Both sessions gets row exclusive locks.
I think it is better disabling autovacuum, do you agree?
________________________________
De: Keith Fiske <keith.fiske@crunchydata.com>
Enviado: segunda-feira, 27 de julho de 2020 19:21
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still grows
On Mon, Jul 27, 2020 at 6:19 PM Keith Fiske <keith.fiske@crunchydata.com<mailto:keith.fiske@crunchydata.com>> wrote:
As the documentation for pg_freespacemap says, it's values are not exact and they may not be up to date because you are viewing the statistics that were gathered during the last analyze, not the actual freespace map
Sorry, just wanted to clarify this. You are looking at the actual freespace map. It's that the values actually stored in it are not exact and based off of statistics gathering
https://www.postgresql.org/docs/9.6/pgfreespacemap.html<https://nam10.safelinks.protection.outloo...;
When you run pgstattuple, it is actually scanning the target object. Also note that scanning a table does not also scan its indexes, those must be done individually. So the free space reported by pgstattuple should be the actual free space, given as both byte size and % of the whole object.
pg_freespacemap is used by the planner and several other internal parts of PG, so checking it must be quick. pgstattuple can take a while to run on larger objects, but it will give you 100% accurate results as of the time it ran. This is why I prefer it when checking for bloat since many of the queries you see out there also try and base their results on stats. While the query runs quick, I've often seen them be wildly wrong.
Also, I would not recommend partitioning simply to improve vacuuming. Especially if extensive tuning hasn't been tried first. Most times you can get per-table tuning working well enough to get autovacuum running properly. Especially on 9.6 and even more-so on PG11, where autovacuum has itself been improved.
--
Keith Fiske
Senior Database Engineer
Crunchy Data - http://crunchydata.com<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fcrunchyda...;
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-admin@postgresql.org
Cc: sidney@tjrj.jus.br, keith.fiske@crunchydata.com, david.g.johnston@gmail.com
Subject: Re: How can i be certain autovacuum is causing reuse if table still grows
In-Reply-To: <CP2PR80MB0707549C2C142538ACDB975C8C720@CP2PR80MB0707.lamprd80.prod.outlook.com>
References: <FR1PR80MB071069E71B2758BB9D187EC18C770@FR1PR80MB0710.lamprd80.prod.outlook.com> <CP2PR80MB0707AE54D878CA370750BE908C720@CP2PR80MB0707.lamprd80.prod.outlook.com> <CAKFQuwYRfH0JMfubcKL=U6oo1cXrtb44H5O+ywXyuKDKg96_KA@mail.gmail.com> <CP2PR80MB0707312D852432398C61BDD08C720@CP2PR80MB0707.lamprd80.prod.outlook.com> <CAODZiv5PeT90z6Ou4pgj9s39oBoYbB6STy_azMSekeDHUCHAEQ@mail.gmail.com> <CP2PR80MB0707395805CE22D89FEB3D278C720@CP2PR80MB0707.lamprd80.prod.outlook.com> <CAODZiv7MrqtzMAZ2vZs5gS1Rv935zjggdZmKAyAVZB6a5H1AJQ@mail.gmail.com> <CAODZiv7xdCkqqn3OjK_17ZQg-ZXtMvMOvBLQ=8RRHB+FU19SzA@mail.gmail.com> <CP2PR80MB0707549C2C142538ACDB975C8C720@CP2PR80MB0707.lamprd80.prod.outlook.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