Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 403F7475461 for ; Fri, 22 Feb 2002 19:51:31 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g1N0pRS21968; Fri, 22 Feb 2002 19:51:27 -0500 (EST) To: Brian McCane Cc: PostgreSQL Subject: Re: Strange locking behaviour In-reply-to: <20020222125330.B18565-100000@fw.mccons.net> References: <20020222125330.B18565-100000@fw.mccons.net> Comments: In-reply-to Brian McCane message dated "Fri, 22 Feb 2002 13:10:43 -0600" Date: Fri, 22 Feb 2002 19:51:26 -0500 Message-ID: <21965.1014425486@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200202/310 X-Sequence-Number: 3463 Brian McCane writes: > BEGIN WORK ; > SELECT stockid FROM stocks WHERE ticker = 'M$FT' FOR UPDATE ; > UPDATE stocks SET nextupdate = NOW + INTERVAL '1 DAY' ; > ....Insert 7 years of stock data.... > UPDATE stocks SET nextupdate = NOW() ; > COMMIT WORK ; What exactly does the "Insert" step do? Why are you bothering to UPDATE stocks.nextupdate twice in this transaction? It's not like any other transaction will be able to see the now + 1 day setting. Do you really mean to update *all* rows of stocks here? > The program that gets the 5 minute updates does: > SELECT stockid FROM stocks WHERE nextupdate <= NOW() ; > -- and for each stockid it finds above > BEGIN WORK ; > ....Insert new data... > COMMIT WORK ; Again, what exactly does the "Insert" step do? Does it change stocks.nextupdate? (One would hope so, else there's a tight loop here.) If it does, won't it block at that point waiting for the other transaction's updates to be committed? regards, tom lane