Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Server status query problem



Hi Andreas,

It was pointed out to me that the server status lock tab doesn't show data
correctly - specifically, the username is always blank, and the query string
normally shows up as <backend information unavailable>.

It seems the cause is that most of the stats functions don't take a PID as
an argument, but a backend ID between 1 and the current number of backends.

A hacked together replacement query looks like the following, but before I
appy it I just wanted to run it past you and the list in case I missed
anything:

SELECT 
  (SELECT datname FROM pg_database WHERE oid = pgl.database) AS dbname,
  pgl.relation::regclass AS class,
  pg_get_userbyid(pg_stat_get_backend_userid(svrid)) as user,
  pgl.transaction, 
  pg_stat_get_backend_pid(svrid) AS pid,
  pgl.mode, 
  pgl.granted, 
  pg_stat_get_backend_activity(svrid) AS current_query
FROM 
  pg_stat_get_backend_idset() svrid,
  pg_locks pgl 
WHERE 
  pgl.pid = pg_stat_get_backend_pid(svrid)
ORDER BY
  pid;

Regards, Dave 





Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group