Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 73C749F9C35; Wed, 6 Dec 2006 09:46:10 -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 73108-09; Wed, 6 Dec 2006 09:45:55 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from svana.org (unknown [125.62.87.134]) by postgresql.org (Postfix) with ESMTP id 7173B9F93E5; Wed, 6 Dec 2006 09:46:00 -0400 (AST) Received: from kleptog by svana.org with local (Exim 4.50) id 1Grx5T-00047C-Ed; Thu, 07 Dec 2006 00:45:27 +1100 Date: Wed, 6 Dec 2006 14:45:27 +0100 From: Martijn van Oosterhout To: Dave Cramer Cc: Jens Schipkowski , Joost Kraaijeveld , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] Locking in PostgreSQL? Message-ID: <20061206134527.GA11211@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: Dave Cramer , Jens Schipkowski , Joost Kraaijeveld , pgsql-general@postgresql.org, pgsql-performance@postgresql.org References: <1165388652.6396.1.camel@panoramix> <30BD1C9A-1664-4290-B343-0FB1FEBA7B53@fastcrypt.com> <4ED560E4-3484-43BA-99BB-18888D968F74@fastcrypt.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="y0ulUmNC+osPPQO6" Content-Disposition: inline In-Reply-To: <4ED560E4-3484-43BA-99BB-18888D968F74@fastcrypt.com> X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 X-PGP-Key-URL: User-Agent: Mutt/1.5.9i X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: kleptog@svana.org X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/258 X-Sequence-Number: 105197 --y0ulUmNC+osPPQO6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 06, 2006 at 08:26:45AM -0500, Dave Cramer wrote: > >>Unless you specifically ask for it postgresql doesn't lock any =20 > >>rows when you update data. > >> > >Thats not right. UPDATE will force a RowExclusiveLock to rows =20 > >matching the WHERE clause, or all if no one is specified. >=20 > Apparently I've completely misunderstood MVCC then.... My =20 > understanding is that unless you do a select ... for update then =20 > update the rows will not be locked . I think it comes down to what you mean by RowExclusiveLock. In MVCC, writers don't block readers, so even if someone executes an update on a row, readers (SELECT statements) will not be blocked. So it's not a lock as such, more a "I've updated this row, go find the new version if that's appropriate for your snapshot". Have a nice day, --=20 Martijn van Oosterhout http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to l= itigate. --y0ulUmNC+osPPQO6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFFdsl3IB7bNG8LQkwRAnwWAKCDKqlHPYIVPoo5n8LcIR1jXewWjwCfbu/8 Wt5bWPvcWOy16oESM/dGgTY= =53TX -----END PGP SIGNATURE----- --y0ulUmNC+osPPQO6--