Subject Re: To SP or not
Author Alexander V.Nevsky
--- In firebird-support@yahoogroups.com, "Alfred Thomas" <alfred@f...>
wrote:
> >>My experience with this was the exact opposite. Contrary to all my
> expectations,
> >>the SP I tried ran twice as slow as the same logic executed from the
> client process
> >>using IBPP. Logic that required 30 seconds when run through the
client
> required
> >>just over 60 seconds when run via SP. I may well have done something
> wrong, but
> >>have no ready explanation for what that might have been.
>
> >>Dan.
>
> Hmm that is strange, I was under the impression that an increase in
speed
> was a given,
> when using SP's. This certainly was the case wherever I used it
(FireBird
> and Oracle).
> Ever found the reason for the slow execution?

1. Filtering, ordering, grouping. When we apply conditions on result
set returned by SP, conditions do'nt lighten server's life by usage of
indices, cursor is always built entirely. So, usage of SPs which
return large result set having in mind to filter it etc. on call, can
be not the best idea.
2. Another situation when client-side logic can be faster - when all
needed to execute some changes is already selected on client side on
stage of decision making but can't be used as SP paremeters and should
be fetched once more on execution.
3. Simple selects like Select Gen_ID(MyGenerator,1) From rdb$database
are more faster than equivalent SP.
4. SP body is many "if"s within which are accessed different objects
but on each particular call only small part of them are executed. On
prepare rights for all objects are checked regardless of parameters.

Best regards,
Alexander.