PostgreSQL: does the order of rows in a bulk insert control the order of `FOR EACH ROW` triggers?
0
votes
1
answer
888
views
I have a trigger like
BEFORE INSERT ON table_a FOR EACH ROW EXECUTE FUNCTION upsert_into_table_b()
.
If I execute a bulk insert like INSERT INTO table_a ([columns]) VALUES ([row 1 values]), ([row 2 values])...
, will the trigger run sequentially on the table_a
rows in the order they were stated? In other words, will the upsert into table_b
be done for row 1, then for row 2, in the order they were given in VALUES
?
(I ask because, if so, reordering the VALUES
may help me solve a deadlock on the upsert.)
Asked by Nathan Long
(1005 rep)
Oct 26, 2023, 01:44 PM
Last activity: Oct 27, 2023, 06:28 AM
Last activity: Oct 27, 2023, 06:28 AM