Subject | Re: [firebird-support] Re: Firebird Trigger Local Variable Gotcha |
---|---|
Author | Ann W. Harrison |
Post date | 2006-04-03T15:22:02Z |
t.s. wrote:
:blah_var = NULL;
exists test involved (for the first time) parsing, compiling,
and optimizing a separate query and (every time) executing the
query with (one hopes) indexed reads, data reads, evaluation, etc.
Regards,
Ann
> So maybe to prevent the same bug to ever see me face to face again,A LOT slower. How about
> would it be better to change the "check whether something exists"
> construct from :
> ...
> select (blah) from (blah_table) into :blah_var;
> if (:blah_var is null) then begin
> -- normal processing here
> end;
> ...
>
> to
> ...
> if (exists(blah blah blah)) then begin
> select (blah) from (blah_table) into :blah_var;
> ...
> -- normal processing here
> end
> ...
>
> The downside is that it'd be slightly slower due to having to do the
> query twice.
:blah_var = NULL;
> select (blah) from (blah_table) into :blah_var;Assigning a value to a variable is approximately free. Running an
> if (:blah_var is null) then begin
> -- normal processing here
exists test involved (for the first time) parsing, compiling,
and optimizing a separate query and (every time) executing the
query with (one hopes) indexed reads, data reads, evaluation, etc.
Regards,
Ann