Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0Bvj-0001Dh-Q4 for pgsql-admin@arkaria.postgresql.org; Mon, 27 Jul 2020 22:49:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k0Bvg-0007Zl-BX for pgsql-admin@arkaria.postgresql.org; Mon, 27 Jul 2020 22:49:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0Bvf-0007Ze-E1 for pgsql-admin@lists.postgresql.org; Mon, 27 Jul 2020 22:49:08 +0000 Received: from mail-eopbgr800055.outbound.protection.outlook.com ([40.107.80.55] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0Bvb-00008N-CY for pgsql-admin@lists.postgresql.org; Mon, 27 Jul 2020 22:49:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYJwXS0TIYylkFymodmQILc8lvmma7AKxedz+QnBXljFxr+EI7PAjt94dmYq5UydBsVKN1Ve3hfH+r+RHflR7q8kt1SyNB7KkpzOiVbRJoMMK0YiVAxYUh5OXzmw2tsftINa48AViieutW0wHpOenp9vghYZYsFC/l8A8pOE47aG2xa7HxsMV6MXbaOeRRJ3UYXwdzYabFN9L6lTThsTwiEr2G0aFDSsyTEtsC+zZLstqlFmHB3/98TcU/D2Qzqun6KIoOHQLTqw3w+sJ5+8O4a5FyJi3lIj5prt7zKXtec69447lbdyTwP7UV23suItMGS/XFb3DlrHc7g7cDTrBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GOswrZZaK8EModBbyME2wip/ThR/rKqIVrPJZ0zm5yA=; b=Bwr+yl0Lxj8v26dnvRGUk9Cl+TBzhqX5n0nJPta/bxI4NXxaRnvJObS6MfpsooBtSM/qSxMG9KFi1Z/nGXYQtHjsBShbbdskvqg1AGgxtpdvpvLFnO0tNYIUBVPphw2hBSK3wnJg/JSsZaWJmOqTStUA9Imf9Rwv2NFEYvSRRGDI0ogtqcRJPovENwIavkQTOzqZE06YFg2eiUxF77X2gxlvPdFc1CYGUqTyj6KXzHxnaruYJEx96BnnkIvO0s5zHzRqZAFBp0new8Z56uT/8n73I8fvcoqkdlYgzB3sEj9x1Z+rlOT8MF7kd1kQ8pQ/Mn/kvODpAHdK/Hv9La+K6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=tjrj.jus.br; dmarc=pass action=none header.from=tjrj.jus.br; dkim=pass header.d=tjrj.jus.br; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tjrj.jus.br; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GOswrZZaK8EModBbyME2wip/ThR/rKqIVrPJZ0zm5yA=; b=PkFDdEh7X2sEP6SuPSaPgUFwz3B1XVUrjTwDSVarSl2YvUPkxxfg4QG8IMM5IWktZtWdGexebXMFI+q+t+k5x4yLynNmzr6gjgGLIzyc4Zw2h5ZwpuIvfHpI0uuqFi8JOtrn2q6CAiRqNP/oGD8xAsjDZuqxBV6Pja60wBqGnYY= Received: from CP2PR80MB0707.lamprd80.prod.outlook.com (2603:10d6:102:b::17) by CPXPR80MB4983.lamprd80.prod.outlook.com (2603:10d6:103:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Mon, 27 Jul 2020 22:48:59 +0000 Received: from CP2PR80MB0707.lamprd80.prod.outlook.com ([fe80::38cc:2347:f088:a9ee]) by CP2PR80MB0707.lamprd80.prod.outlook.com ([fe80::38cc:2347:f088:a9ee%12]) with mapi id 15.20.3216.033; Mon, 27 Jul 2020 22:48:59 +0000 From: Sidney Aloisio Ferreira Pryor To: Keith Fiske CC: "David G. Johnston" , "pgsql-admin@lists.postgresql.org" Subject: RE: How can i be certain autovacuum is causing reuse if table still grows Thread-Topic: How can i be certain autovacuum is causing reuse if table still grows Thread-Index: AQHWYhGepsCqvK/lXUOJcvUYtwojlKkb3nm/gAADXYCAAAQwQIAAB1+AgAAIvqqAAA2hgIAAAKmAgAAERKI= Date: Mon, 27 Jul 2020 22:48:59 +0000 Message-ID: References: , In-Reply-To: Accept-Language: pt-BR, en-US Content-Language: pt-BR X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: crunchydata.com; dkim=none (message not signed) header.d=none;crunchydata.com; dmarc=none action=none header.from=tjrj.jus.br; x-originating-ip: [45.166.79.42] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5424d541-68fd-4b85-96d7-08d8327f402c x-ms-traffictypediagnostic: CPXPR80MB4983: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: j+6bOBq6twaee+C0pGbPu+2XSExvzNuhkOAVMqZDMMxdWMlDupiWM6n3EDF9angtBqaG+kMPkw1nj/LCoefRD1UmhGFQ1hCJ/ifA1xEJs2K+k+67blZaho/zx97hchPU6Mppg5NYv/ey/WhBq5eR3s99ZEo426qNxFjLB3r/qKm9Jvv7GhgM/pAB92cJLqevM9Q/y/rjOXEdYMr++LdgnEi1pb0NQ3pwY/tCTlmFW8Msf9lONg5JysGIenmBfYQRXTrIHkUfr1PvIaAnLxf26//bYsAB6LQYWSMQ/g/7lWDTL7CHfHzia5rqyzPkAOMHPgwymL9YhP9iTlqBqGMHp15VR3MqrCCtyI6W2NOgoWVdiGcPOiAJ38R5GB0jDoeZbvTr4+/54Z5FrRKuzS3cnA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CP2PR80MB0707.lamprd80.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(26005)(55016002)(9686003)(86362001)(66946007)(66446008)(186003)(64756008)(66556008)(66476007)(478600001)(76116006)(33656002)(166002)(71200400001)(53546011)(966005)(4326008)(83380400001)(316002)(2906002)(54906003)(7696005)(19627405001)(52536014)(6506007)(8676002)(8936002)(5660300002)(6916009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: 2UVQKVvevsWaZlri50eNfJcAfilZrWi2AZXRLSoXR6xpt/dbntGbQsPp3g4a3sMCUbOdTApLIciZYsa1oJ4OuQoeh6Apj7D3LNn3IlC09yzZHf2xVXbaRC41H3mUx7lE5ghPCwYJWCUDadkl8nVLTYa3EqunCG1Ffz7zzGBw3ARv12364kC1k4Gn7y6seoN/S3MC30cz9UJZbcu7jRPYolAzT3niracT62JIE8Y66tkopFOTKo78kx1XtkQJJIKVs7ioJKDhmW3uep3Z9+sNwasypA6fufDuD4I/43fr/G+CZBS03nojxfeB1CWT12Q82kmklBd8GukMy5rNLMf9bF1VAPF4kOUCLXJgha3DvvFfSN2hWpJombTbHwZgs42qek5dLrOWmi9bwvFfH5hdxI0XqZCA/azhQPuV2xKPLZTqcqq23AR/L/LGze3njG0+knRjU+GLE+l9clkWNYw+qkBrEUlye6jTAKLI5APMK8c= x-ms-exchange-transport-forked: True Content-Type: multipart/alternative; boundary="_000_CP2PR80MB0707549C2C142538ACDB975C8C720CP2PR80MB0707lamp_" MIME-Version: 1.0 X-OriginatorOrg: tjrj.jus.br X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CP2PR80MB0707.lamprd80.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5424d541-68fd-4b85-96d7-08d8327f402c X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jul 2020 22:48:59.1114 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: ce4e1164-986f-4132-85d1-1e3c17cf7d6e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 388z45JOPcg+lhd1zhDk14WWzjIGlTPMk3pcfKtlE+F38/baggHoJjuM/uCfJ7DR9Ns3qRVI4baQ1KowpLoBRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CPXPR80MB4983 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_CP2PR80MB0707549C2C142538ACDB975C8C720CP2PR80MB0707lamp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 pgst= attuple scans the relation and brings more accurate information. The strange fact is that pg_freespace result is changing from day to day, e= ven 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 wit= h 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 Enviado: segunda-feira, 27 de julho de 2020 19:21 Para: Sidney Aloisio Ferreira Pryor Cc: David G. Johnston ; pgsql-admin@lists.postg= resql.org Assunto: Re: How can i be certain autovacuum is causing reuse if table stil= l grows On Mon, Jul 27, 2020 at 6:19 PM Keith Fiske > wrote: As the documentation for pg_freespacemap says, it's values are not exact an= d they may not be up to date because you are viewing the statistics that we= re 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 of= f of statistics gathering https://www.postgresql.org/docs/9.6/pgfreespacemap.html When you run pgstattuple, it is actually scanning the target object. Also n= ote that scanning a table does not also scan its indexes, those must be don= e individually. So the free space reported by pgstattuple should be the act= ual 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 la= rger 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 quer= ies you see out there also try and base their results on stats. While the q= uery runs quick, I've often seen them be wildly wrong. Also, I would not recommend partitioning simply to improve vacuuming. Espec= ially if extensive tuning hasn't been tried first. Most times you can get p= er-table tuning working well enough to get autovacuum running properly. Esp= ecially on 9.6 and even more-so on PG11, where autovacuum has itself been i= mproved. -- Keith Fiske Senior Database Engineer Crunchy Data - http://crunchydata.com --_000_CP2PR80MB0707549C2C142538ACDB975C8C720CP2PR80MB0707lamp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
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.<= /div>

The strange fact is that pg_freespace result is changing from day to day, e= ven 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 wit= h 2.3TB free VS pg_freespace with 96GB.

But i just killed autovacuum and started a m= anual 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.f= iske@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-admi= n@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Assunto: Re: How can i be certain autovacuum is causing reuse if tab= le still grows
 


On Mon, Jul 27, 2020 at 6:19 PM Kei= th Fiske <keith.fiske@cru= nchydata.com> wrote:
As the documentation for pg_freespacemap says, it's values are not exa= ct and they may not be up to date because you are viewing the statistics th= at were gathered during the last analyze, not the actual freespace map
 

Sorry, just wanted to clarify this. You are looking at the actual free= space map. It's that the values actually stored in it are not exact and bas= ed off of statistics gathering

 

https://www.postgresql.org/docs/9.6/pgfreespacemap.html

When you run pgstattuple, it is actually scanning the target object. A= lso note that scanning a table does not also scan its indexes, those must b= e done individually. So the free space reported by pgstattuple should be th= e actual free space, given as both byte size and % of the whole object. 

pg_freespacemap is used by the planner and several other internal part= s 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 tim= e it ran. This is why I prefer it when checking for bloat since many of the queries you see out there also t= ry 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
--_000_CP2PR80MB0707549C2C142538ACDB975C8C720CP2PR80MB0707lamp_--