Re: Check for duplicates before inserting new rows - Mailing list pgsql-general

From Rich Shepard
Subject Re: Check for duplicates before inserting new rows
Date
Msg-id alpine.LNX.2.20.2009040736090.7473@salmo.appl-ecosys.com
Whole thread Raw
In response to Re: Check for duplicates before inserting new rows  (George Woodring <george.woodring@iglass.net>)
List pgsql-general
On Fri, 4 Sep 2020, George Woodring wrote:

> I would suggest creating a temp table based on the original table and
> loading the data into it first. You can then purge the duplicates.

George,

I hadn't thought of this. Using a duplicate table without a PK would work
well if there's only one attribute that needs checking.

In my case there are two tables involved: locations and measurements. So, I
can create a temporary table from the new data which holds only the
locations. I can then isolate the new location rows that do not already
exist in that table, then insert the new data to eliminate the duplicated
measurements.

Thanks,

Rich




pgsql-general by date:

Previous
From: George Woodring
Date:
Subject: Re: Check for duplicates before inserting new rows
Next
From: Tom Lane
Date:
Subject: Re: Bitmap scan seem like such a strange choice when "limit 1"