Re: ANALYZE, pg_class.xmin && pg_class.reltuples

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Luca Ferrari <fluca1978(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ANALYZE, pg_class.xmin && pg_class.reltuples
Date: 2021-11-25 16:07:53
Message-ID: 297264.1637856473@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Luca Ferrari <fluca1978(at)gmail(dot)com> 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=postgresql.git;a=blob;f=src/backend/commands/vacuum.c;h=5c4bc15b441b36da99b0703500a3268086b40d9e;hb=HEAD#l1266

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaozhong SHI 2021-11-25 16:12:44 function difference not found
Previous Message sivapostgres@yahoo.com 2021-11-25 13:05:49 Re: Error message while trying to connect from PGAdmin 4