mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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.
This commit is contained in:
@ -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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user