How to bulk insert only new rows in PostreSQL
问题 I have list of products (3 million items) without IDs - only titles. But I don't know which titles already exist in DB. New products (about 2.9 million items) must be added into DB. After that I must know ID for each products (new and existing). Is there the fastest way to do it in PostgreSQL? I can change DB as needed (add default values, add columns etc.). 回答1: Import data COPY everything to a temporary staging table and insert only new titles into your target table. CREATE TEMP TABLE tmp