1

我正在尝试使用 Aqua Data Studio 6.5 运行一个带有 while 循环的存储过程,一旦 SP 启动,Aqua Data 就会开始消耗越来越多的 CPU 内存,这对我来说绝对没有意义,因为一切都应该关闭我正在使用的 Sybase 服务器。我已经注释掉并测试了 SP 的每一部分,并将问题缩小到 while 循环。谁能向我解释发生了什么事?

create procedure sp_check_stuff as
begin

declare
    @counter numeric (9),
    @max_id numeric (9),
    @exists numeric (1),
    @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

返回

4

1 回答 1

2

while 循环迭代了多少次?我怀疑 Aqua Data Studio 在查询运行时正在构建数据结构,并且对于循环的每次迭代,都需要进一步的内存块来编目该迭代的计划/统计信息。

于 2010-05-18T20:39:24.310 回答