PostgreSQL statistics

From: Paulo Silva <paulojjs(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: PostgreSQL statistics
Date: 2023-11-17 10:25:17
Message-ID: CAHJdQrk7ycpKYJCUS8suYRF5G0NMzb08agr+Smu1NK5JrKGdxA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)com>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-11-17 16:14:43 Re: PostgreSQL statistics
Previous Message Avi Weinberg 2023-11-16 17:19:21 Trigger to Count Number of Logical Replication Table Changes.