PostgreSQL statistics - Mailing list pgsql-general

From Paulo Silva
Subject PostgreSQL statistics
Date
Msg-id CAHJdQrk7ycpKYJCUS8suYRF5G0NMzb08agr+Smu1NK5JrKGdxA@mail.gmail.com
Whole thread Raw
Responses Re: PostgreSQL statistics
List pgsql-general
Hi,

I have a table in a PostgreSQL 11 server that isn't being used a lot.

If I run a manual ANALYSE on it the last_analyse statistic isn't being update (I've waited enough time for it to be updated):

# SELECT * FROM pg_catalog.pg_stat_user_tables WHERE schemaname='s1' and relname='t1';
   relid   |      schemaname      |      relname      | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze | last_vacuum |        last_autovacuum        | last_analyze | last_autoanalyze | vacuum_count | autovacuum_count | analyze_count | autoanalyze_count
-----------+----------------------+-------------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------+-------------+-------------------------------+--------------+------------------+--------------+------------------+---------------+-------------------
 237177743 | s1 | t1 |        0 |            0 |        0 |             0 |         0 |         0 |         0 |             0 |       4820 |          0 |                   0 |             | 2023-11-03 13:34:23.725802+00 |              |                  |            0 |                1 |             0 |                 0
(1 row)

But if I run a "SELECT * FROM s1.t1"  I see the seq_scan increase to 1 (as expected) and after that I can issue a manual ANALYZE and the last_analyze gets updated.

Is this behaviour normal? Are there some parameters that are verified that prevent the ANALYSE from running?

Regards
--
Paulo Silva <paulojjs@gmail.com>

pgsql-general by date:

Previous
From: Avi Weinberg
Date:
Subject: Trigger to Count Number of Logical Replication Table Changes.
Next
From: Adrian Klaver
Date:
Subject: Re: PostgreSQL statistics