Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id F3BE09FB596 for ; Mon, 30 Jul 2007 23:20:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 52419-07 for ; Mon, 30 Jul 2007 23:20:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id C97FF9FB544 for ; Mon, 30 Jul 2007 23:20:49 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id l6V2Kj9c067851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 30 Jul 2007 20:20:47 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.14.1/8.14.1) with ESMTP id l6V2Kio2024152; Mon, 30 Jul 2007 20:20:44 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.14.1/8.14.1/Submit) id l6V2Kie7024151; Mon, 30 Jul 2007 20:20:44 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 30 Jul 2007 20:20:44 -0600 From: Michael Fuhr To: "Milen A. Radev" Cc: pgsql-admin@postgresql.org Subject: Re: Lock Statistics Message-ID: <20070731022044.GB23999@winnie.fuhr.org> References: <32c009ea0707300911h74f588f6se7d03f5f28d598e5@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32c009ea0707300911h74f588f6se7d03f5f28d598e5@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/342 X-Sequence-Number: 26323 On Mon, Jul 30, 2007 at 07:11:11PM +0300, Milen A. Radev 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). Why do you suspect that locks are the problem? Unless the queries are making concurrent updates of the same row(s) locking isn't likely to be the problem due to the way MVCC works. Could you post one of the slow queries along with the EXPLAIN ANALYZE output? Are you vacuuming and analyzing your tables regularly? What version of PostgreSQL are you running? PostgreSQL 8.3 will have a log_lock_waits configuration setting to log locks that wait longer than deadlock_timeout but that doesn't help you now unless you're able and willing to run tests in a version of PostgreSQL that's still under development (don't use it for anything you wouldn't want to lose). -- Michael Fuhr