Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id B8E179FB4DE for ; Wed, 18 Jul 2007 11:02:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 57807-09 for ; Wed, 18 Jul 2007 11:02:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail3.ecircle.de (mail3.ecircle.de [195.140.186.206]) by postgresql.org (Postfix) with ESMTP id 8BE239FB473 for ; Wed, 18 Jul 2007 11:02:14 -0300 (ADT) Received: from einstein.muc.ecircle.de (einstein.muc.ecircle.de [192.168.1.7]) by mail3.ecircle.de (READY) with ESMTP id 8E79D11C0B7; Wed, 18 Jul 2007 16:02:12 +0200 (CEST) Received: from [192.168.1.91] ([192.168.1.91]) by einstein.muc.ecircle.de with Microsoft SMTPSVC(6.0.3790.1830); Wed, 18 Jul 2007 16:02:12 +0200 Subject: Re: How to use a trigger to write rows to a remote server From: Csaba Nagy To: Michael Dengler Cc: postgres performance list In-Reply-To: References: Content-Type: text/plain Message-Id: <1184767332.10897.6.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 18 Jul 2007 16:02:12 +0200 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Jul 2007 14:02:12.0468 (UTC) FILETIME=[3D2D3340:01C7C944] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/214 X-Sequence-Number: 25898 On Wed, 2007-07-18 at 15:36, Michael Dengler wrote: > Row X is inserted into TableX in DB1 on server1....TableX trigger > function fires and contacts DB2 on server2 and inserts the row into > TableY on server2. This kind of problem is usually solved more robustly by inserting the "change" into a local table and let the remote server (or some external program) poll that periodically, and make the necessary changes to the remote server. This method does not have the problems Heikki mentions in his reply with disconnections and transaction rollbacks, as the external program/remote server will only see committed transactions and it can apply the accumulated changes after connection is recovered in case of failure, without blocking the activity on the "master". This is also covered in a few past posts on the postgres lists (I guess you should look in the "general" list for that), in particular you could be interested in the possibility of notifications if you want your poller to be notified immediately when a change occurs. Cheers, Csaba.