当我在脚本下面运行时,查询运行大约 30 秒,但是当它完成时,我可以获得经过时间等于 0.1 秒且计算时间为 2 毫秒的信息。
你能告诉我这个查询运行 30 秒的原因是什么,即使我不使用任何表?
declare heads bool;
declare heads_in_a_row int64 default 0; #number of heads in a row
declare nb_of_throws int64 default 0; #number of throws
#How many throws I need to get a 8 heads in a row?
while heads_in_a_row <= 8 DO
set heads = RAND() < 0.5;
set nb_of_throws = nb_of_throws +1;
if heads then
set heads_in_a_row = heads_in_a_row + 1 ;
else
set heads_in_a_row = 0;
end if;
end while;
select nb_of_throws;