Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 5116E9F9C35 for ; Wed, 6 Dec 2006 09:27:00 -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 70736-06 for ; Wed, 6 Dec 2006 09:26:36 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id 9B8F19F93E5 for ; Wed, 6 Dec 2006 09:26:41 -0400 (AST) Received: (qmail 15006 invoked from network); 6 Dec 2006 13:26:40 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.14?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 6 Dec 2006 13:26:40 -0000 In-Reply-To: References: <1165388652.6396.1.camel@panoramix> <30BD1C9A-1664-4290-B343-0FB1FEBA7B53@fastcrypt.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <4ED560E4-3484-43BA-99BB-18888D968F74@fastcrypt.com> Cc: "Joost Kraaijeveld" , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: [PERFORM] Locking in PostgreSQL? Date: Wed, 6 Dec 2006 08:26:45 -0500 To: Jens Schipkowski X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/256 X-Sequence-Number: 105195 On 6-Dec-06, at 8:20 AM, Jens Schipkowski wrote: > 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). Apparently I've completely misunderstood MVCC then.... My understanding is that unless you do a select ... for update then update the rows will not be locked . Dave > >> 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 > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings >