Zeos + Mysql + Multi-thread INSERT lazarus / 16-Databases ---------------------------------------------------------------------- warcode · 2011-01-31 21:44 Hi all i have a big probleme here i made a application that make insert query to a mysql 5 database using Zeos 7.0.0-dev. The trouble is that i need to make something like this for x:= 0 to 20000 do begin   query := 'INSERT INTO db_test (file) VALUE ( QuotedStr( 'c:\test.pas' ) )';   zCon.ExecuteDirect( query ); end; Yea 20000 insert query is pretty long !!! So i 'TRY' to convert this using Thread i read  this Multithreaded Application Tutorial Example of multi-threaded application: array of threads But im a bit lose, does i need to create a array [0..20000 ] of TThread  ? Need help plz Christian F ---------------------------------------------------------------------- theo · 2011-01-31 22:17 I wouldn't do that. It's probably not going to be a lot faster, but certainly a lot more complicated and prone to error. If you just need to make your UI more responsive, call Application.Processmessages in the loop periodically. ---------------------------------------------------------------------- marsianinek · 2011-05-12 13:36 No, wrong way. Problem isn't in ProcessMessages(), problem is in running thousands inserts into database. To make this faster use transaction: zCon.StartTransaction(); query := 'INSERT INTO db_test (file) VALUE ( QuotedStr( 'c:\test.pas' ) )'; for x:= 0 to 20000 do begin   zCon.ExecuteDirect( query ); end; zCon.Commit(); Look, I moved query line before for loop, because there is the same value saved in loop 20000 times, what for? There is one enough.