How to increase INSERT performance?
Posted: Sun 20 Jan 2013 16:55
Hi,
I search a component set for replacement of UIB. I see IBDAC have good support, actively developed , multiplatform, Lazarus support,...
With my simple test case UIB speed is ~11100 INSERT/sec. IBDAC ~2630 INSERT/sec, with prepare ~6250 INSERT/sec. Any other trick than prepare?
I used Firebird 2.5.2 32bit embedded and last version of IBDAC.
My simple test case is:
Gabor
I search a component set for replacement of UIB. I see IBDAC have good support, actively developed , multiplatform, Lazarus support,...
With my simple test case UIB speed is ~11100 INSERT/sec. IBDAC ~2630 INSERT/sec, with prepare ~6250 INSERT/sec. Any other trick than prepare?
I used Firebird 2.5.2 32bit embedded and last version of IBDAC.
My simple test case is:
Code: Select all
CREATE SEQUENCE SEQ_1;
CREATE TABLE TABLE1 (
ID BIGINT NOT NULL,
FIELD1 SMALLINT,
FIELD2 VARCHAR(30),
FIELD3 SMALLINT
);Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
x:=10000;
y:=10;
end;
procedure IBDAC;
var
DB:TIBCConnection;
TR:TIBCTransaction;
SC:TIBCSQL;
i,j:integer;
begin
DB:=TIBCConnection.Create(Self);
DB.Options.Charset:='UTF8';
DB.Options.UseUnicode:=True;
DB.AutoCommit:=False;
DB.Database:='MYDB';
DB.UserName:='SYSDBA';
DB.PassWord:='masterkey';
TR:=TIBCTransaction.Create(Self);
TR.IsolationLevel:=iblcustom;
TR.DefaultConnection:=DB;
TR.Params.Add('wait');
TR.Params.Add('write');
TR.Params.Add('read_committed');
TR.Params.Add('no_rec_version');
DB.DefaultTransaction:=TR;
SC:=TIBCSQL.Create(Self);
SC.Connection:=DB;
SC.Transaction:=TR;
SC.SQL.Add('INSERT INTO TABLE1 (');
SC.SQL.Add('ID, FIELD1, FIELD2, FIELD3');
SC.SQL.Add(') VALUES (');
SC.SQL.Add('NEXT VALUE FOR SEQ_1, :IN_FIELD1, :IN_FIELD2, :IN_FIELD3');
SC.SQL.Add(') RETURNING ID;');
DB.Connected:=True;
for i:=1 to x do
begin
TR.StartTransaction;
SC.Prepare;
for j:=1 to y do
begin
SC.ParamByName('IN_FIELD1').Value:=1;
SC.ParamByName('IN_FIELD2').Value:=IntToStr(((i-1)*10)+j));
SC.ParamByName('IN_FIELD3').Value:=1;
SC.Execute;
end;
TR.Commit;
end;
DB.Connected:=False;
end;