Skip to content

Commit b3abca6

Browse files
committed
pgstat: Update docs to match the shared memory stats reality.
This includes removing documentation for stats_temp_directory, adding documentation for stats_fetch_consistency, rephrasing references to the stats collector and documenting that starting a cleanly shut down standby will not remove stats anymore. The latter point might require further wordsmithing, it wasn't easy to adjust some of the existing content. Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Author: Andres Freund <andres@anarazel.de> Reviewed-By: Thomas Munro <thomas.munro@gmail.com> Reviewed-By: Justin Pryzby <pryzby@telsasoft.com> Reviewed-By: "David G. Johnston" <david.g.johnston@gmail.com> Reviewed-By: Lukas Fittl <lukas@fittl.com> Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
1 parent 76cbf7e commit b3abca6

9 files changed

+139
-119
lines changed

doc/src/sgml/backup.sgml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,6 @@ SELECT * FROM pg_backup_stop(wait_for_archive => true);
10361036
<filename>pg_snapshots/</filename>, <filename>pg_stat_tmp/</filename>,
10371037
and <filename>pg_subtrans/</filename> (but not the directories themselves) can be
10381038
omitted from the backup as they will be initialized on postmaster startup.
1039-
If <xref linkend="guc-stats-temp-directory"/> is set and is under the data
1040-
directory then the contents of that directory can also be omitted.
10411039
</para>
10421040

10431041
<para>

doc/src/sgml/catalogs.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9593,9 +9593,9 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
95939593
<para>
95949594
<xref linkend="view-table"/> lists the system views described here.
95959595
More detailed documentation of each view follows below.
9596-
There are some additional views that provide access to the results of
9597-
the statistics collector; they are described in <xref
9598-
linkend="monitoring-stats-views-table"/>.
9596+
There are some additional views that provide access to accumulated
9597+
statistics; they are described in
9598+
<xref linkend="monitoring-stats-views-table"/>.
95999599
</para>
96009600

96019601
<para>

doc/src/sgml/config.sgml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7885,15 +7885,15 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
78857885
<sect1 id="runtime-config-statistics">
78867886
<title>Run-time Statistics</title>
78877887

7888-
<sect2 id="runtime-config-statistics-collector">
7889-
<title>Query and Index Statistics Collector</title>
7888+
<sect2 id="runtime-config-cumulative-statistics">
7889+
<title>Cumulative Query and Index Statistics</title>
78907890

78917891
<para>
7892-
These parameters control server-wide statistics collection features.
7893-
When statistics collection is enabled, the data that is produced can be
7894-
accessed via the <structname>pg_stat</structname> and
7895-
<structname>pg_statio</structname> family of system views.
7896-
Refer to <xref linkend="monitoring"/> for more information.
7892+
These parameters control the server-wide cumulative statistics system.
7893+
When enabled, the data that is collected can be accessed via the
7894+
<structname>pg_stat</structname> and <structname>pg_statio</structname>
7895+
family of system views. Refer to <xref linkend="monitoring"/> for more
7896+
information.
78977897
</para>
78987898

78997899
<variablelist>
@@ -8031,22 +8031,37 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
80318031
</listitem>
80328032
</varlistentry>
80338033

8034-
<varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
8035-
<term><varname>stats_temp_directory</varname> (<type>string</type>)
8034+
<varlistentry id="guc-stats-fetch-consistency" xreflabel="stats_fetch_consistency">
8035+
<term><varname>stats_fetch_consistency</varname> (<type>enum</type>)
80368036
<indexterm>
8037-
<primary><varname>stats_temp_directory</varname> configuration parameter</primary>
8037+
<primary><varname>stats_fetch_consistency</varname> configuration parameter</primary>
80388038
</indexterm>
80398039
</term>
80408040
<listitem>
80418041
<para>
8042-
Sets the directory to store temporary statistics data in. This can be
8043-
a path relative to the data directory or an absolute path. The default
8044-
is <filename>pg_stat_tmp</filename>. Pointing this at a RAM-based
8045-
file system will decrease physical I/O requirements and can lead to
8046-
improved performance.
8047-
This parameter can only be set in the <filename>postgresql.conf</filename>
8048-
file or on the server command line.
8042+
Determines the behavior when cumulative statistics are accessed
8043+
multiple times within a transaction. When set to
8044+
<literal>none</literal>, each access re-fetches counters from shared
8045+
memory. When set to <literal>cache</literal>, the first access to
8046+
statistics for an object caches those statistics until the end of the
8047+
transaction unless <function>pg_stat_clear_snapshot()</function> is
8048+
called. When set to <literal>snapshot</literal>, the first statistics
8049+
access caches all statistics accessible in the current database, until
8050+
the end of the transaction unless
8051+
<function>pg_stat_clear_snapshot()</function> is called. The default
8052+
is <literal>cache</literal>.
80498053
</para>
8054+
<note>
8055+
<para>
8056+
<literal>none</literal> is most suitable for monitoring systems. If
8057+
values are only accessed once, it is the most
8058+
efficient. <literal>cache</literal> ensures repeat accesses yield the
8059+
same values, which is important for queries involving
8060+
e.g. self-joins. <literal>snapshot</literal> can be useful when
8061+
interactively inspecting statistics, but has higher overhead,
8062+
particularly if many database objects exist.
8063+
</para>
8064+
</note>
80508065
</listitem>
80518066
</varlistentry>
80528067

doc/src/sgml/func.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28019,8 +28019,8 @@ SELECT collation for ('foo' COLLATE "de_DE");
2801928019
<para>
2802028020
Requests to log the memory contexts of the backend with the
2802128021
specified process ID. This function can send the request to
28022-
backends and auxiliary processes except logger and statistics
28023-
collector. These memory contexts will be logged at
28022+
backends and auxiliary processes except logger. These memory contexts
28023+
will be logged at
2802428024
<literal>LOG</literal> message level. They will appear in
2802528025
the server log based on the log configuration set
2802628026
(See <xref linkend="runtime-config-logging"/> for more information),

doc/src/sgml/glossary.sgml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,16 @@
136136
The auxiliary processes consist of <!-- in alphabetical order -->
137137
<!-- NB: In the code, the autovac launcher doesn't use the auxiliary
138138
process scaffolding; however it does behave as one so we list it
139-
here anyway. In addition, logger and stats collector aren't
140-
connected to shared memory so most code outside postmaster.c
141-
doesn't even consider them "procs" in the first place.
139+
here anyway. In addition, logger isn't connected to shared memory so
140+
most code outside postmaster.c doesn't even consider them "procs" in
141+
the first place.
142142
-->
143143
the <glossterm linkend="glossary-autovacuum">autovacuum launcher</glossterm>
144144
(but not the autovacuum workers),
145145
the <glossterm linkend="glossary-background-writer">background writer</glossterm>,
146146
the <glossterm linkend="glossary-checkpointer">checkpointer</glossterm>,
147147
the <glossterm linkend="glossary-logger">logger</glossterm>,
148148
the <glossterm linkend="glossary-startup-process">startup process</glossterm>,
149-
the <glossterm linkend="glossary-stats-collector">statistics collector</glossterm>,
150149
the <glossterm linkend="glossary-wal-archiver">WAL archiver</glossterm>,
151150
the <glossterm linkend="glossary-wal-receiver">WAL receiver</glossterm>
152151
(but not the <glossterm linkend="glossary-wal-sender">WAL senders</glossterm>),
@@ -434,6 +433,21 @@
434433
</glossdef>
435434
</glossentry>
436435

436+
<glossentry id="glossary-cumulative-statistics">
437+
<glossterm>Cumulative Statistics System</glossterm>
438+
<glossdef>
439+
<para>
440+
A system which, if enabled, accumulates statistical information
441+
about the <glossterm linkend="glossary-instance">instance</glossterm>'s
442+
activities.
443+
</para>
444+
<para>
445+
For more information, see
446+
<xref linkend="monitoring-stats"/>.
447+
</para>
448+
</glossdef>
449+
</glossentry>
450+
437451
<glossentry>
438452
<glossterm>Data area</glossterm>
439453
<glosssee otherterm="glossary-data-directory" />
@@ -1563,22 +1577,6 @@
15631577
</glossdef>
15641578
</glossentry>
15651579

1566-
<glossentry id="glossary-stats-collector">
1567-
<glossterm>Stats collector (process)</glossterm>
1568-
<glossdef>
1569-
<para>
1570-
An <glossterm linkend="glossary-auxiliary-proc">auxiliary process</glossterm>
1571-
which, if enabled, receives statistical information
1572-
about the <glossterm linkend="glossary-instance">instance</glossterm>'s
1573-
activities.
1574-
</para>
1575-
<para>
1576-
For more information, see
1577-
<xref linkend="monitoring-stats"/>.
1578-
</para>
1579-
</glossdef>
1580-
</glossentry>
1581-
15821580
<glossentry id="glossary-system-catalog">
15831581
<glossterm>System catalog</glossterm>
15841582
<glossdef>

doc/src/sgml/high-availability.sgml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,12 +2227,13 @@ HINT: You can then restart the server after making the necessary configuration
22272227
</para>
22282228

22292229
<para>
2230-
The statistics collector is active during recovery. All scans, reads, blocks,
2231-
index usage, etc., will be recorded normally on the standby. Replayed
2232-
actions will not duplicate their effects on primary, so replaying an
2233-
insert will not increment the Inserts column of pg_stat_user_tables.
2234-
The stats file is deleted at the start of recovery, so stats from primary
2235-
and standby will differ; this is considered a feature, not a bug.
2230+
The cumulative statistics system is active during recovery. All scans,
2231+
reads, blocks, index usage, etc., will be recorded normally on the
2232+
standby. However, WAL replay will not increment relation and database
2233+
specific counters. I.e. replay will not increment pg_stat_all_tables
2234+
columns (like n_tup_ins), nor will reads or writes performed by the
2235+
startup process be tracked in the pg_statio views, nor will associated
2236+
pg_stat_database columns be incremented.
22362237
</para>
22372238

22382239
<para>

doc/src/sgml/maintenance.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ vacuum insert threshold = vacuum base insert threshold + vacuum insert scale fac
839839
it may be beneficial to lower the table's
840840
<xref linkend="reloption-autovacuum-freeze-min-age"/> as this may allow
841841
tuples to be frozen by earlier vacuums. The number of obsolete tuples and
842-
the number of inserted tuples are obtained from the statistics collector;
842+
the number of inserted tuples are obtained from the cumulative statistics system;
843843
it is a semi-accurate count updated by each <command>UPDATE</command>,
844844
<command>DELETE</command> and <command>INSERT</command> operation. (It is
845845
only semi-accurate because some information might be lost under heavy

0 commit comments

Comments
 (0)