Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 8E85B9F9C35; Wed, 6 Dec 2006 09:19:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 70359-02; Wed, 6 Dec 2006 09:19:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mailbackup.inode.at (mailbackup.inode.at [213.229.60.24]) by postgresql.org (Postfix) with ESMTP id CA46A9F93E5; Wed, 6 Dec 2006 09:19:51 -0400 (AST) Received: from [62.99.145.4] (port=41307 helo=mx.inode.at) by mailbackup.inode.at with esmtp (Exim 4.62) (envelope-from ) id 1Grwgg-0000gW-B0; Wed, 06 Dec 2006 14:19:50 +0100 Received: from [83.64.182.18] (port=2590 helo=panettone.apus.local) by smartmx-04.inode.at with esmtp (Exim 4.50) id 1GrwgV-00009w-Gk; Wed, 06 Dec 2006 14:19:39 +0100 Received: from xjens.apus.local ([193.1.1.148]) by panettone.apus.local with esmtp (Exim 3.35 #1 (Debian)) id 1GrwgU-00071Z-00; Wed, 06 Dec 2006 14:19:38 +0100 Date: Wed, 06 Dec 2006 14:20:04 +0100 To: "Dave Cramer" , "Joost Kraaijeveld" Subject: Re: [PERFORM] Locking in PostgreSQL? From: "Jens Schipkowski" Organization: APUS Software GmbH Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <1165388652.6396.1.camel@panoramix> <30BD1C9A-1664-4290-B343-0FB1FEBA7B53@fastcrypt.com> Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <30BD1C9A-1664-4290-B343-0FB1FEBA7B53@fastcrypt.com> User-Agent: Opera Mail/9.02 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.186 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200612/254 X-Sequence-Number: 105193 On Wed, 06 Dec 2006 13:29:37 +0100, Dave Cramer wrote: > Unless you specifically ask for it postgresql doesn't lock any rows when > you update data. > Thats not right. UPDATE will force a RowExclusiveLock to rows matching the WHERE clause, or all if no one is specified. @Joost Kraaijeveld: Yes, because there is no EntryExclusiveLock or something like that. Roughly you can say, each UPDATE statement iterates through the affected table and locks the WHERE clause matching records (rows) exclusivly to prevent data inconsistancy during the UPDATE. After that your rows will be updated and the lock will be repealed. You can see this during an long lasting UPDATE by querying the pg_locks with joined pg_stats_activity (statement must be enabled). > Dave > On 6-Dec-06, at 2:04 AM, Joost Kraaijeveld wrote: > >> Does PostgreSQL lock the entire row in a table if I update only 1 >> column? >> >> >> --Groeten, >> >> Joost Kraaijeveld >> Askesis B.V. >> Molukkenstraat 14 >> 6524NB Nijmegen >> tel: 024-3888063 / 06-51855277 >> fax: 024-3608416 >> web: www.askesis.nl >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 9: In versions below 8.0, the planner will ignore your desire to >> choose an index scan if your joining column's datatypes do not >> match >> > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match CU, Jens -- ** Jens Schipkowski