We've inherited some SQL server 2014 databases, they are running on Azure IaaS. We're getting complaints about performance and trying to get a grip on it. We're starting to look at CPU performance, and run the following test:
DECLARE @Loops INT SET @Loops = 1 DECLARE @CPU INT SET @CPU = @@CPU_BUSY DECLARE @StartDate DATETIME SET @StartDate = GETDATE() WHILE @Loops <= 100000 BEGIN IF COALESCE('123', '456') = '456' PRINT 1 SET @Loops = @Loops + 1 END
PRINT 'Total CPU time: ' + CONVERT(varchar, @@CPU_BUSY - @CPU)
PRINT 'Total milliseconds: ' + CONVERT(varchar, DATEDIFF(ms, @StartDate, GETDATE()))
PRINT ''
GO
On Production machine, 16 Virtual Processors (20 to 30% busy), we get the following result:
Total CPU time: 1150
Total milliseconds: 13473
On test machine, 4 Virtual Processors (also around 20 to 30% busy) we get the following:
Total CPU time: 2
Total milliseconds: 1183
I've tried running a few benchmarks on the production machine, but they don't show any problems, and always show the production machine CPU at least twice as powerful as test machine.
Is there some SQL Server setting that might be configured wrongly? Any idea how to troubleshoot this issue?
Note the 'problem' database is running always on Availability Group, we are wondering if that may be a factor here.