如何判断是否 Autovacuum守护程序 在Postgres 9.x中,正在运行和维护数据库群集?

有帮助吗?

解决方案

Postgresql 9.3

确定是否正在运行Autovacuum

这是特定于Unix上的Postgres 9.3。对于Windows,请参阅此 问题.

查询Postgres系统表

SELECT
  schemaname, relname,
  last_vacuum, last_autovacuum,
  vacuum_count, autovacuum_count  -- not available on 9.0 and earlier
FROM pg_stat_user_tables;

GREP系统过程状态

$ ps -axww | grep autovacuum
24352 ??  Ss      1:05.33 postgres: autovacuum launcher process  (postgres)    

Grep Postgres日志

# grep autovacuum /var/log/postgresql
LOG:  autovacuum launcher started
LOG:  autovacuum launcher shutting down

如果您想进一步了解 Autovacuum 活动,设置 log_min_messagesDEBUG1..DEBUG5. 。 SQL命令 VACUUM VERBOSE 将在日志级别输出信息 INFO.


关于Autovacuum守护程序,Posgres Docs国家:

在默认配置中,启用了AutoVacuuming,并适当设置相关配置参数。

也可以看看:

其他提示

我在用着:

select count(*) from pg_stat_activity where query like 'autovacuum:%';

在收集中,知道有多少自动驾驶量同时运行。

您可能需要创建这样的安全函数:

CREATE OR REPLACE FUNCTION public.pg_autovacuum_count() RETURNS bigint
AS 'select count(*) from pg_stat_activity where query like ''autovacuum:%'';'
LANGUAGE SQL
STABLE
SECURITY DEFINER;

并从collectd中称呼它。

在较早的Postgres中,“ Query”为“ Current_Query”,因此根据有效的方法进行更改。

您还可以运行pg_activity以查看数据库上的当前运行查询。无论如何,我通常在大部分时间内都会打开一个终端 非常 有用。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top