Forum Discussion
Slow WHILE loop on some servers
AnatoliD some update on this?
I found same problem.
I have two sql servers. Old, is 2008 and win server 2008
We created new machine on same vmware host, without any cpu limiations.
Is a sql server 2019 windows server 2019.
A simple loop like this presents up to 1 second difference, beign new system (with no laod) more slow:
select cpu_time from sys.dm_exec_requests where session_id = @@SPID
exec sp_executesql N'
set nocount on;
declare @start_cpu datetime = getdate();
DECLARE @i bigint = 10000000
while @i > 0 set @i -= 1;
select UsedCPU = datediff(ms,@start_cpu, getdate())
'
select cpu_time from sys.dm_exec_requests where session_id = @@SPID
Also, a running a simple powershell loop comparing two servers, and new server is up 2x more slow:
$i = 10000000
while($i--){}