diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-30 03:23:49 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-30 03:23:49 +0000 |
commit | 957d08c81f9cc277725c83b9381c5154b6318a5e (patch) | |
tree | 1c665d6e63c2cb02156df44a3519d2a0bebcaea3 /src/backend/commands/analyze.c | |
parent | 57b82bf324285464783796e5614d5f9aadd0817f (diff) | |
download | postgresql-957d08c81f9cc277725c83b9381c5154b6318a5e.tar.gz postgresql-957d08c81f9cc277725c83b9381c5154b6318a5e.zip |
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.
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r-- | src/backend/commands/analyze.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 700137ec247..2754a6db6a2 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.106 2007/04/19 16:26:44 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.107 2007/04/30 03:23:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -468,29 +468,15 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* Log the action if appropriate */ if (IsAutoVacuumWorkerProcess() && Log_autovacuum >= 0) { - long diff = 0L; - - if (Log_autovacuum > 0) - { - TimestampTz endtime; - int usecs; - long secs; - - endtime = GetCurrentTimestamp(); - TimestampDifference(starttime, endtime, &secs, &usecs); - - diff = secs * 1000 + usecs / 1000; - } - - if (Log_autovacuum == 0 || diff >= Log_autovacuum) - { + if (Log_autovacuum == 0 || + TimestampDifferenceExceeds(starttime, GetCurrentTimestamp(), + Log_autovacuum)) ereport(LOG, (errmsg("automatic analyze of table \"%s.%s.%s\" system usage: %s", get_database_name(MyDatabaseId), get_namespace_name(RelationGetNamespace(onerel)), RelationGetRelationName(onerel), pg_rusage_show(&ru0)))); - } } } |