How can one insert a row into one table and use the id generated from that row into another row so that there can be a transaction around the whole thing? The problem I'm having is that there is massive db latency because I have 100k records, but I can only transact 1-100 at a time.
INSERT INTO foo;
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT INTO foo;
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
INSERT into bar(foo_id) VALUES (last_foo_id)
barrecords are you inserting? start a transaction, insert into foo, do the multiple bar inserts, then commit. start a new transactions, do anotherfoo, then thebars, commit, etc...