4 ms·
What I wound up doing in a case like this was dump (using copy) into a temp table, then run a sql function on the data. That way, you get it done in as few roun
by wiredfool 14y ago
What I wound up doing in a case like this was dump (using copy) into a temp table, then run a sql function on the data. That way, you get it done in as few round trips as possible, essentially 3 statements (create temp table, copy, select dostuff()). The database is real fast about doing what it needs to do when you give it one big block of stuff to work with.
And, if you've got a serial column, you're going go have a primary key/uniqueness constraint on it. Retrying that when it fails at interesting times is going to cost far more time and brain cells than letting the db do it.