Subject Re: [IBO] IBO 10x slower than ibx doing Insert
Author Lucas Franzen
Magni Thor Mortensen schrieb:
> Why is IBO almost 10x slower than InterBase Express when doing bulk
> inserts with prepared statements ?
>
> The following test takes ~10 seconds with IBO, but only ~ 1 second with
> IBX with 1.000 inserts,
> 10.000 takes ~ 45 seconds with IBO

Ridiculous!
It should runder in less than one second unless you're trying to run it
on a real old machine ;-)

> procedure TForm1.Button1Click(Sender: TObject);
> var
> IBOc : TIB_Connection;
> IBOt : TIB_Transaction;
> IBOq : TIB_DSQL;
> start, stop, dur : TTime;
> i : Integer;
> begin
> IBOc := TIB_Connection.Create(nil);
> IBOt := TIB_Transaction.Create(nil);

The default Isolation is tiConcurrency, so set:
IBOt.Isolation := tiCommitted;

> IBOq := TIB_DSQL.Create(nil);
> IBOc.DatabaseName := 'c:\firebird\examples\EMPLOYEE.FDB';

Never set the Databasename property, use the PATH property.

> IBOc.Username := 'sysdba';
> IBOc.Password := 'masterkey';
> IBOc.Connect;
> IBOq.IB_Connection := IBOc;

Maybe be you should assign the IB_Transaction as well.

> IBOq.SQL.Text := 'INSERT INTO COUNTRY (COUNTRY, CURRENCY) VALUES
> (:COUNTRY, :CURRENCY)';
> IBOq.Prepare;
> start := Now;
> IBOt.StartTransaction;
> for i := 0 to 10000 do begin
> IBOq.ParamByName('COUNTRY').AsString := 'a'+IntToStr(i);
> IBOq.ParamByName('CURRENCY').AsString := 'bla';
> IBOq.Execute;
> end;
> IBOt.Commit;
> stop := Now;
> dur := stop - start;
> showMessage(FormatDateTime('hh:ss:zz',dur));
> end;

If this is still slower then try it with components _on_ the form and an
IBOMonitor to find out what's going wrong.

Luc.