SQL Server Help - New Server

Soldato
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
Ok very strange one this that is outside of my skill level unfortunately. We've got a fairly large database (35GB) with medium usage. This was on oldish hardware and SQL Server 2008. We got a new server, lots more ram / faster processors - great! HDD setup is the same (i.e. raid / configuration / file location). Backed up the database and restored on the new server (running in 2012 mode). Everything seemed fine - but all was not well. I'm getting very strange performance issues. Most queries are running slightly faster, which is great, but some queries on the first time are running a lot slower.

Example - we have a query that on initial run takes 7 seconds to complete. If I run it again it takes 250ms. If I change a parameter value it takes 7 seconds to run again. If I clear the query plan cache it takes 7 seconds to run again. If I run the same query on the old database, it takes 500ms on first run, 400ms on second run.

So something is defo up with how long it takes to compile the query. When I return the actual execution plan, its the same but the estimate rows / subtree costs are a lot higher on the new server. When I do properties and get the compile time its 7000 vs 350 on the old server (assuming thats ms).

If I amend the query and have options(recompile) it takes 3 seconds to run pretty much each and every time. So faster initial, but still too slow on recalls.

As part of the migration, rebuilt all indexes and updated statistics.

So long story short, new server is quicker but only after the query plan has been created. Ideas?
 
Soldato
Joined
30 Sep 2005
Posts
16,543
daft question, but you have set the memory allocation within sql studio haven't you? although I think the default should be ok.
Obviously queries after the first run are cached in ram and compiled, hence the performance boost....but I doubt ram is the issue here. Very strange.

Actually, your performance issues are on first run aren't they...Mmmmmm

are the queries pulling data from remote systems or is all the data local? any external connectors?
 
Soldato
OP
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
Nope - the new server is hosted internally right next to the old server. I've been checking trace flags, server settings etc and they're all the same. Change the compat level and still the same. Switched on trace flags in our test environment and not seeing any improvement. When I look at the profiler on the server, the statement completes extremely quickly, but the batch is taking all of the time - but it's the only statement being run :/
 
Soldato
Joined
30 Sep 2005
Posts
16,543
If the only difference you can see is a change of server, I'd check that all the firmware and bios are up to date. Run a disk io tool on both servers to check disk speeds.
I assume the disk layouts and filesystems are the same?

Also, have you gone from an old sql version to a newer one? (ie say from 2008 to 2017).

It does sound like a sql setting though, like the new server is doing an extra check, or piece of work whilst running the initial query.
 
Soldato
OP
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
Production server is in use so plenty going on, where as the old server is read only / locked down now.

Can't switch to 2016 as we have purchased the 2012 licence outright and don't have the budget unfortunately.

Everything is patched / up to date. I've tried removing the auto created stats and turning on the optimise fixes trace flag (4199) but no difference.
 
Man of Honour
Joined
30 Oct 2003
Posts
13,249
Location
Essex
Random one but in server properties under processors have you got "boot SQL Server priority" checked? I noticed that not having this checked in 2012 really did make the server under perform.
 
Soldato
OP
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
Could try the database tuning advisor, often suggests indexes that will help, however not always wise to blanket apply everything it suggests.
But my only issue with that is why does the profile show the query is running pretty fast but the "batch" has such a massive delay? So its not like the query is running slowly...
Random one but in server properties under processors have you got "boot SQL Server priority" checked? I noticed that not having this checked in 2012 really did make the server under perform.
It's off but having had a quick read everyone seems to say its an extremely bad idea to turn it on, and documentation states it will be removed in a future version.
Same on both servers.
 
Man of Honour
Joined
30 Oct 2003
Posts
13,249
Location
Essex
But my only issue with that is why does the profile show the query is running pretty fast but the "batch" has such a massive delay? So its not like the query is running slowly...

It's off but having had a quick read everyone seems to say its an extremely bad idea to turn it on, and documentation states it will be removed in a future version.

Same on both servers.

Ahh I wonder why that is. Perhaps I have to have a read and find out why it is such a bad idea, what I do know is that if we don't have it on certain jobs really suffer. Out of interest are you running any linked servers or statements that go across servers?
 
Soldato
OP
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
No its all pretty standard. It's hitting some big tables, but the query variables ultimately bring back one row - so I'm happy with the query (less than half a second on the old server). So annoying!
 
Soldato
OP
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
Old server had 24GB (currently using 9GB) with a X5550 CPU @ 2.67ghz (8 cores)

New server has 64GB (currently using 60GB) with a E5-2630 v4 @ 2.20ghz (2 processors, 20 cores, 40 logical)
 
Permabanned
Joined
9 Aug 2009
Posts
12,236
Location
UK
OK so I think the first time you run the query it's fetching data from disk and loading it into memory.
The second time you run, the data is already in memory so it's faster.
When you clear the cache you remove the data from memory so it's slow again.

So I think you need to look at disk performance, read specifically.
Probably some generic benchmarks around for that.
 
Associate
Joined
21 Mar 2011
Posts
18
There is some sound advice above, but one thing I've not yet seen suggested is for you to set the database to 2008 compatibility mode. There are changes to various parts of the storage and relational engines between 2008 and later (more so 2016+) SQL Server releases which can affect the cardinality estimates and the resulting query plans for the worse.
 
Soldato
OP
Joined
5 Mar 2003
Posts
10,757
Location
Nottingham
Yeah I changed the compatibility mode and no change unfortunately.
The hardware guys are running IO tests this evening... But as the statement completes quickly in the profiler and the batch takes long makes me doubt that. I'd rather the query just runs slow... But with stats time on etc the figures are good.
 
Soldato
Joined
30 Sep 2005
Posts
16,543
CPU Boost should definately be kept off. I originally thought disk performance, but I would be doubtful if that was the root cause.
Did you run any disk benchmarks as I suggested? Like I say, doubtful but who knows if it's an iffy raid driver causing slowdowns. We are talking seconds though, so unlikely.

Could you, as a side test build a second server running sql 2016 and take a copy of the database and run the same tests just to see what the performance is like? Do you have a spare server?

I'm not a fan of 2012. Had past woes with it. Running 2016 now and they are much better, but our queries run mega amounts of data so we can see small improvements make a big difference here.

also check BIOS settings, and even stuff like power management in windows. Everything needs setting to high/max performance.

Still thinking it's something within SQL itself rather than the server. What's the make/model?
 
Last edited:
Back
Top Bottom