X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3B8DBD7246 for ; Sun, 21 Aug 2005 22:44:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39603-06 for ; Mon, 22 Aug 2005 01:44:09 +0000 (GMT) Received: from a2s4.a2hosting.com (a2s4.a2hosting.com [64.9.205.220]) by svr1.postgresql.org (Postfix) with ESMTP id BB310D7273 for ; Sun, 21 Aug 2005 22:44:07 -0300 (ADT) Received: from user-1120fe1.dsl.mindspring.com ([66.32.61.193] helo=[192.168.1.10]) by a2s4.a2hosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.51) id 1E71MB-0005fa-E9; Sun, 21 Aug 2005 21:44:11 -0400 In-Reply-To: References: <6c21003b050821122278e3d7d5@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Don Drake , pgsql-admin@postgresql.org Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: sleep? Date: Sun, 21 Aug 2005 21:43:55 -0400 To: Guido Barosio X-Mailer: Apple Mail (2.733) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s4.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 required=5 tests=[AWL=0.008] X-Spam-Level: X-Archive-Number: 200508/257 X-Sequence-Number: 18576 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;