我正在尝试使用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
返回
答案 0 :(得分:2)
while循环迭代了多少次?我怀疑Aqua Data Studio在查询运行时正在构建数据结构,并且对于循环的每次迭代,需要进一步的内存块来编制该迭代的计划/统计信息。