How to increase INSERT performance?

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
gaborboros
Posts: 6
Joined: Tue 02 Oct 2012 11:32

How to increase INSERT performance?

Post by gaborboros » 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:

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;
Gabor

AndreyZ

Re: How to increase INSERT performance?

Post by AndreyZ » Mon 21 Jan 2013 10:50

Hello,

To increase performance, you should set the UseUnicode property to False. We had a similar request at http://forums.devart.com/viewtopic.php?f=24&t=18926 . Please read it, there we explained in details the performance problem connected with the UseUnicode property (at the second page).

gaborboros
Posts: 6
Joined: Tue 02 Oct 2012 11:32

Re: How to increase INSERT performance?

Post by gaborboros » Mon 21 Jan 2013 11:40

AndreyZ wrote:Hello,

To increase performance, you should set the UseUnicode property to False. We had a similar request at http://forums.devart.com/viewtopic.php?f=24&t=18926 . Please read it, there we explained in details the performance problem connected with the UseUnicode property (at the second page).
The speed is same with UseUnicode:=True and UseUnicode:=False. Any other idea?

Gabor

AndreyZ

Re: How to increase INSERT performance?

Post by AndreyZ » Mon 21 Jan 2013 14:11

Thank you for the information. We have reproduced the problem and investigation of the problem is in progress. As soon as we have any results, we will let you know.

gaborboros
Posts: 6
Joined: Tue 02 Oct 2012 11:32

Re: How to increase INSERT performance?

Post by gaborboros » Mon 21 Jan 2013 15:51

AndreyZ wrote:Thank you for the information. We have reproduced the problem and investigation of the problem is in progress. As soon as we have any results, we will let you know.
Nice. Thank You for your support!

gaborboros
Posts: 6
Joined: Tue 02 Oct 2012 11:32

Re: How to increase INSERT performance?

Post by gaborboros » Wed 27 Feb 2013 08:38

AndreyZ wrote:Thank you for the information. We have reproduced the problem and investigation of the problem is in progress. As soon as we have any results, we will let you know.
Any news?

Gabor

AndreyZ

Re: How to increase INSERT performance?

Post by AndreyZ » Fri 01 Mar 2013 09:15

We are still investigating this question. We will let you know as soon as we have any results.

Bjarke_Moholt
Posts: 39
Joined: Thu 21 Nov 2013 12:51

Re: How to increase INSERT performance?

Post by Bjarke_Moholt » Fri 22 Nov 2013 08:55

I experience a similar problem. I see this thread has been passive for quite a while, is there any news on this?

AndreyZ

Re: How to increase INSERT performance?

Post by AndreyZ » Tue 26 Nov 2013 10:08

We have made several changes in IBDAC which improve the overall performance. These changes will be included in the next IBDAC build.

Post Reply