Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id A19E99FB50B for ; Wed, 7 Mar 2007 12:26:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 45298-02 for ; Wed, 7 Mar 2007 12:25:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from ex14.myhostedexchange.com (ex14.myhostedexchange.com [69.50.2.20]) by postgresql.org (Postfix) with ESMTP id 196AD9FA38A for ; Wed, 7 Mar 2007 12:25:55 -0400 (AST) Received: from 205.238.79.158 ([205.238.79.158]) by ex14.hostedexchange.local ([69.50.2.20]) with Microsoft Exchange Server HTTP-DAV ; Wed, 7 Mar 2007 16:25:54 +0000 User-Agent: Microsoft-Entourage/11.2.5.060620 Date: Wed, 07 Mar 2007 09:25:51 -0700 Subject: Re: Transaction atomicity From: Jeff Hubbach To: Message-ID: Thread-Topic: [JDBC] Transaction atomicity Thread-Index: Acdg1UVIg48FtczIEdu8EAANk0UQgg== In-Reply-To: <1173283563.20645.53.camel@scarafaggio> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.502 tagged_above=0 required=5 tests=AWL, BAYES_50, RCVD_NUMERIC_HELO X-Spam-Level: * X-Archive-Number: 200703/77 X-Sequence-Number: 16791 On 3/7/07 9:06 AM, "Giuseppe Sacco" wrote: > You are right, but I need different sequences for every user, i.e., if > two users insert on the same table then I need a way to use different > sequence. The reason of this is that I have to split my application into > a few different postgresql instances based in different offices. Every > night all instances synchronise their data (this is and INSERT only > table), so I need a different table sequence in every office (or group > of users or single user). Using select(max(id)) won't work in this case, either (if I'm understanding your setup correctly). So each office has its own postgresql instance. Then every night you copy the data from all offices to all other offices. Therefore, that whole day, inserts were made in each office instance with the same IDs, which will cause duplicate key exceptions. Does each user in each office have their own instance? Why not have a compound key on this table, with an ID generated by a sequence (one sequence, named the same, for each instance of PostgreSQL for each office), and an Office ID that is static for each instance? Then the merge/sync would go through without a hitch. -- Jeff Hubbach