开发者

Sybase SQL stored procedure consumes too much memory

开发者 https://www.devze.com 2022-12-31 10:51 出处:网络
I am trying to run a stored procedure with a while loop in it using Aqua Data Studio 6.5 and as soon as the SP starts Aqua Data starts consuming an increasing amount of my CPU\'s memory which makes ab

I am trying to run a stored procedure with a while loop in it using Aqua Data Studio 6.5 and as soon as the SP starts Aqua Data starts consuming an increasing amount of my CPU's memory which makes absolutely no sense to me because everything should be off on the Sybase server I am working with. I have commented out and tested every piece of the SP and narrowed the issue down to the while loop. Can anyone explain to me what is going on?

create procedure sp_check_stuff as
begin

declare
    @counter numeric (9),
    @max_id numeric (9),
    @exists numeric (1)开发者_如何学JAVA,
    @rows numeric (1)

select @max_id = max(id) 
    from my_table      

set @counter = 0
set @exists = 0
set @rows = 0

while @count <= @max_id
    begin

     //More logic which doesn't affect memory usage based
     //on commenting it out and running the SP

    set @counter = @counter + 1
    set @exists = 0
    set @rows = 0

   end
end

return


How many times does the while loop iterate? I suspect Aqua Data Studio is building up data structures as the query runs and for every iteration of the loop, a further block of memory is needed to catalogue the plan/stats of that iteration.

0

精彩评论

暂无评论...
验证码 换一张
取 消