How can I tell if PostgreSQL's Autovacuum is running on UNIX?

前端 未结 3 1714
鱼传尺愫
鱼传尺愫 2021-02-06 20:55

How can one tell if the autovacuum daemon in Postgres 9.x is running and maintaining the database cluster?

3条回答
  •  暖寄归人
    2021-02-06 21:13

    I'm using:

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

    in collectd to know how many autovacuum are running concurrently.

    You may need to create a security function like this:

    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;
    

    and call that from collectd.

    In earlier Postgres, "query" was "current_query" so change it according to what works.

提交回复
热议问题