I am trying to populate postgres table from another table, nearly about 24 millions records. but query become too slow it taking 9-10 hours. the update operation only update 1-2 row each second. i cant understand why it slow.
Current benchmark
- Query =
INSERT INTO .... SELECT FROM .... ON CONFLICT DO UPDATE - Source table has
24 Millionrecords - Destination Already have
560 Millionsrecords withindexes,unique keys,primary and foreign keys
Query(Sample)
INSERT INTO destination_tbl(col1, col2 .... , col22, false AS processed, null AS updated_at)
SELECT (col1, col2 .... , col22) FROM source_tbl
WHERE processed=false
ON CONFLICT (unique_cols...)
DO UPDATE
SET col1 = EXCLUDED.col1
....
col22 = EXCLUDED.col22
processed = false
updated_at = now()
