Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

INT math is slow in SQL server, but only under VMware - really weird!

$
0
0

Hi

I had noticed a really strangle thing. INT calculation is 2-3-5 times slower in SQL server running in VMware than on physical machines. From VMware side, I had eliminated all possible things: balooning, CPU overconsumption, "ready" time etc. INT CPU tests (link 'Pi' digits calculation programs) show the same performance, while SQL server math operations are MUCH slower. 

Please check the test of few results on different machines. I am DBA for >20y, but I am really puzzled.

Test is simple, no parallelism, no IO, limited memory use (L2,L3 caching is irrelevant)

Results

-- 31403 ms, one PROD VM, SQL 13.0.5337 (why is it so slow??? )
-- 9227 ms,  AWS RDS 14.0.3035.2
-- 7733 ms,  very old physical machine, 10.50.6220.0, very old
-- 13666 ms,  my really old desktop, physical, 13.0.4446.0
-- 6346 ms,   desktop of my colleague, physical, 14.1000.169

create function dbo.isPrime (@n bigint)
returns int
as
  begin
  if @n = 1 return 0
  if @n = 2 return 1
  if @n = 3 return 1
  if @n % 2 = 0 return 0
  declare @sq int
  set @sq = sqrt(@n)+1 -- check odds up to sqrt
  declare @dv int = 1
  while @dv < @sq 
    begin
	set @dv=@dv+2
	if @n % @dv = 0 return 0
	end
  return 1
  end
GO
declare @dt datetime set @dt=getdate()
select dbo.isPrime(1000000000000037)
select datediff(ms,@dt,getdate()) as ms
GO




Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>