X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0B9E1D1E928 for ; Tue, 16 Mar 2004 15:57:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 09354-09 for ; Tue, 16 Mar 2004 11:57:01 -0400 (AST) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 3F348D1E93E for ; Tue, 16 Mar 2004 11:56:55 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i2GFusW22068; Tue, 16 Mar 2004 10:56:54 -0500 (EST) From: Bruce Momjian Message-Id: <200403161556.i2GFusW22068@candle.pha.pa.us> Subject: Re: Can statement_timeout emulated NOWAIT? In-Reply-To: To: Luis P Caamano Date: Tue, 16 Mar 2004 10:56:54 -0500 (EST) Cc: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/176 X-Sequence-Number: 17275 Yes, I think these are all correct, except I am not positive FOR UPDATE NOWAIT will be in 7.5 unless someone codes it. --------------------------------------------------------------------------- Luis P Caamano wrote: > > I've researched the recent discussions about statement_timeout > and NOWAIT and I'd like to confirm my understanding of the > situation before acting on it. Please let me know if the > following statements are true: > > - LOCK TABLE ... NOWAIT has been checked in and will be available > in 7.5 > > - SELECT ... FOR UPDATE NOWAIT is in the TODO list (among other > NOWAIT commands) but it will also be available in 7.5 > > - Using "SET LOCAL statement_timeout=xxx" can be used before > "SELECT ... FOR UPDATE" to emulate NOWAIT when the select > is simple and involves a relatively small number of rows. > That is, the following: > > BEGIN; > SET LOCAL statement_timeout=3000; > SELECT ... FOR UPDATE; -- (1 row) > COMMIT; > > will be equivalent to: > > BEGIN; > SELECT ... FOR UPDATE NOWAIT; > COMMIT; > > - The NOWAIT feature will be able to handle select-for-updates > that involve many rows better than statement_timeout because > it will track timeouts on a row by row basis, which eliminates > false positives. That is, if the statement_timeout is too > short for the select, it might fail before finishing the select > instead of failing because of locked row. > > - The error raised by statement_timeout and NOWAIT will be the > same. > > Basically, I'd like to write low level code that implements > NOWAIT in the application using statement_timeout. Later on, > 7.5, I'd be able to reimplement the low level functions using > NOWAIT without having to change the higher level code. > > Your thoughts and comments are appreciated. > > Thanks > > Luis P Caamano > Atlanta, GA, USA > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073