I have many records,If I use "Insert(...)" in for(int i=0;i<n;i++),I find that it is very slow,how to insert many records into Mysql fast?
I have many records,If I use "Insert(...)" in for(int i=0;i<n;i++),I find that it is very slow,how to insert many records into Mysql fast?
You can use transaction.
Qt Code:
dbConnection.transaction(); for(int i=0;i<n;i++) { // insert record here } dbConnection.commit();To copy to clipboard, switch view to plain text mode
transactions are the best way, but if your DBS doesn't support them, then you (maybe) can gain speed by joining all inserts and only execute one INSERT statement.
saa7_go (15th July 2010)
Bookmarks