From: | Don Drake <dondrake(at)gmail(dot)com> |
---|---|
To: | John DeSoi <desoi(at)pgedit(dot)com> |
Cc: | Guido Barosio <gbarosio(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org |
Subject: | Re: sleep? |
Date: | 2005-08-22 13:34:29 |
Message-ID: | 6c21003b05082206341411de2d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Thanks for all of the replies. I recompiled my DB with plperlu and am using
perl's sleep function.
I agree that a basic function (non-CPU intensive sleep) like this should be
built in.
Thanks again.
-Don
On 8/21/05, John DeSoi <desoi(at)pgedit(dot)com> wrote:
>
>
> On Aug 21, 2005, at 5:09 PM, Guido Barosio wrote:
>
> > Don't know about such thing, but I guess that a plpgsql function
> > could help using datetime var's.
> >
> > Just a guess, don't know if the optimal solution.
>
>
> Yes, you can write one in plpgsql using timeofday, but it is horribly
> inefficient wastes CPU cycles busy looping. I use the version below
> for some simple testing, but it is not useful for a production
> system. It would be nice to have a sleep function that does not
> require anything beyond plpgsql.
>
>
> John DeSoi, Ph.D.
> http://pgedit.com/
> Power Tools for PostgreSQL
>
>
>
> create or replace function sleep (integer) returns time as '
> declare
> seconds alias for $1;
> later time;
> thetime time;
> begin
> thetime := timeofday()::timestamp;
> later := thetime + (seconds::text || '' seconds'')::interval;
> loop
> if thetime >= later then
> exit;
> else
> thetime := timeofday()::timestamp;
> end if;
> end loop;
>
> return later;
> end;
> ' language plpgsql;
>
--
Donald Drake
President
Drake Consulting
http://www.drakeconsult.com/
http://www.MailLaunder.com/
http://www.mobilemeridian.com/
312-560-1574
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-08-22 14:01:33 | Re: sleep? |
Previous Message | Sean Chittenden | 2005-08-22 06:51:49 | Corrupted data, best course of repair? |