Thread: How can i be certain autovacuum is causing reuse if table still grows
How can i be certain autovacuum is causing reuse if table still grows
Re: How can i be certain autovacuum is causing reuse if table still grows
Hi, we have a 9.6.5 postgres
Autovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: 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
Hi, we have a 9.6.5 postgres
Autovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)
Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.
P {margin-top:0;margin-bottom:0;} Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.
Angular momentum makes the world go 'round.
RE: How can i be certain autovacuum is causing reuse if table still grows
About pgstattuple was a bit confusing its free area information when we compared to pg_freespace.
Enviado: segunda-feira, 27 de julho de 2020 17:59
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
Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.
RE: How can i be certain autovacuum is causing reuse if table still grows
Thank you Ron but this table has no date column.
It has one line for each page of each scanned document.
Enviado: segunda-feira, 27 de julho de 2020 18:27
Para: 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
Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.
Angular momentum makes the world go 'round.
Thank you so much Keith.We will try manual vacuum as you suggested.I read something like this but did not give the right attention to it.
About pgstattuple was a bit confusing its free area information when we compared to pg_freespace.Can you please explain this difference?De: Keith Fiske <keith.fiske@crunchydata.com>
Enviado: segunda-feira, 27 de julho de 2020 17:59
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 growsOn Mon, Jul 27, 2020 at 4:36 PM Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.Correct, the tuples will only be released once the autovacuum transaction has committed.If it's been running for days without being committed, I would recommend cancelling it and immediately running a manual vacuum before it starts up again. You'll have to be quick and double-check that your manual vacuum is the one running and not getting blocked by the wraparound vac starting up again. You can check this by looking at pg_stat_activity. You may see the wraparound vacuum try and start up again as well, but it should be blocked by yours and typically cancel out once yours finishes.A manual vacuum runs with different, more aggressive settings than autovacuum. So you should see this finish much sooner. May still take a few hours, but it shouldn't be much longer. The biggest culprit with autovacuum taking a long time on a given table, besides there being a lot of bloat, is typically autovacuum_vacuum_cost_delay, which can cause autovacuum to pause if autovacuum_vacuum_cost_limit is reached. With a manual vacuum, this delay is disabled (it uses vaccum_cost_delay which is by default 0). You can see more in this section of the documentation - https://www.postgresql.org/docs/9.6/runtime-config-autovacuum.htmlYou may want to adjust the autovac cost delay (lower it from 2 to 1 maybe). I believe you can do this on a per-table basis vs changing it for the entire database. I would not recommend completely disabling the delay until you at least get your system fully vacuumed and in a better state. I'd also recommend some more aggressive vacuuming be configured for your given table as well, so it doesn't accumulate so many dead rows before vacuum is able to run. I wrote about how to do this here - https://www.keithf4.com/per-table-autovacuum-tuning/After it finishes running, in addition to upgrading to the latest version of 9.6, I would recommend checking the table & indexes for bloat. You can use the pgstattuple contrib module or this script which makes it a little more user-friendly https://github.com/keithf4/pg_bloat_check--
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
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.On Mon, Jul 27, 2020 at 5:35 PM Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Thank you so much Keith.We will try manual vacuum as you suggested.I read something like this but did not give the right attention to it.
About pgstattuple was a bit confusing its free area information when we compared to pg_freespace.Can you please explain this difference?De: Keith Fiske <keith.fiske@crunchydata.com>
Enviado: segunda-feira, 27 de julho de 2020 17:59
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 growsOn Mon, Jul 27, 2020 at 4:36 PM Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.Correct, the tuples will only be released once the autovacuum transaction has committed.If it's been running for days without being committed, I would recommend cancelling it and immediately running a manual vacuum before it starts up again. You'll have to be quick and double-check that your manual vacuum is the one running and not getting blocked by the wraparound vac starting up again. You can check this by looking at pg_stat_activity. You may see the wraparound vacuum try and start up again as well, but it should be blocked by yours and typically cancel out once yours finishes.A manual vacuum runs with different, more aggressive settings than autovacuum. So you should see this finish much sooner. May still take a few hours, but it shouldn't be much longer. The biggest culprit with autovacuum taking a long time on a given table, besides there being a lot of bloat, is typically autovacuum_vacuum_cost_delay, which can cause autovacuum to pause if autovacuum_vacuum_cost_limit is reached. With a manual vacuum, this delay is disabled (it uses vaccum_cost_delay which is by default 0). You can see more in this section of the documentation - https://www.postgresql.org/docs/9.6/runtime-config-autovacuum.htmlYou may want to adjust the autovac cost delay (lower it from 2 to 1 maybe). I believe you can do this on a per-table basis vs changing it for the entire database. I would not recommend completely disabling the delay until you at least get your system fully vacuumed and in a better state. I'd also recommend some more aggressive vacuuming be configured for your given table as well, so it doesn't accumulate so many dead rows before vacuum is able to run. I wrote about how to do this here - https://www.keithf4.com/per-table-autovacuum-tuning/After it finishes running, in addition to upgrading to the latest version of 9.6, I would recommend checking the table & indexes for bloat. You can use the pgstattuple contrib module or this script which makes it a little more user-friendly https://github.com/keithf4/pg_bloat_check----
RE: How can i be certain autovacuum is causing reuse if table still grows
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
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
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.
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 growsOn Mon, Jul 27, 2020 at 6:19 PM Keith Fiske <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 mapSorry, 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 gatheringWhen 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.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: segunda-feira, 27 de julho de 2020 20:55
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
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 growsOn Mon, Jul 27, 2020 at 6:19 PM Keith Fiske <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 mapSorry, 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 gatheringWhen 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.
Thank you for the explanation Keith.We will really improve our minor release update policy.We have few but important postgres database here.I guess an outage would really be better.Index bloat is shorter than table bloat but it is present too.So far manual vacuum 3 of 8 indexes.An alter table to disable autovacuum and an autovacuum are both waiting for manual vacuum verbose.flip=# SELECT pid,flip-# Age(query_start, Clock_timestamp()),flip-# usename,flip-# query,flip-# state,flip-# wait_eventflip-# FROM pg_stat_activityflip-# WHERE query != '<IDLE>'flip-# AND query ilike '%vacuum%'flip-# ORDER BY query_start ASC;pid | age | usename | query | state | wait_event-------+------------------+----------+------------------------------------------------------------------------------+--------+------------25849 | -01:59:22.309787 | postgres | vacuum verbose flip_pagina_edicao; | active |22317 | -00:55:09.848074 | postgres | ALTER TABLE flip_pagina_edicao SET (autovacuum_enabled = false); | active | relation27718 | -00:53:00.368776 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound) | active | relationI am truly optimist it will solve.So far no user session is locked or waiting.
De: Keith Fiske <keith.fiske@crunchydata.com>
Enviado: segunda-feira, 27 de julho de 2020 20:55
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 growsWhat were the results of pgstattuple? Curious what the live tuple_* and dead_tuple* values vs the free space were. Also note that if you just ran it on the table, that is the results for JUST the table. If there are indexes as well, you'd have to check those separately and they may be even worse (index bloat is often worse than table). The pg_bloat_check script I linked, when run against a single table, will run against the table and all b-tree indexes (it cannot check gin/gist).Unfortunately, since this is a wraparound vacuum that is starting, disabling autovacuum will not work. Wraparound vacuums run even when autovac is disabled in order to try and keep you from getting into transaction exhaustion territory which means you must take the database offline to fix things and avoid data corruption. As I said autovac will attempt to run again, even if you start yours. And both will attempt to get the lock, but only one will actually succeed in getting it. Check the wait_event_type and wait_event column in pg_stat_activity to determine which one actually obtained the lock and you want to make sure yours is the one that did. Can check the documentation for the meanings of those columns https://www.postgresql.org/docs/9.6/monitoring-stats.html#PG-STAT-ACTIVITY-VIEWIn all honesty, though, if this table is as bloated as it seems, you may want to just try and schedule an outage to run a VACUUM FULL on this table and get it fully cleaned up. 2.3TB of empty space in just the table is quite a lot and each index may be just as bad. Until regular vacuums can efficiently run on this table it's only going to get progressively worse and just keep taking longer and longer. I would also highly suggest getting on the latest version of 9.6 before doing so that you're sure all bug fixes are in place.An outage now may be costly, but it will be nowhere near as costly as autovacuum never being able to run on this table and reaching transaction exhaustion.On Mon, Jul 27, 2020 at 6:49 PM Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote: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 growsOn Mon, Jul 27, 2020 at 6:19 PM Keith Fiske <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 mapSorry, 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 gatheringWhen 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.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: segunda-feira, 27 de julho de 2020 21:49
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Keith Fiske <keith.fiske@crunchydata.com>; 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
Thank you for the explanation Keith.We will really improve our minor release update policy.We have few but important postgres database here.I guess an outage would really be better.Index bloat is shorter than table bloat but it is present too.So far manual vacuum 3 of 8 indexes.An alter table to disable autovacuum and an autovacuum are both waiting for manual vacuum verbose.flip=# SELECT pid,flip-# Age(query_start, Clock_timestamp()),flip-# usename,flip-# query,flip-# state,flip-# wait_eventflip-# FROM pg_stat_activityflip-# WHERE query != '<IDLE>'flip-# AND query ilike '%vacuum%'flip-# ORDER BY query_start ASC;pid | age | usename | query | state | wait_event-------+------------------+----------+------------------------------------------------------------------------------+--------+------------25849 | -01:59:22.309787 | postgres | vacuum verbose flip_pagina_edicao; | active |22317 | -00:55:09.848074 | postgres | ALTER TABLE flip_pagina_edicao SET (autovacuum_enabled = false); | active | relation27718 | -00:53:00.368776 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound) | active | relationI am truly optimist it will solve.So far no user session is locked or waiting.
De: Keith Fiske <keith.fiske@crunchydata.com>
Enviado: segunda-feira, 27 de julho de 2020 20:55
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 growsWhat were the results of pgstattuple? Curious what the live tuple_* and dead_tuple* values vs the free space were. Also note that if you just ran it on the table, that is the results for JUST the table. If there are indexes as well, you'd have to check those separately and they may be even worse (index bloat is often worse than table). The pg_bloat_check script I linked, when run against a single table, will run against the table and all b-tree indexes (it cannot check gin/gist).Unfortunately, since this is a wraparound vacuum that is starting, disabling autovacuum will not work. Wraparound vacuums run even when autovac is disabled in order to try and keep you from getting into transaction exhaustion territory which means you must take the database offline to fix things and avoid data corruption. As I said autovac will attempt to run again, even if you start yours. And both will attempt to get the lock, but only one will actually succeed in getting it. Check the wait_event_type and wait_event column in pg_stat_activity to determine which one actually obtained the lock and you want to make sure yours is the one that did. Can check the documentation for the meanings of those columns https://www.postgresql.org/docs/9.6/monitoring-stats.html#PG-STAT-ACTIVITY-VIEWIn all honesty, though, if this table is as bloated as it seems, you may want to just try and schedule an outage to run a VACUUM FULL on this table and get it fully cleaned up. 2.3TB of empty space in just the table is quite a lot and each index may be just as bad. Until regular vacuums can efficiently run on this table it's only going to get progressively worse and just keep taking longer and longer. I would also highly suggest getting on the latest version of 9.6 before doing so that you're sure all bug fixes are in place.An outage now may be costly, but it will be nowhere near as costly as autovacuum never being able to run on this table and reaching transaction exhaustion.On Mon, Jul 27, 2020 at 6:49 PM Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote: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 growsOn Mon, Jul 27, 2020 at 6:19 PM Keith Fiske <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 mapSorry, 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 gatheringWhen 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.
P {margin-top:0;margin-bottom:0;} Thank you Ron but this table has no date column.
It has one line for each page of each scanned document.
De: Ron <ronljohnsonjr@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 18:27
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsAnother suggestion is to partition the table by a chronological key, so that only a fraction of the table needs to be vacuumed.On 7/27/20 3:36 PM, Sidney Aloisio Ferreira Pryor wrote: Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.--
Angular momentum makes the world go 'round.
Angular momentum makes the world go 'round.
On 7/27/20 5:19 PM, Keith Fiske wrote: [snip] > 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. SIMPLY to improve vacuum performance? No. But there are reasons that partitioning was "invented", and minimizing the work needed to be done on the whole of a Very Large and Rapidly Growing table is one of them. -- Angular momentum makes the world go 'round.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: 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
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.
> All lines even old ones might be updated by our application.
Ah. Even so, there are benefits to maintaining "lots of smaller chunks" instead of One Giant Table: "pg_dump --jobs=X" will run faster, for example, when there are more small-to-mid-sized tables instead of A Few Giant Tables. Ditto "reindexdb --jobs=X".
Given that even "old" records get updated, I'd look into some other key that you can "naturally" partition on.
P {margin-top:0;margin-bottom:0;} Thank you Ron.Yes there is a column id in which value is provided by a sequence.But it was not clear to me exactly how to partition?The idea is to cover a limited range of "id" so there will be less lines to vacuum on each operation?Because yet we will need eventually to vacuum all others.All lines even old ones might be updated by our application.De: Ron <ronljohnsonjr@gmail.com>
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn 7/27/20 5:19 PM, Keith Fiske wrote:
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.
Angular momentum makes the world go 'round.
So you can use your SERIAL (or GENERATED AS IDENTITY) column for this. If you don't have this, you might add a DATE DEFAULT CURRENT_DATE column, even if it's of no use except being the partition key.
Any key that "increases linearly over time" is a chronological key; sequences are a perfect example.On 7/27/20 4:38 PM, Sidney Aloisio Ferreira Pryor wrote:P {margin-top:0;margin-bottom:0;} Thank you Ron but this table has no date column.
It has one line for each page of each scanned document.
De: Ron <ronljohnsonjr@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 18:27
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsAnother suggestion is to partition the table by a chronological key, so that only a fraction of the table needs to be vacuumed.On 7/27/20 3:36 PM, Sidney Aloisio Ferreira Pryor wrote: Thank you, David.So can i assume that autovacuum only release dead tuples when it ends its execution?Autovacuum is not finishing and is running for days.We did not find a parameter to limit autovacuum executing time.Do you have any recomendation?Thank you.Sidney.De: David G. Johnston <david.g.johnston@gmail.com>
Enviado: segunda-feira, 27 de julho de 2020 17:17
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn Monday, July 27, 2020, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Hi, we have a 9.6.5 postgresAutovacuum is set with default parameters and is running on this table for days without naping or stopping.3285 | -5 days -23:33:10.792166 | postgres | autovacuum: VACUUM ANALYZE public.flip_pagina_edicao (to prevent wraparound)(1 rows)Its probably best avoid drawing conclusions here until the anti-wraparound vacuum has completed and you’ve updated to the latest minor version of PostgreSQL.David J.--
Angular momentum makes the world go 'round.--
Angular momentum makes the world go 'round.
-- Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
Re: How can i be certain autovacuum is causing reuse if table still grows
Em 28 de jul de 2020, à(s) 02:16, Ron <ronljohnsonjr@gmail.com> escreveu:
> All lines even old ones might be updated by our application.
Ah. Even so, there are benefits to maintaining "lots of smaller chunks" instead of One Giant Table: "pg_dump --jobs=X" will run faster, for example, when there are more small-to-mid-sized tables instead of A Few Giant Tables. Ditto "reindexdb --jobs=X".
Given that even "old" records get updated, I'd look into some other key that you can "naturally" partition on.On 7/27/20 10:54 PM, Sidney Aloisio Ferreira Pryor wrote:Thank you Ron.Yes there is a column id in which value is provided by a sequence.But it was not clear to me exactly how to partition?The idea is to cover a limited range of "id" so there will be less lines to vacuum on each operation?Because yet we will need eventually to vacuum all others.All lines even old ones might be updated by our application.De: Ron <ronljohnsonjr@gmail.com>
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn 7/27/20 5:19 PM, Keith Fiske wrote:
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.--
Angular momentum makes the world go 'round.
Thank you RonI would appreciate if you could share a good documentation or review link about partitioning tables on postgres.Enviado do meu iPhoneEm 28 de jul de 2020, à(s) 02:16, Ron <ronljohnsonjr@gmail.com> escreveu:
> All lines even old ones might be updated by our application.
Ah. Even so, there are benefits to maintaining "lots of smaller chunks" instead of One Giant Table: "pg_dump --jobs=X" will run faster, for example, when there are more small-to-mid-sized tables instead of A Few Giant Tables. Ditto "reindexdb --jobs=X".
Given that even "old" records get updated, I'd look into some other key that you can "naturally" partition on.On 7/27/20 10:54 PM, Sidney Aloisio Ferreira Pryor wrote:Thank you Ron.Yes there is a column id in which value is provided by a sequence.But it was not clear to me exactly how to partition?The idea is to cover a limited range of "id" so there will be less lines to vacuum on each operation?Because yet we will need eventually to vacuum all others.All lines even old ones might be updated by our application.De: Ron <ronljohnsonjr@gmail.com>
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn 7/27/20 5:19 PM, Keith Fiske wrote:
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.--
Angular momentum makes the world go 'round.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: terça-feira, 28 de julho de 2020 10:55
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Ron <ronljohnsonjr@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
Thank you RonI would appreciate if you could share a good documentation or review link about partitioning tables on postgres.Enviado do meu iPhoneEm 28 de jul de 2020, à(s) 02:16, Ron <ronljohnsonjr@gmail.com> escreveu:
> All lines even old ones might be updated by our application.
Ah. Even so, there are benefits to maintaining "lots of smaller chunks" instead of One Giant Table: "pg_dump --jobs=X" will run faster, for example, when there are more small-to-mid-sized tables instead of A Few Giant Tables. Ditto "reindexdb --jobs=X".
Given that even "old" records get updated, I'd look into some other key that you can "naturally" partition on.On 7/27/20 10:54 PM, Sidney Aloisio Ferreira Pryor wrote:Thank you Ron.Yes there is a column id in which value is provided by a sequence.But it was not clear to me exactly how to partition?The idea is to cover a limited range of "id" so there will be less lines to vacuum on each operation?Because yet we will need eventually to vacuum all others.All lines even old ones might be updated by our application.De: Ron <ronljohnsonjr@gmail.com>
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn 7/27/20 5:19 PM, Keith Fiske wrote:
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.--
Angular momentum makes the world go 'round.
RE: How can i be certain autovacuum is causing reuse if table still grows
Copy of Orginal (after vacuum full):
In meantime if you could please help us understand some curious facts below about vacuum verbose (not full).
Thank you.
Enviado: terça-feira, 28 de julho de 2020 15:20
Para: Keith Fiske <keith.fiske@crunchydata.com>
Cc: Ron <ronljohnsonjr@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
Enviado: terça-feira, 28 de julho de 2020 10:55
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Ron <ronljohnsonjr@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
Thank you RonI would appreciate if you could share a good documentation or review link about partitioning tables on postgres.Enviado do meu iPhoneEm 28 de jul de 2020, à(s) 02:16, Ron <ronljohnsonjr@gmail.com> escreveu:
> All lines even old ones might be updated by our application.
Ah. Even so, there are benefits to maintaining "lots of smaller chunks" instead of One Giant Table: "pg_dump --jobs=X" will run faster, for example, when there are more small-to-mid-sized tables instead of A Few Giant Tables. Ditto "reindexdb --jobs=X".
Given that even "old" records get updated, I'd look into some other key that you can "naturally" partition on.On 7/27/20 10:54 PM, Sidney Aloisio Ferreira Pryor wrote:Thank you Ron.Yes there is a column id in which value is provided by a sequence.But it was not clear to me exactly how to partition?The idea is to cover a limited range of "id" so there will be less lines to vacuum on each operation?Because yet we will need eventually to vacuum all others.All lines even old ones might be updated by our application.De: Ron <ronljohnsonjr@gmail.com>
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn 7/27/20 5:19 PM, Keith Fiske wrote:
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.--
Angular momentum makes the world go 'round.
Re: How can i be certain autovacuum is causing reuse if table still grows
Hi Keith, how are you?Hope you are very fine.As i promissed we ran vacuum full on that table on a test environment similar to production and it took 11 hours to complete.It reduced the original table segment from 2.3TB to 100GB as below (note that it is still growing...).So we are now proposing to our Direction a maintenance window to vacuum full production.Original:table_schema | table_name | total_size | data_size | external_size--------------+---------------------+------------+-----------+---------------public | flip_pagina_edicao | 4578 GB | 2880 GB | 1699 GB
Copy of Orginal (after vacuum full):table_schema | table_name | total_size | data_size | external_size--------------+---------------------+------------+-----------+---------------public | flip_pagina_edicao | 180 GB | 100 GB | 80 GB
In meantime if you could please help us understand some curious facts below about vacuum verbose (not full).I am running on production another vacuum verbose (not full) because that first one stucked on the same indexes for 3 days.But now is on a 3rd sequential scan of all indexes of that table followed by a scan on the table itself.It is not finishing even completing scans.1) Why it is scanning again and not finishing vacuum?
2) I noticed that on all scans it is taking 12 hours only on an index on a bpchar(1) column (character(1) DEFAULT 'N'::bpchar).All other indexes and even the table it self are running too much faster, can you guess a reason for this?CREATE INDEX ocrindexON public.flip_pagina_edicaoUSING btree(ocr COLLATE pg_catalog."default");
3) And is repeatly scanning 11.184.520 or 521 or 528 row versions.Why does it not end and scans again the same amount of row versions?
flip=# vacuum verbose flip_pagina_edicao;INFO: vacuuming "public.flip_pagina_edicao"INFO: scanned index "id_caderno" to remove 11184520 row versionsDETAIL: CPU 155.34s/540.40u sec elapsed 1101.49 secINFO: scanned index "ordem_index" to remove 11184520 row versionsDETAIL: CPU 253.35s/870.77u sec elapsed 1962.36 secINFO: scanned index "primary00024" to remove 11184520 row versionsDETAIL: CPU 134.10s/478.79u sec elapsed 922.02 secINFO: scanned index "ordem" to remove 11184520 row versionsDETAIL: CPU 265.16s/932.90u sec elapsed 1878.20 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184520 row versionsDETAIL: CPU 149.51s/523.42u sec elapsed 949.68 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184520 row versionsDETAIL: CPU 460.19s/1171.75u sec elapsed 2696.89 secINFO: scanned index "nomepdfindex" to remove 11184520 row versionsDETAIL: CPU 598.88s/1286.84u sec elapsed 3543.26 secINFO: scanned index "ocrindex" to remove 11184520 row versionsDETAIL: CPU 25657.30s/18907.82u sec elapsed 46652.49 secINFO: scanned index "idr_documento_index" to remove 11184520 row versionsDETAIL: CPU 321.96s/968.75u sec elapsed 2004.91 secINFO: "flip_pagina_edicao": removed 11184520 row versions in 3762529 pagesDETAIL: CPU 165.65s/95.06u sec elapsed 647.49 secINFO: scanned index "id_caderno" to remove 11184521 row versionsDETAIL: CPU 175.89s/461.26u sec elapsed 1098.74 secINFO: scanned index "ordem_index" to remove 11184521 row versionsDETAIL: CPU 301.57s/887.26u sec elapsed 2052.44 secINFO: scanned index "primary00024" to remove 11184521 row versionsDETAIL: CPU 150.12s/461.92u sec elapsed 947.74 secINFO: scanned index "ordem" to remove 11184521 row versionsDETAIL: CPU 286.29s/896.03u sec elapsed 1954.21 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184521 row versionsDETAIL: CPU 140.75s/423.38u sec elapsed 901.04 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184521 row versionsDETAIL: CPU 455.24s/1043.27u sec elapsed 2551.54 secINFO: scanned index "nomepdfindex" to remove 11184521 row versionsDETAIL: CPU 644.78s/1163.80u sec elapsed 3469.67 secINFO: scanned index "ocrindex" to remove 11184521 row versionsDETAIL: CPU 25951.95s/18712.36u sec elapsed 49880.37 secINFO: scanned index "idr_documento_index" to remove 11184521 row versionsDETAIL: CPU 274.05s/710.37u sec elapsed 1799.98 secINFO: "flip_pagina_edicao": removed 11184521 row versions in 2358457 pagesDETAIL: CPU 68.83s/36.81u sec elapsed 353.40 secINFO: scanned index "id_caderno" to remove 11184528 row versionsDETAIL: CPU 156.47s/372.75u sec elapsed 1022.31 secINFO: scanned index "ordem_index" to remove 11184528 row versionsDETAIL: CPU 257.13s/669.86u sec elapsed 2057.05 secINFO: scanned index "primary00024" to remove 11184528 row versionsDETAIL: CPU 116.29s/319.86u sec elapsed 842.55 secINFO: scanned index "ordem" to remove 11184528 row versionsDETAIL: CPU 232.78s/562.22u sec elapsed 2676.35 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184528 row versionsDETAIL: CPU 91.21s/241.00u sec elapsed 875.27 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184528 row versionsDETAIL: CPU 285.71s/585.63u sec elapsed 2593.08 secINFO: scanned index "nomepdfindex" to remove 11184528 row versionsDETAIL: CPU 413.55s/692.77u sec elapsed 3843.78 sec
Thank you.Sidney Pryor.De: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Enviado: terça-feira, 28 de julho de 2020 15:20
Para: Keith Fiske <keith.fiske@crunchydata.com>
Cc: Ron <ronljohnsonjr@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 growsThank you very much for this complete explanation and opinion, Keith.The first goal of publishing this mail on the list was to answer how to measure precisely free space: pgstattuple is the correct one.The second goal is running so far: manual vacuum to accomplish reuse of that large free area. (i will post a pgstattuple of the table when this vacuum ends)And the third goal is to free and downsize this huge allocation of space: schedule an outage to run vacuum full.Again i am truly grateful for your precious help.And i will post here Pg_total_relation_size before and after running vacuum full when we schedule that outage.Best Regards,Sidney PryorDe: Keith Fiske <keith.fiske@crunchydata.com>
Enviado: terça-feira, 28 de julho de 2020 10:55
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Ron <ronljohnsonjr@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 growsAgain, I would caution against going with partitioning until you can first try and tune the table itself. I have quite a bit of experience with it as I'm the author of pg_partman so you can see I have nothing against partitioning itself, but I'm only for using it when it's necessary. If you decide to go that route, it would be a good tool to help you automate much of the maintenance process of partitioning either by time or integer.I say this because, while it could possibly help with making vacuum more efficient, there are many caveats to partitioning. Since you're on 9.6, there is no native partitioning, so you'd have to do trigger based partitioning which has a HUGE impact on write performance (at least 2x slower if not worse). Even with native partitioning in 10+, there is a performance penalty during tuple routing and you would want to test that impact. Especially if you are doing updates which would move data across child partitions (updates that move data prior to PG10 are very, very complicated and not supported by pg_partman). Also, if you have any unique keys to maintain, they are not enforced across the partition set, and only supported in native if they are also part of the partition key itself. You're also just adding to the general complexity of your database overall.I would in general say the primary reason you would want to consider partitioning in PG is if you're trying to expire old data out. Dropping a table is much more efficient than running large/many DELETE statements due to the very issues you're encountering now: bloat. But it sounds like you are not expiring data, so you also have to take into account how many partitions you will have long term. It wasn't until PG12 that having over just even a few hundred partitions could have major performance impact overall. So, before even considering partitioning, you would want to get onto the latest major release.Partitioning can help with vacuum and general maintenance, but that's really only when the actual live data in a single table starts getting very, very large. And in that case you may want to first consider your hardware resources before going down the road of partitioning since that may be the better benefit long term. You've got nearly 2.3TB of space to clean up in this table, so, again, you want to solve that problem first. If you had that much free space before this vacuum finished, you likely have even more now after it finishes. And just note that a regular vacuum is likely not going to clean up this space. It may clean up some, but vacuum only returns space to the system in very specific circumstances (the tail-end pages are empty). You could use something like pg_repack or pg_squeeze to do this without a long outage, but with bloat this size, you may run into issues with how long those tools would need to run. Especially if the table is still in use. So, again, I would recommend an outage to do a VACUUM FULL which will lock and rewrite the table. I'd be curious to see what your total size of the entire table before and after is. The following function will give that total size (table + indexes)select pg_total_relation_size('public.mytable');
So, while partitioning could possibly be the answer long term, I would not recommend it until you've cleaned up the existing bloat on this table and its indexes and try to tune autovacuum run more efficiently. If that works, you've saved yourself a great deal of complexity. And again, you'd definitely want to get on the latest major version of PG where partitioning has improved tremendously, so if a major version upgrade isn't in the works for a while, I wouldn't even consider it.--On Tue, Jul 28, 2020 at 6:18 AM Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:Thank you RonI would appreciate if you could share a good documentation or review link about partitioning tables on postgres.Enviado do meu iPhoneEm 28 de jul de 2020, à(s) 02:16, Ron <ronljohnsonjr@gmail.com> escreveu:
> All lines even old ones might be updated by our application.
Ah. Even so, there are benefits to maintaining "lots of smaller chunks" instead of One Giant Table: "pg_dump --jobs=X" will run faster, for example, when there are more small-to-mid-sized tables instead of A Few Giant Tables. Ditto "reindexdb --jobs=X".
Given that even "old" records get updated, I'd look into some other key that you can "naturally" partition on.On 7/27/20 10:54 PM, Sidney Aloisio Ferreira Pryor wrote:Thank you Ron.Yes there is a column id in which value is provided by a sequence.But it was not clear to me exactly how to partition?The idea is to cover a limited range of "id" so there will be less lines to vacuum on each operation?Because yet we will need eventually to vacuum all others.All lines even old ones might be updated by our application.De: Ron <ronljohnsonjr@gmail.com>
Enviado: terça-feira, 28 de julho de 2020 00:39
Para: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if table still growsOn 7/27/20 5:19 PM, Keith Fiske wrote:
[snip]
> 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.
SIMPLY to improve vacuum performance? No. But there are reasons that
partitioning was "invented", and minimizing the work needed to be done on
the whole of a Very Large and Rapidly Growing table is one of them.
--
Angular momentum makes the world go 'round.--
Angular momentum makes the world go 'round.
--
--Le lun. 3 août 2020 à 23:36, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> a écrit :Hi Keith, how are you?Hope you are very fine.As i promissed we ran vacuum full on that table on a test environment similar to production and it took 11 hours to complete.It reduced the original table segment from 2.3TB to 100GB as below (note that it is still growing...).So we are now proposing to our Direction a maintenance window to vacuum full production.Original:table_schema | table_name | total_size | data_size | external_size--------------+---------------------+------------+-----------+---------------public | flip_pagina_edicao | 4578 GB | 2880 GB | 1699 GB
Copy of Orginal (after vacuum full):table_schema | table_name | total_size | data_size | external_size--------------+---------------------+------------+-----------+---------------public | flip_pagina_edicao | 180 GB | 100 GB | 80 GB
In meantime if you could please help us understand some curious facts below about vacuum verbose (not full).I am running on production another vacuum verbose (not full) because that first one stucked on the same indexes for 3 days.But now is on a 3rd sequential scan of all indexes of that table followed by a scan on the table itself.It is not finishing even completing scans.1) Why it is scanning again and not finishing vacuum?Your maintenance_work_mem parameter value is probably too low.2) I noticed that on all scans it is taking 12 hours only on an index on a bpchar(1) column (character(1) DEFAULT 'N'::bpchar).All other indexes and even the table it self are running too much faster, can you guess a reason for this?CREATE INDEX ocrindexON public.flip_pagina_edicaoUSING btree(ocr COLLATE pg_catalog."default");Not used, so not in cache? or much bigger than the other ones?3) And is repeatly scanning 11.184.520 or 521 or 528 row versions.Why does it not end and scans again the same amount of row versions?Well, VACUUM is a multi-steps operation. It first scans the table and puts every tid that needs to be deleted in memory. Once done, il will scan indexes. But if there's more TID than memory can hold, it will have to do multiple scans of the table and the indexes. It seems clear in your case that, when VACUUM finds 11184520 TID, memory is full. By the way, memory is limited by a parameter named maintenance_work_mem. So what is its current value?flip=# vacuum verbose flip_pagina_edicao;INFO: vacuuming "public.flip_pagina_edicao"INFO: scanned index "id_caderno" to remove 11184520 row versionsDETAIL: CPU 155.34s/540.40u sec elapsed 1101.49 secINFO: scanned index "ordem_index" to remove 11184520 row versionsDETAIL: CPU 253.35s/870.77u sec elapsed 1962.36 secINFO: scanned index "primary00024" to remove 11184520 row versionsDETAIL: CPU 134.10s/478.79u sec elapsed 922.02 secINFO: scanned index "ordem" to remove 11184520 row versionsDETAIL: CPU 265.16s/932.90u sec elapsed 1878.20 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184520 row versionsDETAIL: CPU 149.51s/523.42u sec elapsed 949.68 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184520 row versionsDETAIL: CPU 460.19s/1171.75u sec elapsed 2696.89 secINFO: scanned index "nomepdfindex" to remove 11184520 row versionsDETAIL: CPU 598.88s/1286.84u sec elapsed 3543.26 secINFO: scanned index "ocrindex" to remove 11184520 row versionsDETAIL: CPU 25657.30s/18907.82u sec elapsed 46652.49 secINFO: scanned index "idr_documento_index" to remove 11184520 row versionsDETAIL: CPU 321.96s/968.75u sec elapsed 2004.91 secINFO: "flip_pagina_edicao": removed 11184520 row versions in 3762529 pagesDETAIL: CPU 165.65s/95.06u sec elapsed 647.49 secINFO: scanned index "id_caderno" to remove 11184521 row versionsDETAIL: CPU 175.89s/461.26u sec elapsed 1098.74 secINFO: scanned index "ordem_index" to remove 11184521 row versionsDETAIL: CPU 301.57s/887.26u sec elapsed 2052.44 secINFO: scanned index "primary00024" to remove 11184521 row versionsDETAIL: CPU 150.12s/461.92u sec elapsed 947.74 secINFO: scanned index "ordem" to remove 11184521 row versionsDETAIL: CPU 286.29s/896.03u sec elapsed 1954.21 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184521 row versionsDETAIL: CPU 140.75s/423.38u sec elapsed 901.04 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184521 row versionsDETAIL: CPU 455.24s/1043.27u sec elapsed 2551.54 secINFO: scanned index "nomepdfindex" to remove 11184521 row versionsDETAIL: CPU 644.78s/1163.80u sec elapsed 3469.67 secINFO: scanned index "ocrindex" to remove 11184521 row versionsDETAIL: CPU 25951.95s/18712.36u sec elapsed 49880.37 secINFO: scanned index "idr_documento_index" to remove 11184521 row versionsDETAIL: CPU 274.05s/710.37u sec elapsed 1799.98 secINFO: "flip_pagina_edicao": removed 11184521 row versions in 2358457 pagesDETAIL: CPU 68.83s/36.81u sec elapsed 353.40 secINFO: scanned index "id_caderno" to remove 11184528 row versionsDETAIL: CPU 156.47s/372.75u sec elapsed 1022.31 secINFO: scanned index "ordem_index" to remove 11184528 row versionsDETAIL: CPU 257.13s/669.86u sec elapsed 2057.05 secINFO: scanned index "primary00024" to remove 11184528 row versionsDETAIL: CPU 116.29s/319.86u sec elapsed 842.55 secINFO: scanned index "ordem" to remove 11184528 row versionsDETAIL: CPU 232.78s/562.22u sec elapsed 2676.35 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184528 row versionsDETAIL: CPU 91.21s/241.00u sec elapsed 875.27 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184528 row versionsDETAIL: CPU 285.71s/585.63u sec elapsed 2593.08 secINFO: scanned index "nomepdfindex" to remove 11184528 row versionsDETAIL: CPU 413.55s/692.77u sec elapsed 3843.78 sec
Thank you.Sidney Pryor.Guillaume.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: terça-feira, 4 de agosto de 2020 10:49
Para: Guillaume Lelarge <guillaume@lelarge.info>
Cc: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>; Ron <ronljohnsonjr@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
--Le lun. 3 août 2020 à 23:36, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> a écrit :Hi Keith, how are you?Hope you are very fine.As i promissed we ran vacuum full on that table on a test environment similar to production and it took 11 hours to complete.It reduced the original table segment from 2.3TB to 100GB as below (note that it is still growing...).So we are now proposing to our Direction a maintenance window to vacuum full production.Original:table_schema | table_name | total_size | data_size | external_size--------------+---------------------+------------+-----------+---------------public | flip_pagina_edicao | 4578 GB | 2880 GB | 1699 GB
Copy of Orginal (after vacuum full):table_schema | table_name | total_size | data_size | external_size--------------+---------------------+------------+-----------+---------------public | flip_pagina_edicao | 180 GB | 100 GB | 80 GB
In meantime if you could please help us understand some curious facts below about vacuum verbose (not full).I am running on production another vacuum verbose (not full) because that first one stucked on the same indexes for 3 days.But now is on a 3rd sequential scan of all indexes of that table followed by a scan on the table itself.It is not finishing even completing scans.1) Why it is scanning again and not finishing vacuum?Your maintenance_work_mem parameter value is probably too low.2) I noticed that on all scans it is taking 12 hours only on an index on a bpchar(1) column (character(1) DEFAULT 'N'::bpchar).All other indexes and even the table it self are running too much faster, can you guess a reason for this?CREATE INDEX ocrindexON public.flip_pagina_edicaoUSING btree(ocr COLLATE pg_catalog."default");Not used, so not in cache? or much bigger than the other ones?3) And is repeatly scanning 11.184.520 or 521 or 528 row versions.Why does it not end and scans again the same amount of row versions?Well, VACUUM is a multi-steps operation. It first scans the table and puts every tid that needs to be deleted in memory. Once done, il will scan indexes. But if there's more TID than memory can hold, it will have to do multiple scans of the table and the indexes. It seems clear in your case that, when VACUUM finds 11184520 TID, memory is full. By the way, memory is limited by a parameter named maintenance_work_mem. So what is its current value?flip=# vacuum verbose flip_pagina_edicao;INFO: vacuuming "public.flip_pagina_edicao"INFO: scanned index "id_caderno" to remove 11184520 row versionsDETAIL: CPU 155.34s/540.40u sec elapsed 1101.49 secINFO: scanned index "ordem_index" to remove 11184520 row versionsDETAIL: CPU 253.35s/870.77u sec elapsed 1962.36 secINFO: scanned index "primary00024" to remove 11184520 row versionsDETAIL: CPU 134.10s/478.79u sec elapsed 922.02 secINFO: scanned index "ordem" to remove 11184520 row versionsDETAIL: CPU 265.16s/932.90u sec elapsed 1878.20 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184520 row versionsDETAIL: CPU 149.51s/523.42u sec elapsed 949.68 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184520 row versionsDETAIL: CPU 460.19s/1171.75u sec elapsed 2696.89 secINFO: scanned index "nomepdfindex" to remove 11184520 row versionsDETAIL: CPU 598.88s/1286.84u sec elapsed 3543.26 secINFO: scanned index "ocrindex" to remove 11184520 row versionsDETAIL: CPU 25657.30s/18907.82u sec elapsed 46652.49 secINFO: scanned index "idr_documento_index" to remove 11184520 row versionsDETAIL: CPU 321.96s/968.75u sec elapsed 2004.91 secINFO: "flip_pagina_edicao": removed 11184520 row versions in 3762529 pagesDETAIL: CPU 165.65s/95.06u sec elapsed 647.49 secINFO: scanned index "id_caderno" to remove 11184521 row versionsDETAIL: CPU 175.89s/461.26u sec elapsed 1098.74 secINFO: scanned index "ordem_index" to remove 11184521 row versionsDETAIL: CPU 301.57s/887.26u sec elapsed 2052.44 secINFO: scanned index "primary00024" to remove 11184521 row versionsDETAIL: CPU 150.12s/461.92u sec elapsed 947.74 secINFO: scanned index "ordem" to remove 11184521 row versionsDETAIL: CPU 286.29s/896.03u sec elapsed 1954.21 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184521 row versionsDETAIL: CPU 140.75s/423.38u sec elapsed 901.04 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184521 row versionsDETAIL: CPU 455.24s/1043.27u sec elapsed 2551.54 secINFO: scanned index "nomepdfindex" to remove 11184521 row versionsDETAIL: CPU 644.78s/1163.80u sec elapsed 3469.67 secINFO: scanned index "ocrindex" to remove 11184521 row versionsDETAIL: CPU 25951.95s/18712.36u sec elapsed 49880.37 secINFO: scanned index "idr_documento_index" to remove 11184521 row versionsDETAIL: CPU 274.05s/710.37u sec elapsed 1799.98 secINFO: "flip_pagina_edicao": removed 11184521 row versions in 2358457 pagesDETAIL: CPU 68.83s/36.81u sec elapsed 353.40 secINFO: scanned index "id_caderno" to remove 11184528 row versionsDETAIL: CPU 156.47s/372.75u sec elapsed 1022.31 secINFO: scanned index "ordem_index" to remove 11184528 row versionsDETAIL: CPU 257.13s/669.86u sec elapsed 2057.05 secINFO: scanned index "primary00024" to remove 11184528 row versionsDETAIL: CPU 116.29s/319.86u sec elapsed 842.55 secINFO: scanned index "ordem" to remove 11184528 row versionsDETAIL: CPU 232.78s/562.22u sec elapsed 2676.35 secINFO: scanned index "flip_pagina_edicao_pkey" to remove 11184528 row versionsDETAIL: CPU 91.21s/241.00u sec elapsed 875.27 secINFO: scanned index "flip_flippagedic_idcaderno" to remove 11184528 row versionsDETAIL: CPU 285.71s/585.63u sec elapsed 2593.08 secINFO: scanned index "nomepdfindex" to remove 11184528 row versionsDETAIL: CPU 413.55s/692.77u sec elapsed 3843.78 sec
Thank you.Sidney Pryor.Guillaume.
Thank you very much Guillaume and Keith for your straight and quick answers.I was looking this database size and tup_update history.It never shrank even with autovacuum enabled (growing 100GB a month).The number of updates was always this high.But on last 2 months its size started to grow a lot (growing 50GB a day).We will schedule a vacuum full to stop adding disks.But i am truly afraid postgres is not suitable for this application.We are talkiing with dev team for the last three weeks.And so far no answer about optimizing the number of updates.It is true we have never executed a vacuum full on this database.But its size even growing was not so much to worry about.And if postgres was never able to follow the number of updates and reuse efficiently.I am afraid an autovacuum tuning may not be sufficente to reuse after we finish vacuum full and downsize the database from 4tb to 200gb.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: terça-feira, 4 de agosto de 2020 13:34
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Guillaume Lelarge <guillaume@lelarge.info>; Ron <ronljohnsonjr@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
Thank you very much Guillaume and Keith for your straight and quick answers.I was looking this database size and tup_update history.It never shrank even with autovacuum enabled (growing 100GB a month).The number of updates was always this high.But on last 2 months its size started to grow a lot (growing 50GB a day).We will schedule a vacuum full to stop adding disks.But i am truly afraid postgres is not suitable for this application.We are talkiing with dev team for the last three weeks.And so far no answer about optimizing the number of updates.It is true we have never executed a vacuum full on this database.But its size even growing was not so much to worry about.And if postgres was never able to follow the number of updates and reuse efficiently.I am afraid an autovacuum tuning may not be sufficente to reuse after we finish vacuum full and downsize the database from 4tb to 200gb.
RE: How can i be certain autovacuum is causing reuse if table still grows
data | n_tup_ins | n_tup_upd | n_tup_del | n_tup_live | n_tup_dead | last_autovacuum | last_autoanalyze |
30/06/2020 13:30 | 57.308.133 | 6.744.431.635 | 1.614.325 | 165.531.847 | 2.458.943.354 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
30/06/2020 19:00 | 57.386.558 | 6.748.230.176 | 1.618.162 | 165.606.435 | 2.462.729.202 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
01/07/2020 13:30 | 57.736.340 | 6.783.682.703 | 1.636.765 | 165.937.614 | 2.483.584.486 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
01/07/2020 19:30 | 57.837.003 | 6.837.618.849 | 1.650.215 | 166.024.827 | 2.489.316.701 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
02/07/2020 13:30 | 58.143.439 | 6.865.274.910 | 1.660.968 | 166.320.510 | 2.515.717.862 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
02/07/2020 19:30 | 58.226.810 | 6.882.586.543 | 1.663.168 | 166.401.681 | 2.527.673.618 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
03/07/2020 13:30 | 58.544.013 | 6.908.650.471 | 1.687.055 | 166.694.933 | 2.551.229.982 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
03/07/2020 19:30 | 58.640.756 | 6.931.648.963 | 1.693.146 | 166.785.585 | 2.564.810.596 | 2020-05-10 19:31:11.792893-03 | 2020-05-10 19:33:55.497008-03 |
Enviado: terça-feira, 4 de agosto de 2020 13:50
Para: Keith Fiske <keith.fiske@crunchydata.com>
Cc: Guillaume Lelarge <guillaume@lelarge.info>; Ron <ronljohnsonjr@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
Enviado: terça-feira, 4 de agosto de 2020 13:34
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Guillaume Lelarge <guillaume@lelarge.info>; Ron <ronljohnsonjr@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
Thank you very much Guillaume and Keith for your straight and quick answers.I was looking this database size and tup_update history.It never shrank even with autovacuum enabled (growing 100GB a month).The number of updates was always this high.But on last 2 months its size started to grow a lot (growing 50GB a day).We will schedule a vacuum full to stop adding disks.But i am truly afraid postgres is not suitable for this application.We are talkiing with dev team for the last three weeks.And so far no answer about optimizing the number of updates.It is true we have never executed a vacuum full on this database.But its size even growing was not so much to worry about.And if postgres was never able to follow the number of updates and reuse efficiently.I am afraid an autovacuum tuning may not be sufficente to reuse after we finish vacuum full and downsize the database from 4tb to 200gb.
> On Aug 4, 2020, at 12:31 PM, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote: > > Beside this, i saw on pg_stat_tables and the vacuum and autovacuum count for this table is 0. Those values are not persistent; they are only since the last start of PG.
RE: How can i be certain autovacuum is causing reuse if table still grows
Enviado: terça-feira, 4 de agosto de 2020 16:53
Para: Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br>
Cc: Keith Fiske <keith.fiske@crunchydata.com>; Guillaume Lelarge <guillaume@lelarge.info>; Ron <ronljohnsonjr@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
>
> Beside this, i saw on pg_stat_tables and the vacuum and autovacuum count for this table is 0.
Those values are not persistent; they are only since the last start of PG.
> On Aug 4, 2020, at 12:31 PM, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:
>
> Beside this, i saw on pg_stat_tables and the vacuum and autovacuum count for this table is 0.
Those values are not persistent; they are only since the last start of PG.
I think statistics are also reset and not persistent through restarts when the pg_ctl option "-m immediate" is used when shutting down PG since it forces recovery mode when starting PG back up. By the way, for PostgreSQL Aurora, statistics are reset automatically every time aurora forces PG to restart or reboot or the user selects that option manually. I reported this as a bug with Aurora a few months ago. They said it was not a bug, but a feature that the might implement in the future. YUK.
Regards,
Michael Vitale
Keith Fiske wrote on 8/4/2020 6:25 PM:
On Tue, Aug 4, 2020 at 3:54 PM Scott Ribe <scott_ribe@elevated-dev.com> wrote:> On Aug 4, 2020, at 12:31 PM, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:
>
> Beside this, i saw on pg_stat_tables and the vacuum and autovacuum count for this table is 0.
Those values are not persistent; they are only since the last start of PG.This is not correct. Statistics are persistent through restarts. They are only reset during specific cases such as a crash or a major version upgrade. They can also be reset at any time manually.--
Hi Keith,
I think statistics are also reset and not persistent through restarts when the pg_ctl option "-m immediate" is used when shutting down PG since it forces recovery mode when starting PG back up. By the way, for PostgreSQL Aurora, statistics are reset automatically every time aurora forces PG to restart or reboot or the user selects that option manually. I reported this as a bug with Aurora a few months ago. They said it was not a bug, but a feature that the might implement in the future. YUK.
Regards,
Michael Vitale
Keith Fiske wrote on 8/4/2020 6:25 PM:On Tue, Aug 4, 2020 at 3:54 PM Scott Ribe <scott_ribe@elevated-dev.com> wrote:> On Aug 4, 2020, at 12:31 PM, Sidney Aloisio Ferreira Pryor <sidney@tjrj.jus.br> wrote:
>
> Beside this, i saw on pg_stat_tables and the vacuum and autovacuum count for this table is 0.
Those values are not persistent; they are only since the last start of PG.This is not correct. Statistics are persistent through restarts. They are only reset during specific cases such as a crash or a major version upgrade. They can also be reset at any time manually.--