Re: pg_stat_activity.query empty

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Robert Lichtenberger <r(dot)lichtenberger(at)synedra(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_stat_activity.query empty
Date: 2022-04-26 14:47:19
Message-ID: CAB8KJ=hrMQmw5uMd1OSh7aAyX_GVtYjudpFN9Pu=avtHXyKxfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2022年4月26日(火) 23:24 Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>:
>
> On Tue, 2022-04-26 at 06:59 -0700, David G. Johnston wrote:
> > On Tue, Apr 26, 2022 at 6:55 AM Robert Lichtenberger <r(dot)lichtenberger(at)synedra(dot)com> wrote:
> > > When executing "SELECT * FROM pg_stat_activity" I get lots of rows that
> > > have an empty "query" column.
> > >
> > > According to [1] this column should contain the "Text of this backend's
> > > most recent query", either a query that is currently running or the last
> > > query that was executed.
> > >
> > > So how comes that a lot of the rows in pg_stat_activity have an empty
> > > "query"?
> > >
> > > https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW
> >
> > They've never executed a query. Probably due to connection pooling opening connections for the pool but never needing to hand them out.
>
> An alternative option is that the last query sent was an empty string.

Or it's the kind of backend which doesn't normally execute queries.

epp=# SELECT backend_type FROM pg_stat_activity WHERE query = '';
backend_type
------------------------------
autovacuum launcher
pglogical supervisor
logical replication launcher
pglogical manager 16389
background writer
checkpointer
walwriter
(7 rows)

Regards

Ian Barwick

--
EnterpriseDB: https://www.enterprisedb.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message alias 2022-04-26 16:43:43 row level security on conflict do update
Previous Message Laurenz Albe 2022-04-26 14:24:12 Re: pg_stat_activity.query empty