March 9, 2023 at 5:46 pm
I have a process that uses 2 tables in PROD and it has been running slow in PROD.
The tables are identical in UAT and the process runs much faster in UAT.
What is the best way to tackle this....I was thinking of using Extended Events to capture the details.
Is this the best approach? Plz advise
Regards,
SQLisAwe5oMe.
March 9, 2023 at 6:33 pm
Most likely causes:
Bad statistics in production
Parameter sniffing
Production hardware is different than staging or production hardware is oversubscribed. If UAT is in a dev cluster that is lightly used, it could be fast in spite of the hosts being oversubscribed where in production everything is being used and the virtual host that has 10 Virtual cores issued for every actual CPU on the host is struggling leading to time sharing among the guests.
use first responder toolkit sp_BlitzCache to find your slow query then run the command it gives you in one of the right most columns to remove the plan from cache. If the query is fast after that, it is parameter sniffing.
If it is still slow, do a statistics update. If it is still slow, question the hardware provided to the SQL server.
If none of those are it, there are a bunch of other branches of events that could be causing it.
March 9, 2023 at 6:47 pm
The question is a little vague so I'm afraid I can only give a broad answer in return. DEV/Staging environments don't typically have the same amount of data so check for issues with your query. It's not uncommon for inefficient code to work fine in dev only to be problematic in production. So without knowing any more specifics check that you have appropriate indexes to accommodate the query. Also, check the execution plan and look for any issues. That would be at the bare minimum the first things I would look at. The truth is there could be so many reasons why this is happening. Start with the basics and work your way up.
March 9, 2023 at 6:49 pm
Look at the execution plan on both databases.
March 9, 2023 at 6:54 pm
Thanks everyone for the responds....I will start with basics.
Do you have the link for "first responder toolkit sp_BlitzCache"
Regards,
SQLisAwe5oMe.
March 9, 2023 at 7:49 pm
Thanks everyone for the responds....I will start with basics.
Do you have the link for "first responder toolkit sp_BlitzCache"
That is part of a package of free tools provided by the most excellent Brent Ozar. https://www.brentozar.com/blitz/
Those tools are great to have in your arsenal, but they might actually overwhelm you at first if you are not quite sure what you are looking for. I know examining an execution plan can be overwhelming at first but it truly is a right of passage. You don't need to be an expert to be able to identify obvious issues such as incorrect cardinality estimates, index scans vs seeks, nested vs merge joins, etc... Also recognize when something is just a red herring. Index scans aren't necessarily an issue (and likely more efficient) on small tables for example.
March 9, 2023 at 9:45 pm
I have a process that uses 2 tables in PROD and it has been running slow in PROD.
The tables are identical in UAT and the process runs much faster in UAT.
What is the best way to tackle this....I was thinking of using Extended Events to capture the details.
Is this the best approach? Plz advise
The very first thing to check is the rowcount differences in the tables between that UAT and Prod databases. That will probably explain the differences.
The next step, if the data is less, is to forget about UAT and figure out what's going on with the "process" in Prod. While I agree that Brent's code is fabulous for a lot of things, it won't replace the knowledge required to look at execution plans to find the "high spots" to begin working on. You also need to know what to look for in the code like non-SARGable predicates and more.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 9, 2023 at 10:32 pm
Thanks....the 2 tables in question are pretty small and have same amount of rows in both UAT & PROD
I've updated the STATISTICS on both tables and waiting for user to give me feedback.
Regards,
SQLisAwe5oMe.
March 10, 2023 at 7:40 am
Thanks....the 2 tables in question are pretty small and have same amount of rows in both UAT & PROD
I've updated the STATISTICS on both tables and waiting for user to give me feedback.
Have you checked to see if they have the same indexes?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 10, 2023 at 2:42 pm
SQLisAwe5oMe wrote:Thanks....the 2 tables in question are pretty small and have same amount of rows in both UAT & PROD
I've updated the STATISTICS on both tables and waiting for user to give me feedback.
Have you checked to see if they have the same indexes?
Oh my gosh this!!!
And the same structures, etc. If we're comparing performance, it has to be like-to-like. Same versions of SQL Server. Same server and database settings. Same connection string settings. All of it.
However, the fastest way to gain a quick understanding would be to get the execution plans for each query. Pull them straight out of the cache on the servers (or Query Store if it's enabled) and you'll see pretty much exactly why you're getting different performance and probably guideposts on how to improve it. I wouldn't recommend, in this instance, using Extended Events because capturing plans is extremely expensive (it is in Trace too).
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply