Subject | Re: [IBO] Digest Number 603 |
---|---|
Author | lobolo2000 |
Post date | 2001-09-16T10:38:02Z |
For how long does the reference to IB_DSQL1.ParamByName('P1') hold? I recall
reading somewhere something about it lasting long enough for something to be
done. Poor ol' memory.
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com
reading somewhere something about it lasting long enough for something to be
done. Poor ol' memory.
> procedure TForm1.ButtonEnh4Click(Sender: TObject);_________________________________________________________
> var
> i: integer;
> Col1, Col2: TIB_Column;
> tmpDT: TDateTime;
> tmpStr: string;
> begin
> IB_DSQL1.SQL.Clear;
> IB_DSQL1.SQL.Add( 'INSERT INTO COUNTRY( COUNTRY, CURRENCY )' );
> IB_DSQL1.SQL.Add( 'VALUES( :P1, :P2 )' );
> IB_DSQL1.Prepare;
> tmpDT := Now;
> Col1 := IB_DSQL1.ParamByName('P1');
> Col2 := IB_DSQL1.ParamByName('P2');
> for i := 0 to 10000 do
> begin
> Col1.AsString := 'C ' + IntToStr(i);
> Col2.AsString := 'D ' + IntToStr(i);
> IB_DSQL1.Execute;
> end;
> tmpDT := Now - tmpDT;
> DateTimeToString( tmpStr, 'hh:nn:ss.zzz', tmpDT );
> MemoEnh1.Lines.Add( 'ColRef: ' + tmpStr );
> end;
>
>
> Connected and ran the top function 5 times:
>
> ByName: 00:00:08.500
> ByName: 00:00:08.391
> ByName: 00:00:09.828
> ByName: 00:00:09.906
> ByName: 00:00:09.828
>
> Average: 9.29
>
>
> Connected and run the second function 5 times:
>
> ColRef: 00:00:07.485
> ColRef: 00:00:07.219
> ColRef: 00:00:08.734
> ColRef: 00:00:08.765
> ColRef: 00:00:08.750
>
> Average: 8.19
>
>
> Which makes the second function (using column references) a bit over
> 11% faster.
>
> (I would have run some longer tests but I am still waiting on a new
> CPU fan and did not want to cook my system.)
>
> The tests were done using a local firebird installation. Presumably
> the difference would be less significant on a remote server. If you
> have more than two fields/parameters you can expect the difference to
> be larger. If you have blob columns involved then the difference will
> probably be smaller (more work involved in saving a blob).
>
> So I think this demonstrates that column references are significantly
> faster. The difference is not so great as to be important in many
> situations, such responding to user interactions etc. But the
> difference is big enough to be prefer this approach in loops.
>
>
> Geoff Worboys
> Telesis Computing
>
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com