My team is moving several hundred database objects from our QA server to our UAT server. All of the new objects are in two schemas that don't yet exist on the UAT database.
The first thing we do upon creating all these objects is run some very complex views to do an initial data population of our base tables (yes, the views are badly written, and it would be much more efficient to write them as stored procs, but this isn't the thrust of my question).
Most of our data load testing has been done in a database where all the objects already exist, and the performance is fine. The longest load is ten minutes.
However, when we move these new schemas/objects onto a different server and try the data load, the same code doesn't finish in 10 hours. However, if we try to run the underlying view separately, while we wait for the first exercise of the view to finish, it's very fast.
It seems obvious this is a problem with the optimizer (we've verified that the code is exactly the same between servers: we're not missing any indexes or stats). If we cancel our long-running queries and restart them, then the performance matches QA.
Here's what we've tried:
This stuff makes some difference, though it's still nowhere as quick as it is in our original environment.
What am I missing here? Beyond cleaning the optimizer, the indexes and the stats, what else could be driving the performance?
I also don't understand why the optimizer picks a terrible plan for the initial data load, but then, while that load is crawling along, it picks a great plan for the same code if I run that on another cnn.
SQL Version is SQL 2012, Svc Pack 3.
=========================
EDIT: I understand that nobody is going to be able to produce a piece of code that fixes my issue. I am curious if someone knows of an area I haven't explored yet. Examples:
I've seen faster hardware run slower because it can hit concurrency issues that don't crop up on the slower hardware, especially when more cores are introduced.
Check your MAXDOP settings. CXPacket waits can indicate parallelism contention. https://www.brentozar.com/archive/2013/08/what-is-the-cxpacket-wait-type-and-how-do-you-reduce-it/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With