Page 1 of 1

Stage variable Vs Routine- Which one gives good performance

Posted: Mon May 30, 2005 12:13 am
by dslearner
Hi all,

i hav a question,if i have a big condition tobe check and using 5 times only in a specific job,can i write routine for that or use stage variable.

In performance issue which is fast stage variable or routine.

can any one help?

Thanks in advance

Posted: Mon May 30, 2005 12:54 am
by WoMaWil
everything depends on your issues. We have to know more about your problem to tell you what will be best.

You can even use a Routine in a Stage Variable.

Routines are usefull if your code is complicated or has to be used several times.

If you are on an optimizing trip you may even consider Transforms.

Wolfgang

Posted: Mon May 30, 2005 1:09 am
by ArndW
dslearner,

if you can put your logic in stage variables it tends to be a bit faster than by incurring the overhead of calling a routine (which involves pushing the current program on the stack, calling a new routine, and popping back to the caller). As Wolfgang explained, there are many cases where a routine or a function might serve your purposes better. The difference between using local transform variables and a routine is easily measured; but I would guess that on 1 million calls you would get less than 5 seconds difference in execution time, and if you are doing Database I/O this time might not even come into play.

Posted: Wed Jun 01, 2005 10:52 am
by anupam
First of all, one thing should be noted. i.e. if we call a routine or use stage variable, the same logic would be implemented for both of these methods, that means we would be having the same code at both the places.

So, if the code can be written and is not very complicated then the first choice would be stage variable.

If it is really complicated then we have left with no other then routine as the option.

Performance wise stage variable would provide a better throughput.

Posted: Wed Jun 01, 2005 10:57 am
by amsh76
If you are going to use same logic, in different jobs use routine, but if the logic is used specifically for some field in one job you are better off using Stage variable.