X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 65D929FA326 for ; Sun, 28 May 2006 10:11:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 17477-02 for ; Sun, 28 May 2006 10:11:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by postgresql.org (Postfix) with ESMTP id 483BA9F9F3D for ; Sun, 28 May 2006 10:11:28 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1FkL3B-0005YG-00; Sun, 28 May 2006 09:11:21 -0400 To: Brendan Duddridge Cc: PostgreSQL Performance Subject: Re: App very unresponsive while performing simple update References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> In-Reply-To: <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 May 2006 09:11:21 -0400 Message-ID: <874pzanvk6.fsf@stark.xeocode.com> Lines: 34 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/504 X-Sequence-Number: 19291 Brendan Duddridge writes: > Further to my issue, the update never did finish. I received the following > message in psql: > > ssprod=# update product set is_hungry = 'true' where date_modified > > current_date - 10; > ERROR: deadlock detected > DETAIL: Process 18778 waits for ShareLock on transaction 711698780; blocked > by process 15784. > Process 15784 waits for ShareLock on transaction 711697098; blocked by process > 18778. What queries are those two processes executing? And what foreign keys do you have on the product table or elsewhere referring to the product table? And what indexes do you have on those columns? I think this indicates you have foreign keys causing the deadlock. One process is waiting until an update elsewhere finishes before modifying a record that other update refers to via a foreign key. But that other process is waiting similarly for the first one. Do you have any foreign keys in other tables referring to the product table? Do you have indexes on those other tables? The update needs to check those other tables to make sure there are no references to the records you're updating. If there's no index it has to do a sequential scan. To get a deadlock I think you would need another update running somewhere though. -- greg