Sql-server – Identify Query Waiting on resources

blockingparallelismperformanceperformance-tuningsql serverwaits

I have some query with CXCONSUMER wait time when i ran sp_whoisactive as shown in the screenshot below.

enter image description here
When i checked the status it is suspended.That means it is waiting for some process to release resource.As far as my understanding CXPACKET is the producer and CXCONSUMER is the consumer and CXPACKET is the main culprit and action should be taken on that.But i don't see any CXPACKET.
Since this is a parallel execution i am not sure where i should start fixing.

Can anyone suggest me how to find out the process on which my queries are waiting(because i see suspended as status)?

Additional Info

When i query sys.dm_os_wait_stats ,the top two entries are CONSUMER and CXPACKETS.

  • SQL Server 2016
  • 128 GB RAM
  • MAX DOP : 8
  • Cost of threshold : 20

Best Answer

Check out this post from Erik Darling: CXCONSUMER Is Harmless? Not So Fast, Tiger

That shows a really extreme example of a problem query where CXCONUSMER is the highest wait. So while the Microsoft recommendations indicate it's harmless, it definitely can be a sign of other problems.

Based on that, and your screenshot, it's quite possible that you're running into issues with skewed parallelism. You can find some great info about skewed parallelism from Paul Randal: More on CXPACKET Waits: Skewed Parallelism

In theory, waits due to skewed parallelism should be surfaced as CXPACKET waits. This doesn't appear to always be the case in practice at this time though.

Without the query text, and especially an actual execution plan, we can only guess at what might be causing the CXCONSUMER waits for your scenario. But hopefully this helps gives you a direction to look in.

If you edit your question to include the execution plan and query text (and relevant table / index definitions), we can be more help in tracking down the root cause.