Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6A065B5DCC6 for ; Thu, 3 Nov 2011 20:45:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 04406-04 for ; Thu, 3 Nov 2011 23:45:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 45021B5DCC2 for ; Thu, 3 Nov 2011 20:45:46 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pA3NjkjN019909; Thu, 3 Nov 2011 19:45:46 -0400 (EDT) To: Claudio Freire cc: postgres performance list Subject: Re: Blocking excessively in FOR UPDATE In-reply-to: References: <6734.1320345936@sss.pgh.pa.us> Comments: In-reply-to Claudio Freire message dated "Thu, 03 Nov 2011 16:53:41 -0300" Date: Thu, 03 Nov 2011 19:45:46 -0400 Message-ID: <19908.1320363946@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/72 X-Sequence-Number: 45583 Claudio Freire writes: > On Thu, Nov 3, 2011 at 4:29 PM, Claudio Freire wrote: >> Next time I find it blocking, I will check pg_locks directly and post >> the output. > Here it is, two instances of the query, while blocked: Hmm ... definitely seems that you're not blocked on a FOR UPDATE tuple lock. If you were, there'd be an ungranted ShareLock on a transactionid in there. It seems possible that you're blocked on an LWLock, which would not show in pg_locks. But before pursuing that idea, probably first you should back up and confirm whether the process is actually waiting, or running, or just really slow due to CPU contention. It might be useful to see what strace has to say about it. regards, tom lane