X-Original-To: pgsql-general-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 5C9EE9FB3A9 for ; Wed, 6 Sep 2006 19:03:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 74398-03-3 for ; Wed, 6 Sep 2006 22:03:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from servata.com (ip-216-152-249-241.servata.com [216.152.249.241]) by postgresql.org (Postfix) with ESMTP id F35B89FB3E1 for ; Wed, 6 Sep 2006 19:03:27 -0300 (ADT) Received: from [209.162.219.253] (helo=dogma.v10.wvs) by servata.com with esmtpa (Exim 4.50) id 1GL5UJ-0004Bv-6k; Wed, 06 Sep 2006 15:03:15 -0700 Subject: Re: Asynchronous trigger From: Jeff Davis To: Jean-Christophe Praud Cc: pgsql-general@postgresql.org In-Reply-To: <44FF3DAE.5050406@praud.com> References: <44FF3DAE.5050406@praud.com> Content-Type: text/plain Date: Wed, 06 Sep 2006 15:03:12 -0700 Message-Id: <1157580192.20589.127.camel@dogma.v10.wvs> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-7) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_HELO_PASS X-Spam-Level: X-Archive-Number: 200609/223 X-Sequence-Number: 100477 On Wed, 2006-09-06 at 23:29 +0200, Jean-Christophe Praud wrote: > Hi all, > > I'm planning to convert an application to postgresql 8.1 (from mysql). > Currently we have some recursive procedures done on the application side > we would want to rewrite as stored pl/pgsql procedures called by triggers... > > Is it possible for these triggers to be asynchronous, in order not to > block the client application during the recursive process ? > You can send the query itself asynchronously using PQsendQuery (for libpq, see your client library's docs for a similar function). That allows your application to continue processing, but doesn't allow you to issue any more queries over that connection. You could make your trigger send a notification to an application that just handles that one task in the background. Regards, Jeff Davis