troubleshooting Question

speed up master detail inserts

Avatar of andieje
andieje asked on
MySQL Server
8 Comments1 Solution791 ViewsLast Modified:
Hi

Is there anyway to speed up master detail inserts if the master table has an autoinc primary key.

Is there a better way than this:

START TRANSACTION;
NSERT master (field1,field2) VALUES (data1,data2);
INSERTdetail (foreign_key, field1,field2) VALUES (last_insert_id(), data3,data4);
INSERTmaster (field1,field2) VALUES (data5,data6);
INSERT detail (foreign_key,field1,field2) VALUES (LAST_INSERT_ID,data7,data8);
COMMIT;

IS there a way of using mysqlimport or load data file for master detail data in separate tab files when the master table has an autoinc primary key?

thanks
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros