Implement rate-limiting logic on how often backends will attempt to send
Tom Lane <tgl@sss.pgh.pa.us>
Implement rate-limiting logic on how often backends will attempt to send messages to the stats collector. This avoids the problem that enabling stats_row_level for autovacuum has a significant overhead for short read-only transactions, as noted by Arjen van der Meijden. We can avoid an extra gettimeofday call by piggybacking on the one done for WAL-logging xact commit or abort (although that doesn't help read-only transactions, since they don't WAL-log anything). In my proposal for this, I noted that we could change the WAL log entries for commit/abort to record full TimestampTz precision, instead of only time_t as at present. That's not done in this patch, but will be committed separately.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xact.c | modified | +33 −4 |
| src/backend/commands/analyze.c | modified | +4 −18 |
| src/backend/commands/vacuumlazy.c | modified | +4 −18 |
| src/backend/postmaster/pgstat.c | modified | +23 −4 |
| src/backend/utils/adt/timestamp.c | modified | +22 −1 |
| src/include/access/xact.h | modified | +2 −1 |
| src/include/utils/timestamp.h | modified | +4 −1 |
| src/test/regress/expected/stats.out | modified | +8 −0 |
| src/test/regress/sql/stats.sql | modified | +4 −0 |