pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: adey <adey11@gmail.com>
To: Milen A. Radev <milen@radev.net>
Cc: pgsql-admin@postgresql.org
Subject: Re: Lock Statistics
Date: Tue, 31 Jul 2007 10:35:25 +1200
Message-ID: <1c66bda80707301535s24e675f4i483b06f91351289e@mail.gmail.com> (raw)
In-Reply-To: <32c009ea0707300911h74f588f6se7d03f5f28d598e5@mail.gmail.com>
References: <32c009ea0707300911h74f588f6se7d03f5f28d598e5@mail.gmail.com>

Try this query for a start, and add system tables to the join to find what
you want:-


-- displays locks with database name and username, but not table

-- CAUTION: this query may impact system performance as you are selecting
from system tables

select

relation

, c.relname

, u.usename

, pid

, mode

, transaction

, granted

, datname

, u.usesysid

, usesuper

--*

from pg_locks l, pg_stat_activity s, pg_user u, pg_class c

where l.pid = s.procpid

and l.relation = c.relfilenode

and s.usesysid = u.usesysid

order by l.pid;



On 7/31/07, Milen A. Radev <milen@radev.net> wrote:
>
> I have performance problems with a DB (slow queries) and I suspect the
> main cause is that a lot of queries wait for a lock on one small
> table. That's why I need some stats about the number and (average)
> wait-time for locks (even only for this particular table).
>
> After a bit of googling I found a project in PgFoundry with a
> promising description - http://pgfoundry.org/projects/pglockdiag/.
> Unfortunately the projects seems stillborn - no published files and
> nothing in CVS.
>
>
> --
> Milen A. Radev
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

view thread (5+ messages)  latest in thread

Message-ID: <1c66bda80707301535s24e675f4i483b06f91351289e@mail.gmail.com>
Permalink:  ../1c66bda80707301535s24e675f4i483b06f91351289e@mail.gmail.com/
Also on:    postgresql.org/message-id/1c66bda80707301535s24e675f4i483b06f91351289e@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: adey11@gmail.com, milen@radev.net
  Subject: Re: Lock Statistics
  In-Reply-To: <1c66bda80707301535s24e675f4i483b06f91351289e@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox