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 00E4FD1E2D7 for ; Tue, 16 Mar 2004 13:58:32 +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 77214-02 for ; Tue, 16 Mar 2004 09:58:33 -0400 (AST) Received: from firecrest.mail.pas.earthlink.net (firecrest.mail.pas.earthlink.net [207.217.121.247]) by svr1.postgresql.org (Postfix) with ESMTP id 3D6C4D1E2CD for ; Tue, 16 Mar 2004 09:58:30 -0400 (AST) Received: from c-24-99-33-22.atl.client2.attbi.com ([24.99.33.22] helo=SUNFLY) by firecrest.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1B3F5W-0007jD-00 for pgsql-sql@postgresql.org; Tue, 16 Mar 2004 05:58:34 -0800 From: "Luis P Caamano" To: Subject: Can statement_timeout emulated NOWAIT? Date: Tue, 16 Mar 2004 08:58:32 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 In-Reply-To: X-ELNK-Trace: c89b1cbb1e3324b89c7f779228e2f6aeda0071232e20db4d2267b30ca3285d55f0d50c94e9004a87350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/173 X-Sequence-Number: 17272 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