February 12, 2024 at 6:43 pm
Hi All,
One of the app query is running slow. When I saw the spid's waitype, it is CXPACKET. After digging further one of the thread is waiting for SOS_SCHEDULER_YIELD. question I have is, except this query nothing else is running at that moment. only small other queries coming and exiting. When I observed the windows task manager, Server CPU usage is under 15% utilization. VM has 32 cpus. Why it is had to wait for SOS_SCHEDULER_YIELD.when it is not a high cpu condition on the server? How to troubleshoot and fix such queries?
Regards,
Sam
February 13, 2024 at 2:37 pm
Looks that SOS_SCHEDULER_YIELD is a benign wait. The cpu was fully utilized
What is the parallelism setting for this query?
If maxdop= 1 results in 1 vcpu /32 vcpu = 3% of total cpu usage
February 13, 2024 at 4:10 pm
Does the virtual host have at least one physical core per virtual processor provisioned to all guest VMs on the host?
You can of course oversubscribe processor resources to a degree, but SQL can be a workload that does not like to be oversubscribed.
What is your maxdop? I hope it isn't set to 0?
February 13, 2024 at 5:17 pm
maxdop is set to 1 at instance level and at database level it is set to 4. looks like each operator within plan is taking 4 threads
February 13, 2024 at 6:38 pm
I do believe that the database level setting overrides the instance level setting.
Is this a purely/high majority OLTP application? The problem could be excessive parallelism.
High SOS scheduler yield waits with low CPU is a pretty classic sign of oversubscribed virtualization hosts.
CX waits are really tough to make a determination from on their own without other context
February 14, 2024 at 1:31 pm
Have you looked at the execution plan for the query in question? That's going to tell you a whole lot about how it's being executed, what resources are being used, etc. Estimated plan will give you most of what you need, so you can pluck it from Query Store or the cache. If you can execute the query and capture a plan with runtime metrics you'll get more info to help with determining what is happening and why.
"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
February 14, 2024 at 11:11 pm
maxdop is set to 1 at instance level and at database level it is set to 4. looks like each operator within plan is taking 4 threads
Is the "query" an UPDATE by any chance?
Either way, can you post the query, please.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 15, 2024 at 6:38 pm
Another thing - is there a query hint to put the MAXDOP to another value? I know you can set that at the instance level, database level, and query (or stored procedure) level.
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
February 16, 2024 at 7:25 am
vsamantha35 wrote:maxdop is set to 1 at instance level and at database level it is set to 4. looks like each operator within plan is taking 4 threads
Is the "query" an UPDATE by any chance?
Either way, can you post the query, please.
Yes Sir. it is bunch of updates. its running over 6 hours, I feel something wrong with their joins and filters. I ll post the query and actual plan if i can collect.
February 16, 2024 at 1:47 pm
Estimated plan can tell us a lot. Sure, actual plan tells you more, but just plucking the plan out of cache goes a long way.
"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
February 16, 2024 at 3:01 pm
Jeff Moden wrote:vsamantha35 wrote:maxdop is set to 1 at instance level and at database level it is set to 4. looks like each operator within plan is taking 4 threads
Is the "query" an UPDATE by any chance?
Either way, can you post the query, please.
Yes Sir. it is bunch of updates. its running over 6 hours, I feel something wrong with their joins and filters. I ll post the query and actual plan if i can collect.
Heh... say "Happy Halloween". 😀
Heh... dollars to donuts it turns out to be what I lovingly call a "Death by SQL" update, which is more appropriately called an "Illegal Form of Joined Update". Please see the following old but still very pertinent article on the subject. I can vouch for the author and his findings. 😀
https://www.sqlservercentral.com/articles/more-rbar-and-tuning-updates-1
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply