pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Can statement_timeout emulated NOWAIT?
4+ messages / 3 participants
[nested] [flat]

* Can statement_timeout emulated NOWAIT?
@ 2004-03-16 13:58  Luis P Caamano <lcaamano@mindspring.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Luis P Caamano @ 2004-03-16 13:58 UTC (permalink / raw)
  To: pgsql-sql


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
    



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Can statement_timeout emulated NOWAIT?
@ 2004-03-16 15:48  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Luis P Caamano <lcaamano@mindspring.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2004-03-16 15:48 UTC (permalink / raw)
  To: Luis P Caamano <lcaamano@mindspring.com>; +Cc: pgsql-sql

"Luis P Caamano" <lcaamano@mindspring.com> writes:
> 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

Yes.

> - SELECT ... FOR UPDATE NOWAIT is in the TODO list (among other
>   NOWAIT commands) but it will also be available in 7.5

I haven't seen anyone working on that.

> - 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.

Yes, if you are sure you know how long the select "ought" to take.

> - The error raised by statement_timeout and NOWAIT will be the
>   same.

Wouldn't expect so.  (Right now, I think statement_timeout reports
the same error code as query cancel, which is pretty bogus also.)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Can statement_timeout emulated NOWAIT?
@ 2004-03-16 15:56  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Luis P Caamano <lcaamano@mindspring.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2004-03-16 15:56 UTC (permalink / raw)
  To: Luis P Caamano <lcaamano@mindspring.com>; +Cc: pgsql-sql


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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Can statement_timeout emulated NOWAIT?
@ 2004-03-16 16:33  Luis P Caamano <lcaamano@mindspring.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Luis P Caamano @ 2004-03-16 16:33 UTC (permalink / raw)
  To: pgsql-sql

Excellent! Thanks for your prompt replies.

--
Luis P Caamano
Atlanta, GA, USA





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-03-16 16:33 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-03-16 13:58 Can statement_timeout emulated NOWAIT? Luis P Caamano <lcaamano@mindspring.com>
2004-03-16 15:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-03-16 16:33   ` Luis P Caamano <lcaamano@mindspring.com>
2004-03-16 15:56 ` Bruce Momjian <pgman@candle.pha.pa.us>

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