Re: Inserting a timed delay in a pl/pgsql procedure

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Benjamin Krajmalnik <kraj(at)illumen(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Inserting a timed delay in a pl/pgsql procedure
Date: 2006-08-18 19:50:02
Message-ID: C9CA00EE-2ACB-4A86-AD84-EEA4E3198322@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


On Aug 18, 2006, at 3:26 PM, Benjamin Krajmalnik wrote:

> However, it appears that current_timestamp is not being recalculated.
> Any ideas? While normally we want the stored procedures to run as
> quickly as possible, this is a case where I need to insert a delay.
> I guess an option would be to place a counter and loop through it, but
> it does not allow me the control I relly need.

current_timestamp returns the same value for the scope of the
transaction (or function call). Search the archives for "sleep" for
previous discussions of this issue. You can use timeofday to get a
changing time value, but any looping you do in plpgsql will eat a lot
of CPU cycles. The only other solution I recall was to use a
different pl language like perl which has a proper sleep function.

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Bruno Wolff III 2006-08-18 19:52:21 Re: Restoring database question..
Previous Message Benjamin Krajmalnik 2006-08-18 19:26:24 Inserting a timed delay in a pl/pgsql procedure