Can you instead give us a table structure (create table ...) + some sample data for before and after the execution of the procedure? It looks like you're calculating a moving average or sum, and that might be amenable to just calculating on the fly with an analytic function