Page 1 of 1

Performance issue any idea

Posted: Thu 30 Sep 2010 23:46
by Daniel Fagnan
Any idea how to fill all data with more performance very often we try to do
It's correct to used While like this
while not BatchQry.EOF do Begin

Example :

Try

Session.StartTransaction;
while not BatchQry.EOF do Begin
s := StripChargenumber( BatchQry.FieldByName('tmpChargenumber').asString);
// Showmessage(s);
if Length(s) > 0 then
begin
With MyTb do
begin
insert;
FieldByName('EmplId').asinteger := BatchQry.FieldByName('tmpEmplId').asinteger;
FieldByName('chargeNumber').AsString := BatchQry.FieldByName('tmpChargenumber').asString;
FieldByName('OperationNumber').asInteger := BatchQry.FieldByName('tmpOperationNumber').asInteger;
FieldByName('TotalHoursSeq').asFloat:= BatchQry.FieldByName('tmpTotalHourSeq').AsFloat;
FieldByName('TotalhoursSeq_Reg').asFloat:= BatchQry.FieldByName('TmpTotalHourSeq_reg').AsFloat;
FieldByName('TotalhoursSeq_Suppl').asFloat:= BatchQry.FieldByName('TmpTotalHourSeq_Over').AsFloat;
FieldByName('DateTransaction').AsDateTime := BatchQry.FieldByName('tmpDateTransaction').asDateTime;
FieldByName('NeedtoCompleted').asBoolean := BatchQry.FieldByName('tmpNeedToCompleted').asBoolean;
FieldByName('HasModified').asString:= '0';
FieldByName('WorkOrder').asString := UPPERCASE(s);
FieldByName('ProjetId').asString := BatchQry.FieldByName('TmpUr').asString;
FieldByName('EquipmentID').asInteger := BatchQry.FieldByName('tmpEquipmentID').Asinteger;
post;
end; //with MyTb
end;// if Length

BatchQry.Edit;
BatchQry.FieldByName('tmpBatchMove').asinteger:= 1;
BatchQry.post;
s:='';
BatchQry.Next;
End; // while not ADQ.EOF
MyTb.ApplyUpdates; {try to write the updates to the database}
Session.Commit; {on success, commit the changes}
Except
MyTb.RestoreUpdates; {restore update result for applied records}
Session.Rollback; {on failure, undo the changes}
raise; {raise the exception to prevent a call to CommitUpdates!}
End;
MyTb.CommitUpdates; {on success, clear the cache} :!: :!:

Posted: Fri 01 Oct 2010 01:39
by easyblue
Do not use FieldByName.

First detect all the field index in advance, and then directly

Fields[0].asInteger:=..
Fields[1].asString:=..

Posted: Mon 04 Oct 2010 14:04
by AndreyZ
Hello,

You can use the TMyLoader component which serves for fast loading of data to the server. You can look at the example of using it in MyDACDemo.
Also you can use the LoadFromDataset method of the TMyLoader component. This method loads data from the specified dataset. For more information please read MyDAC Reference Manual.