pg_stat_get_backend_activity_start()

A function reporting the time a backend's most recent query was started.

pg_stat_get_backend_activity_start() is a system function reporting the time when the specified backend's most recent query was started.

pg_stat_get_backend_activity_start() was added in PostgreSQL 7.4.

Usage

pg_stat_get_backend_activity_start ( integer ) → timestamp with time zone

The backend is specified by a backend ID number reported by pg_stat_get_backend_idset(); see below for an execution example.

The value returned by pg_stat_get_backend_activity_start() corresponds to the column query_start in pg_stat_activity.

The following related functions are also available:

Change history

Examples

Basic execution example for pg_stat_get_backend_activity_start():

postgres=# SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
                  pg_stat_get_backend_activity_start(s.backendid) AS query_start
             FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;
  pid  |          query_start
-------+-------------------------------
 23529 |
 23532 |
 18419 | 2021-07-20 04:29:24.54157+02
  6177 |
 18474 | 2021-07-20 04:26:35.539942+02
 18427 | 2021-07-20 04:29:23.355595+02
 18488 | 2021-07-20 04:27:18.906881+02
 18185 | 2021-07-20 04:21:58.292271+02
 16549 | 2021-07-20 03:38:12.636572+02
 18489 | 2021-07-20 04:29:23.968442+02
 18546 | 2021-07-20 04:29:26.69587+02
 18359 | 2021-07-20 04:27:32.220973+02
 18362 | 2021-07-20 04:29:06.522822+02
  6233 |
 18566 | 2021-07-20 04:29:49.440485+02
 23527 |
 23526 |
 23528 |
(18 rows)

Categories

System function

See also

pg_stat_activity