I have this logic that I want to construct a query either with plain SQL or with PL/pgSQL.
So the logic is I have a large set of data, around 100,000 records that I need to upsert into two different tables
I have table_a:
id, col_1, col_2, col_3
id, table_a_id, col_4, col_5, col_6
for each record, I want to:
insert in table_a (col_1, col_2, col_3) values (...) on conflict (col_1, col2) do update ...
And then use the returning ID of table_a in table_b as following:
insert into table_b (table_a_id, col_4, col_5, col_6) values (...) on conflict (table_a_id, col_4) update ...