Bulk insert

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
miguelenguica
Posts: 18
Joined: Mon 11 Apr 2011 15:28

Bulk insert

Post by miguelenguica » Mon 11 Apr 2011 15:35

Hi. I have a text file with 500.000 inserts in SQL.

"insert into knowledge_2('knowledge_id','phrase_id','word_text') value(4,15,'user');"

What's the fastest way to insert them into a MySQL table? I've tried MyDump but the result was very slow. Must I write anything else into the SQL file to make it perform bulk inserts?

MyLoader is not an option. Can you help?

Thanks.

AndreyZ

Post by AndreyZ » Tue 12 Apr 2011 07:34

Hello,

Please try using transactions and the TMyDump component in the following way:

Code: Select all

MyDump.Connection.Open;
MyDump.Connection.StartTransaction;
MyDump.RestoreFromFile('your_filename');
MyDump.Connection.Commit;

Post Reply