diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index f87f3e0..0a365a0 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -800,6 +800,14 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu + Autovacuum detects orphaned temporary tables that could be left behind + by a crashed backend, and forcibly drops them. In the event of a backend + crash, looking at the contents of orphaned temporary tables to perform + some research on their contents is possible though it is advised to + set autovacuum to off before doing so. + + + The default thresholds and scale factors are taken from postgresql.conf, but it is possible to override them (and many other autovacuum control parameters) on a per-table basis; see diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index e3a6911..3a0f4a8 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -2037,34 +2037,21 @@ do_autovacuum(void) /* We just ignore it if the owning backend is still active */ if (backendID == MyBackendId || BackendIdGetProc(backendID) == NULL) { + ObjectAddress object; + /* - * We found an orphan temp table (which was probably left - * behind by a crashed backend). If it's so old as to need - * vacuum for wraparound, forcibly drop it. Otherwise just - * log a complaint. + * We found an orphan temp table which was probably left + * behind by a crashed backend, so forcibly drop it. */ - if (wraparound) - { - ObjectAddress object; - - ereport(LOG, - (errmsg("autovacuum: dropping orphan temp table \"%s\".\"%s\" in database \"%s\"", - get_namespace_name(classForm->relnamespace), - NameStr(classForm->relname), - get_database_name(MyDatabaseId)))); - object.classId = RelationRelationId; - object.objectId = relid; - object.objectSubId = 0; - performDeletion(&object, DROP_CASCADE, PERFORM_DELETION_INTERNAL); - } - else - { - ereport(LOG, - (errmsg("autovacuum: found orphan temp table \"%s\".\"%s\" in database \"%s\"", - get_namespace_name(classForm->relnamespace), - NameStr(classForm->relname), - get_database_name(MyDatabaseId)))); - } + ereport(LOG, + (errmsg("autovacuum: dropping orphan temp table \"%s\".\"%s\" in database \"%s\"", + get_namespace_name(classForm->relnamespace), + NameStr(classForm->relname), + get_database_name(MyDatabaseId)))); + object.classId = RelationRelationId; + object.objectId = relid; + object.objectSubId = 0; + performDeletion(&object, DROP_CASCADE, PERFORM_DELETION_INTERNAL); } } else