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 1mqHI1-0004Es-5m for pgsql-general@arkaria.postgresql.org; Thu, 25 Nov 2021 16:08:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mqHI0-00050o-3F for pgsql-general@arkaria.postgresql.org; Thu, 25 Nov 2021 16:08:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mqHHz-00050e-OV for pgsql-general@lists.postgresql.org; Thu, 25 Nov 2021 16:07:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mqHHw-0004ZD-Oe for pgsql-general@lists.postgresql.org; Thu, 25 Nov 2021 16:07:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1APG7rPv297265; Thu, 25 Nov 2021 11:07:53 -0500 From: Tom Lane To: Luca Ferrari cc: pgsql-general Subject: Re: ANALYZE, pg_class.xmin && pg_class.reltuples In-reply-to: References: Comments: In-reply-to Luca Ferrari message dated "Thu, 25 Nov 2021 13:58:02 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <297263.1637856473.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 25 Nov 2021 11:07:53 -0500 Message-ID: <297264.1637856473@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Luca Ferrari writes: > I've a doubt about running ANALYZE and inspecting pg_class.xmin and > pg_class.reltuples. > ... > So the pg_class record has changed its content, and in fact we are now > 2 transaction away the table creation, but the pg_class.xmin is the > same. ANALYZE (and VACUUM) update the table's pg_class row non-transactionally. See the comments for vac_update_relstats(): https://git.postgresql.org/gitweb/?p=3Dpostgresql.git;a=3Dblob;f=3Dsrc/bac= kend/commands/vacuum.c;h=3D5c4bc15b441b36da99b0703500a3268086b40d9e;hb=3DH= EAD#l1266 regards, tom lane