-
+
Routine Database Maintenance Tasks
- linkend="sql-vacuum">) command has to run on a regular basis for several
- reasons:
+ command has to run on
+ a regular basis for several reasons:
- Fortunately, autovacuum () monitors table
+ Fortunately,
+ monitors table
activity and performs VACUUMs when necessary.
Autovacuum works dynamically so it is often better
administration-scheduled vacuuming.
- Fortunately, autovacuum () monitors table
+ Fortunately,
+ monitors table
activity and performs VACUUMs when necessary. This
eliminates the need for administrators to worry about disk space
recovery in all but the most unusual cases.
The
PostgreSQL query planner relies on
statistical information about the contents of tables in order to
generate good plans for queries. These statistics are gathered by
- the ANALYZE> command, which can be invoked by itself or
+ the command,
+ which can be invoked by itself or
as an optional step in VACUUM>. It is important to have
reasonably accurate statistics, otherwise poor choices of plans might
degrade database performance.
- Fortunately, autovacuum () monitors table
+ Fortunately,
+ monitors table
activity and performs ANALYZEs when necessary. This
eliminates the need for administrators to manually schedule
ANALYZE.
when it was last vacuumed.
If it were to go unvacuumed for longer than that,
data loss could result. To ensure that this does not
- happen, the autovacuum> facility described in
- is invoked on any table
+ happen,
+ is invoked on any table
that might contain XIDs older than the age specified by the
configuration parameter
. (This will happen
Notes
- It is a good idea to run ANALYZE periodically, or
+ In the default
PostgreSQL configuration,
+
+ takes care of automatic analyzing of tables when they are first loaded
+ with data, and as they change throughout regular operation.
+ When autovacuum is disabled,
+ it is a good idea to run ANALYZE periodically, or
just after making major changes in the contents of a table. Accurate
statistics will help the planner to choose the most appropriate query
plan, and thereby improve the speed of query processing. A common
- Unlike VACUUM FULL, ANALYZE
+ ANALYZE
requires only a read lock on the target table, so it can run in
parallel with other activity on the table.
There is no ANALYZE statement in the SQL standard.
+
+
+
See Also
+
+
+
+
+
+
+
+