pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luis P Caamano <lcaamano@mindspring.com>
To: pgsql-sql@postgresql.org
Subject: Can statement_timeout emulated NOWAIT?
Date: Tue, 16 Mar 2004 08:58:32 -0500
Message-ID: <DIEAJDKECNMGBBCLCGFFAEHPCGAA.lcaamano@mindspring.com> (raw)
In-Reply-To: <DIEAJDKECNMGBBCLCGFFIEHNCGAA.lcaamano@mindspring.com>


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
    



view thread (4+ messages)  latest in thread

Message-ID: <DIEAJDKECNMGBBCLCGFFAEHPCGAA.lcaamano@mindspring.com>
Permalink:  ../DIEAJDKECNMGBBCLCGFFAEHPCGAA.lcaamano@mindspring.com/
Also on:    postgresql.org/message-id/DIEAJDKECNMGBBCLCGFFAEHPCGAA.lcaamano@mindspring.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lcaamano@mindspring.com
  Subject: Re: Can statement_timeout emulated NOWAIT?
  In-Reply-To: <DIEAJDKECNMGBBCLCGFFAEHPCGAA.lcaamano@mindspring.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox