in reply to Matching alphabetic diacritics with Perl and Postgresql
Aside from using dynamic SQL and incurring its ills, running a query to check for duplicates when the actual insertion will be another query, allows a duplicate to be inserted between the two statements, unless the table is locked. Hence, it is generally recommended to use an atomic statement, that is, insert into...where not exists(); This guarantees the record is not there at the time of insertion itself.
Also, if you have a CSV file with millions of records, it would likely be best to import the data using something like COPY, and either put it directly into the table you want, or use a staging table with no constraints, and then a simple insert into target(cola, colb, ...) select cola, colb, ... from staging where not exists(select * from target...).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching alphabetic diacritics with Perl and Postgresql
by anonymized user 468275 (Curate) on Jun 03, 2017 at 19:36 UTC | |
by chacham (Prior) on Jun 03, 2017 at 20:03 UTC | |
by anonymized user 468275 (Curate) on Jun 03, 2017 at 23:56 UTC | |
by chacham (Prior) on Jun 04, 2017 at 03:33 UTC | |
by marinersk (Priest) on Jun 04, 2017 at 10:19 UTC | |
by anonymized user 468275 (Curate) on Jun 04, 2017 at 11:18 UTC | |
|