Best to do with a lot of records

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Best to do with a lot of records

Post by calou » Tue 27 Jan 2009 17:35

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 28 Jan 2009 09:09

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.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 28 Jan 2009 10:44

Thank you plash

Post Reply