MySQL Forums
Forum List  »  Stored Procedures

Re: 4.1 (pre 5.0.x) stored procedure options
Posted by: Roland Bouman
Date: September 27, 2005 02:05AM

Ok, glad that helped. To be sure, what I meant was that you should ALWAYS use these aggregate functions to calculate summaries. Any attempt to calculate summaries using running-value calculations are bound to be slower and more resource consuming then the builtin aggregate.

So this example running-value pseudocode:

declare my_sum int := 0;
foreach record in (
select *
from table_i_want_to_query
) loop
my_sum := my_sum + record.column_i_want_to_summate;
end loop;

return my_sum;

should always be shunned in favour of this:

select sum(column_i_want_to_summate)
from table_i_want_to_query

Even if you wrap that in a stored procedure/function

Options: ReplyQuote


Subject
Views
Written By
Posted
8729
September 22, 2005 08:39PM
3013
September 26, 2005 07:17PM
Re: 4.1 (pre 5.0.x) stored procedure options
2895
September 27, 2005 02:05AM
2682
September 27, 2005 07:43PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.