Re: Avoiding duplicates (or at least marking them as such) in a "cumulative" transaction table.

From: Allan Kamau <kamauallan(at)gmail(dot)com>
To: Postgres General Postgres General <pgsql-general(at)postgresql(dot)org>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Subject: Re: Avoiding duplicates (or at least marking them as such) in a "cumulative" transaction table.
Date: 2010-03-08 06:31:19
Message-ID: ab1ea6541003072231n25c49ab8m4ea1f1c83621662e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 8, 2010 at 5:49 AM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:
> On Sun, Mar 7, 2010 at 1:45 AM, Allan Kamau <kamauallan(at)gmail(dot)com> wrote:
>> Hi,
>> I am looking for an efficient and effective solution to eliminate
>> duplicates in a continuously updated "cumulative" transaction table
>> (no deletions are envisioned as all non-redundant records are
>> important). Below is my situation.
>
> Is there a reason you can't use a unique index and detect failed
> inserts and reject them?
>

I think it would have been possible make use of a unique index as you
have suggested, and silently trap the uniqueness violation.

But in my case (as pointed out in my previous lengthy mail) I am
inserting multiple records at once, which implicitly means a single
transaction. I think in this scenario a violation of uniqueness by
even a single record will lead to all the other records (in this
batch) being rejected either.

Is there perhaps a way to only single out the unique constraint
violating record(s) without having to perform individual record
inserts, I am following the example found here
"http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING".

Allan.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben Chobot 2010-03-08 06:58:19 obsessive-compulsive vacuum behavior
Previous Message Devrim GÜNDÜZ 2010-03-08 06:07:02 Re: [NOVICE] How to read oracle table's data from postgre