X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id B127E9FB227 for ; Fri, 18 Aug 2006 16:54:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 86155-02-2 for ; Fri, 18 Aug 2006 16:52:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from a2s5.a2hosting.com (host-209-124-50-10.a2webhosting.com [209.124.50.10]) by postgresql.org (Postfix) with ESMTP id 7F98C9FB3EA for ; Fri, 18 Aug 2006 16:50:55 -0300 (ADT) Received: from adsl-6-63-167.tys.bellsouth.net ([65.6.63.167] helo=[192.168.1.10]) by a2s5.a2hosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.52) id 1GEAMm-0003g0-Sr; Fri, 18 Aug 2006 15:50:53 -0400 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: Inserting a timed delay in a pl/pgsql procedure Date: Fri, 18 Aug 2006 15:50:02 -0400 To: Benjamin Krajmalnik X-Mailer: Apple Mail (2.752.2) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s5.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: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.191 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/226 X-Sequence-Number: 22769 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