Subject Re: [firebird-support] Re: When do I commit
Author David Johnson
When I was performance testing in Delphi, 30 to 50% of the time was
spent in the ParamByName and FieldByName during query submission and
data retrieval, respectively. String operations are expensive in Delphi
- as expensive as in Java - and should be avoided if possible.

You can dereference these up front if you desire, gaining the power of
the use of query metadata, but the performance of integers or even
pointers.

Please forgive me for not providing an example. It has been over a year
since I programmed in Delphi, and I don't even have a working
installation of Delphi any more.

Approximately, in pseudocode, assuming you can dereference the TField
and TParam objects from the dataset:

F1: TField;
P1: TParameter;

myQuery.prepare;
p1 := myQuery.getParameter('paramName');
f1 := myQuery.getField('fieldName'); // beware - some drivers don't
initialize this until the query returns -
for i := start to finish do
begin
p1.value := xxx;
myQuery.execute;
// solution for drivers that don't initialize Query result metadata
until first data is returned
/*
if f1 = nil then begin
f1 := myQuery.getField('fieldName');
end;
*/
writeln (f1.value);
end;


On Tue, 2005-06-07 at 02:01 +0000, Adam wrote:
> --- In firebird-support@yahoogroups.com, Grant Brown <grant@s...>
> wrote:
> > Hi Adam,
> >
> > >> do you really want ALL of the inserts to be rolled back?
> >
> > Yes - What I need is an all or nothing. The for loop should process
> 18
> > times and I need all 18 loops to be without error or they all need
> to be
> > rolled back.
>
> In that case your statement is correct, you want all the inserts to
> happen inside the single transaction.
>
> >
> > Question :- doest "ParamByName" (and FieldByname for that matter)
> cause
> > the query to search its parameters list each time its called and
> then
> > returns the index value. Params[0] prevents the search and hence
> speeds
> > up the query ?
>
> I doubt it is noticable. They tend to be very small lists and are
> kept in memory, so each search is at worst n complexity. Certainly,
> the first time someone adds a new parameter to your query and you
> have to figure out why your program stops working you will appreciate
> having the FieldByName. Certainly, having the prepare inside the for
> loop well and truly stuffs up any performance gain you had there.
>
> >
> > >> Also, unless I am going nuts, you probably want to stop at
> > High(PerArray)-1
> >
> > PerArray is a zero based array so High(MyArray) will return
> > Length(MyArray) - 1
> >
>
> Yep I'm nuts :(
>
> Adam
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>