Page 1 of 1

Best to do with a lot of records

Posted: Tue 27 Jan 2009 17:35
by calou
Hello,

What is the best (more quickly) to do insert a lot of records?

Code: Select all

  IBQuery.Sql:='insert into ......';
  IBTransaction.StartTransaction;
  IBQuery.Prepare;
  while not ...
  begin
    IBQuery.ParamByName('...'):='....';
    IBQuery.Execute;
  end;
IBTransaction.commit;
Or doing a commit after each execute?

Is it the same law for 10 000 records or 1 000 000 records?

Thank you for help

Posted: Wed 28 Jan 2009 09:09
by Plash
The faster way is the following:

- use the TIBCSQL component instead of TIBCQuery;
- start transaction once before inserting, and commit it once after inserting all records;
- make sure that the AutoCommit property is set to False;

Use this way for any number of records.

Posted: Wed 28 Jan 2009 10:44
by calou
Thank you plash