postgresql/src/backend/commands
Andres Freund 5891c7a8ed pgstat: store statistics in shared memory.
Previously the statistics collector received statistics updates via UDP and
shared statistics data by writing them out to temporary files regularly. These
files can reach tens of megabytes and are written out up to twice a
second. This has repeatedly prevented us from adding additional useful
statistics.

Now statistics are stored in shared memory. Statistics for variable-numbered
objects are stored in a dshash hashtable (backed by dynamic shared
memory). Fixed-numbered stats are stored in plain shared memory.

The header for pgstat.c contains an overview of the architecture.

The stats collector is not needed anymore, remove it.

By utilizing the transactional statistics drop infrastructure introduced in a
prior commit statistics entries cannot "leak" anymore. Previously leaked
statistics were dropped by pgstat_vacuum_stat(), called from [auto-]vacuum. On
systems with many small relations pgstat_vacuum_stat() could be quite
expensive.

Now that replicas drop statistics entries for dropped objects, it is not
necessary anymore to reset stats when starting from a cleanly shut down
replica.

Subsequent commits will perform some further code cleanup, adapt docs and add
tests.

Bumps PGSTAT_FILE_FORMAT_ID.

Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-By: 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: Tomas Vondra <tomas.vondra@2ndquadrant.com> (in a much earlier version)
Reviewed-By: Arthur Zakirov <a.zakirov@postgrespro.ru> (in a much earlier version)
Reviewed-By: Antonin Houska <ah@cybertec.at> (in a much earlier version)
Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
Discussion: https://postgr.es/m/20220308205351.2xcn6k4x5yivcxyd@alap3.anarazel.de
Discussion: https://postgr.es/m/20210319235115.y3wz7hpnnrshdyv6@alap3.anarazel.de
2022-04-06 21:29:46 -07:00
..
Makefile Move parallel vacuum code to vacuumparallel.c. 2021-12-23 11:42:52 +05:30
aggregatecmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
alter.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
amcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
analyze.c pgstat: stats collector references in comments. 2022-04-06 13:56:06 -07:00
async.c Reduce more the number of calls to GetMaxBackends() 2022-02-10 10:27:29 +09:00
cluster.c Set relfrozenxid to oldest extant XID seen by VACUUM. 2022-04-03 09:57:21 -07:00
collationcmds.c Add option to use ICU as global locale provider 2022-03-17 11:13:16 +01:00
comment.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
conversioncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copy.c Add header matching mode to COPY FROM 2022-03-30 09:02:31 +02:00
copyfrom.c Fix typo in comment. 2022-03-30 19:00:00 +09:00
copyfromparse.c Add header matching mode to COPY FROM 2022-03-30 09:02:31 +02:00
copyto.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
createas.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dbcommands.c pgstat: stats collector references in comments. 2022-04-06 13:56:06 -07:00
define.c Add Boolean node 2022-01-17 10:38:23 +01:00
discard.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dropcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
event_trigger.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
explain.c JSON_TABLE 2022-04-04 16:03:47 -04:00
extension.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
foreigncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
functioncmds.c pgstat: scaffolding for transactional stats creation / drop. 2022-04-06 18:27:52 -07:00
indexcmds.c Fix comment in CheckIndexCompatible(). 2022-02-18 12:19:10 +09:00
lockcmds.c Add support for security invoker views. 2022-03-22 10:28:10 +00:00
matview.c pgstat: stats collector references in comments. 2022-04-06 13:56:06 -07:00
opclasscmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
operatorcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
policy.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
portalcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
prepare.c Add pg_analyze_and_rewrite_varparams() 2022-03-07 08:13:30 +01:00
proclang.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
publicationcmds.c Allow specifying column lists for logical replication 2022-03-26 01:01:27 +01:00
schemacmds.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
seclabel.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
sequence.c Add decoding of sequences to built-in replication 2022-03-24 18:49:27 +01:00
statscmds.c Check syscache result in AlterStatistics 2022-01-23 03:16:31 +01:00
subscriptioncmds.c Reorder subskiplsn in pg_subscription to avoid alignment issues. 2022-04-07 09:39:25 +05:30
tablecmds.c Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
tablespace.c Revert "Fix replay of create database records on standby" 2022-03-29 15:36:21 +02:00
trigger.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00
tsearchcmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
typecmds.c Add missing TYPEALIGN macros 2022-02-16 19:33:28 +07:00
user.c Remove the ability of a role to administer itself. 2022-03-28 13:38:13 -04:00
vacuum.c pgstat: store statistics in shared memory. 2022-04-06 21:29:46 -07:00
vacuumparallel.c pgstat: store statistics in shared memory. 2022-04-06 21:29:46 -07:00
variable.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
view.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00