Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id C81642E2FD0 for ; Wed, 28 Nov 2007 16:33:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 73153-05 for ; Wed, 28 Nov 2007 16:33:10 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 157B52E2F47 for ; Wed, 28 Nov 2007 16:33:08 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id lASKX7hi020831; Wed, 28 Nov 2007 15:33:07 -0500 (EST) To: "Daniel Caune" cc: pgsql-sql@postgresql.org Subject: Re: Strang behaviour SELECT ... LIMIT n FOR UPDATE In-reply-to: <1E293D3FF63A3740B10AD5AAD88535D2068A67DD@UBIMAIL1.ubisoft.org> References: <1E293D3FF63A3740B10AD5AAD88535D2068A67DD@UBIMAIL1.ubisoft.org> Comments: In-reply-to "Daniel Caune" message dated "Wed, 28 Nov 2007 14:50:55 -0500" Date: Wed, 28 Nov 2007 15:33:07 -0500 Message-ID: <20830.1196281987@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/146 X-Sequence-Number: 29674 "Daniel Caune" writes: > I did the following test, removing all the where-clause from the SELECT statement. Every statement completes immediately, i.e. it doesn't block. I think you left out some critical information, like who else was doing what to the table. What it looks like to me is that the third and fourth rows in this view were live according to your transaction snapshot, but were committed dead as of current time, and so FOR UPDATE wouldn't return them. > agoratokens=> select id from "Tokens" where id IN (47, 104, 44, 42) limit 3 for update; > This time, the statement returns the row where id equals to 44. No, it returns *some* row where id equals 44. Not necessarily the same one seen in the seqscan. (I imagine this query is using an index, and so would visit rows in a different physical order.) Printing the ctid of the rows would confirm or disprove that theory. regards, tom lane