Re: Duplicated records deleting between some secs

From: Guy Flaherty <naoshika(at)gmail(dot)com>
To: Ruzsinszky Attila <ruzsinszky(dot)attila(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Duplicated records deleting between some secs
Date: 2009-06-25 22:46:18
Message-ID: 23d251df0906251546i5d9a7cc1tdcb58387d546a420@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Jun 26, 2009 at 7:38 AM, Ruzsinszky Attila <
ruzsinszky(dot)attila(at)gmail(dot)com> wrote:

> Hi,
>
> As we found there is a bug in my program.
> In some days ago the records arrived duplicated with some secs difference
> in
> timestamp. (the difference can be 0s, too) Not all records are
> duplicated, because
> the problem is the first part of the input stream, so there are
> records which aren't
> duplicated.
>
> How can I delete the records which arrived later?
>
> I would'nt like miss or drop the original records.
>
> TIA,
> Ruzsi
>

It is a little difficult to help you with only this information. How many
records are in your table? What is your primary key structure? Do you need
to delete them whilst the table is 'live', ie. records are constantly being
updated/inserted etc, or can you afford to just fix the records without
having to worry about the table being used for anything else?

You might be able to delete the records by using min(timestamp) to get the
earliest inserted records. You could push these into a temp copy of your
table, truncate the main table and then copy them back in from the temp
table. It would be easier to tell with more information about your data and
table.

Guy Flaherty

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kindra Martinenko 2009-06-26 04:38:50 Re: Problems importing csv files
Previous Message Ruzsinszky Attila 2009-06-25 21:38:07 Duplicated records deleting between some secs