Subject Re: [IBO] development
Author Minoru
Hi,

I had no performance problem with IBO 4.8.7, very good performance :)
Usually, the copy between databases is using the method of parameterized-insert.

This thread sounds bad IBO performance for me...
I try the Geoff's Xfer_IBO code on my environment.
It seems that the result is later than the parameterized-insert.
(Sorry, blob subtype is text only in this testing)

Then i download the FIBPlus 6.9.9, and change to Parameterized-insert(TpFIBQuery
from TpFIBDataSet). as far as my testing, it seems that the IBO is a few faster
than FIBPlus.

I'm satisfied with this performance :)

--
Thanks.
Minoru

Testing result is:

Case1 - Source:100,000 records( DBsize 17,874,944byte )

=== Xfer_IBO ===
App Init Time: 0ms
Object Prepare Time: 46ms
Records Transfered: 100000
Records Transfer Time: 63883ms
Transaction Commit Time: 749ms
Connection Close Time: 15ms
Application Run Time: 64693ms

=== Test_IBO (Parameterized-insert)===
App Init Time: 0ms
Object Prepare Time: 31ms
Records Transfered: 100000
Records Transfer Time: 18284ms
Transaction Commit Time: 780ms
Connection Close Time: 0ms
Application Run Time: 19095ms

Case2 - Source:1,000,000 records(DBsize 148,258,816byte)

=== Xfer_IBO ===
App Init Time: 0ms
Object Prepare Time: 31ms
Records Transfered: 1000000
Records Transfer Time: 670056ms
Transaction Commit Time: 1154ms
Connection Close Time: 0ms
Application Run Time: 671241ms

=== Test_IBO (Parameterized-insert)===
App Init Time: 0ms
Object Prepare Time: 16ms
Records Transfered: 1000000
Records Transfer Time: 183800ms
Transaction Commit Time: 1170ms
Connection Close Time: 0ms
Application Run Time: 184986ms

My environment is:

Win7 64bit (WoW64)
Intel Core2 Duo CPU 2.93GHz / Mem 4GB
Firebird 64bit 2.5RC2(WI-V2.5.0.25920)
Delphi7 Ent/IBO V4.8.7

/* Create Database */
Set SQL Dialect 3;
Create Database 'Localhost:C:\Temp\SrcDB.fdb' /* and DscDB */
User 'SYSDBA'
Password 'masterkey'
Page_Size 16384
Default Character set UTF8;

/* Create Table */
Create Table "MyTable"
(
"Key" INTEGER Not Null
, "A" BIGINT
, "B" VARCHAR(20)
, "C" BLOB Sub_Type Text Segment Size 80
, "D" DATE
, "E" TIMESTAMP
, Constraint "PK_MyTable" Primary Key ("Key")
);

=== Test_IBO (Parameterized-insert)
program Test_IBO;

//* mark was modified.

{$APPTYPE CONSOLE}

uses
SysUtils,
Windows,
IB_Components;

const
SrcDB: string = 'C:\Temp\SrcDB.fdb';
DstDB: string = 'C:\Temp\DstDB.fdb';
Usr: string = 'SYSDBA';
Pwd: string = 'masterkey';
SrcSql: string = 'SELECT * FROM "MyTable"';
//* DstSql: string = 'SELECT * FROM LOCALITIES FOR UPDATE';
TargetTableName: string = '"MyTable"';

var
SrcCon: TIB_Connection;
SrcTran: TIB_Transaction;
SrcCsr: TIB_Cursor;
DstCon: TIB_Connection;
DstTran: TIB_Transaction;
DstCsr: TIB_Cursor;

AppStart: DWord;
CheckPt: DWord;

ii, rcount: integer;

procedure TimerOutput(const AMsg: string);
var
TmpTicks: DWord;
begin
TmpTicks := GetTickCount;
WriteLn( AMsg + ': ' + IntToStr(TmpTicks - CheckPt) + 'ms' );
CheckPt := TmpTicks;
end;

begin
try
AppStart := GetTickCount;
CheckPt := AppStart;

SrcCon := TIB_Connection.Create(nil);
with SrcCon do
begin
Database := SrcDB;
UserName := Usr;
Password := Pwd;
end;
SrcTran := TIB_Transaction.Create(nil);
with SrcTran do
begin
IB_Connection := SrcCon;
ReadOnly := true;
end;
SrcCsr := TIB_Cursor.Create(nil);
with SrcCsr do
begin
IB_Connection := SrcCon;
IB_Transaction := SrcTran;
SQL.Text := SrcSql;
end;

DstCon := TIB_Connection.Create(nil);
with DstCon do
begin
Database := DstDB;
UserName := Usr;
Password := Pwd;
end;
DstTran := TIB_Transaction.Create(nil);
with DstTran do
begin
IB_Connection := DstCon;
end;
DstCsr := TIB_Cursor.Create(nil);
with DstCsr do
begin
IB_Connection := DstCon;
IB_Transaction := DstTran;
//*SQL.Text := DstSql;
end;

TimerOutput('App Init Time');

SrcCon.Connected := true;
SrcTran.StartTransaction;
SrcCsr.Prepare;

with DstCsr do
begin
IB_Connection := DstCon;
IB_Transaction := DstTran;

//*Make SQL from Src-SQL
SQL.Clear;
SQL.Add('Insert Into '+TargetTableName+'(');
for ii := 0 to SrcCsr.FieldCount-1 do begin
if ii = 0 then SQL.Add(SrcCsr.Fields[ii].FieldName)
else SQL.Add(', '+SrcCsr.Fields[ii].FieldName);
end;
SQL[SQL.Count-1] := SQL[SQL.Count-1] + ')';
SQL.Add('Values(');
for ii := 0 to SrcCsr.FieldCount-1 do begin
if ii = 0 then SQL.Add(':'+SrcCsr.Fields[ii].FieldName)
else SQL.Add(', :'+SrcCsr.Fields[ii].FieldName);
end;
SQL[SQL.Count-1] := SQL[SQL.Count-1] + ')';
// WriteLn( SQL.Text);
end;

DstCon.Connected := true;
DstTran.StartTransaction;

DstCsr.Prepare;

TimerOutput('Object Prepare Time');

rcount := 0;
SrcCsr.First;
with SrcCsr do
while not Eof do
begin

{
//DstCsr.Append;
DstCsr.Insert;
for ii := 0 to FieldCount - 1 do
DstCsr.Fields[ii].Assign(Fields[ii]);
Next;
DstCsr.Post;
}

//*
for ii := 0 to FieldCount - 1 do
DstCsr.params[ii].Asstring := Fields[ii].asstring;

DstCsr.execute;
Next;

Inc(rcount);
end;
WriteLn('Records Transfered: ' + IntToStr(rcount));

TimerOutput('Records Transfer Time');

SrcTran.Commit;
DstTran.Commit;

TimerOutput('Transaction Commit Time');

SrcCon.Close;
DstCon.Close;

TimerOutput('Connection Close Time');

CheckPt := AppStart;
TimerOutput('Application Run Time');

except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.