diff options
author | Andres Freund <andres@anarazel.de> | 2021-09-16 02:02:40 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2021-09-16 02:05:50 -0700 |
commit | 37a9aa659111c454386b7055dcd3809e45bc17de (patch) | |
tree | 3a5dd7b5b6d4f288f1eef499435823762254f939 /src/backend/tcop/postgres.c | |
parent | dc899146dbf0e1d23fb24155a5155826ddce34c9 (diff) | |
download | postgresql-37a9aa659111c454386b7055dcd3809e45bc17de.tar.gz postgresql-37a9aa659111c454386b7055dcd3809e45bc17de.zip |
Fix performance regression from session statistics.
Session statistics, as introduced by 960869da08, had several shortcomings:
- an additional GetCurrentTimestamp() call that also impaired the accuracy of
the data collected
This can be avoided by passing the current timestamp we already have in
pgstat_report_stat().
- an additional statistics UDP packet sent every 500ms
This is solved by adding the new statistics to PgStat_MsgTabstat.
This is conceptually ugly, because session statistics are not
table statistics. But the struct already contains data unrelated
to tables, so there is not much damage done.
Connection and disconnection are reported in separate messages, which
reduces the number of additional messages to two messages per session and a
slight increase in PgStat_MsgTabstat size (but the same number of table
stats fit).
- Session time computation could overflow on systems where long is 32 bit.
Reported-By: Andres Freund <andres@anarazel.de>
Author: Andres Freund <andres@anarazel.de>
Author: Laurenz Albe <laurenz.albe@cybertec.at>
Discussion: https://postgr.es/m/20210801205501.nyxzxoelqoo4x2qc%40alap3.anarazel.de
Backpatch: 14-, where the feature was introduced.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 82d22e4eed7..489e27f99ae 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4116,6 +4116,8 @@ PostgresMain(int argc, char *argv[], if (IsUnderPostmaster && Log_disconnections) on_proc_exit(log_disconnections, 0); + pgstat_report_connect(MyDatabaseId); + /* Perform initialization specific to a WAL sender process. */ if (am_walsender) InitWalSender(); |