Re: Is the pg_locks been used? - Mailing list pgsql-general

From Neil Conway
Subject Re: Is the pg_locks been used?
Date
Msg-id 1140943058.8830.164.camel@localhost.localdomain
Whole thread Raw
In response to Is the pg_locks been used?  (Carlos Henrique Reimer <carlosreimer@yahoo.com.br>)
List pgsql-general
On Thu, 2006-02-23 at 17:12 -0300, Carlos Henrique Reimer wrote:
> When the pg_locks view is used the internal lock manager data
> structures are momentarily locked and that is why I would like to know
> if some application is reading the pg_locks view and how many times.
>
> Is there a way to discover it?

AFAIK there is no easy way to determine this information. You could
probably patch Postgres to record the info fairly easy: one way would be
to allocate a small block of shared memory and an LWLock to protect it,
and then have pg_lock_status() acquire the lock and increment a counter.
Then add a new function to retrieve the current value of the counter.

You could even do it without modifying the backend proper: change the
definition of the pg_locks view to invoke a set-returning PL/PgSQL
function. That function would increment a counter stored in some table,
and then construct and return the normal pg_locks result set.

-Neil




pgsql-general by date:

Previous
From: "Andrus Moor"
Date:
Subject: Wish: remove ancient constructs from Postgres
Next
From: "Uwe C. Schroeder"
Date:
Subject: Re: Wish: remove ancient constructs from Postgres