Re: Is the pg_locks been used?

From: Neil Conway <neilc(at)samurai(dot)com>
To: Carlos Henrique Reimer <carlosreimer(at)yahoo(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is the pg_locks been used?
Date: 2006-02-26 08:37:38
Message-ID: 1140943058.8830.164.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Uwe C. Schroeder 2006-02-26 08:54:57 Re: Wish: remove ancient constructs from Postgres
Previous Message Andrus Moor 2006-02-26 08:36:23 Wish: remove ancient constructs from Postgres