Share via

SQL - Select Statement taking time to execute - No Blocking/No High Utilization

Yogesh Bhadauriya 26 Reputation points
2023-08-25T13:37:05.9533333+00:00

I am having Dynamic CRM product, where one select statement is always taking time to execute from the application.

select    new_OrderNo, new_LineNumber, new_ProductNumber   
from    [CRM Sales History Table]
where CreatedOn >= DATEADD(Day, -30, getdate())   
and OwnerId = '92e58b27e70143519c80347562ea7111'

I validated the all SQL resourecs & didn't find anything unusal. Note that whenever I manualy run this query, it is executing within a second.

Attached Execution plan of the query

Execution Plan

Any guidance why this happend ? Note : No blocking, No high CPU/Memory utilization

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
2023-08-31T20:42:44.0066667+00:00

I checked all the options, somehow this query is stuck in "ASYNC_NETWORK_IO" wait type.

That explains everything. It is most likely an application issue. This wait type means that SQL Server is waiting for the client to fetch the data from the output buffer. There are be two reasons for this error:

  1. Network issue. In your case it would happen if the application server for Dynamics CRM has a modem connection of 9600 baud to SQL Server. Well maybe not that bad, but definitely a connection below par.
  2. The application itself is misbehaving. Rather than reading all rows in one fell swoop, it reads a row, performs some calculations or whatever, then reads the next row etc.

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Javier Villegas 905 Reputation points MVP
    2023-08-26T11:09:05.5566667+00:00

    I will suggest to use sp_whoisactive from Adam Machanic to identify the statement when is running from the application . Using the option to retireve the execution plan so you can checki is i the same as in SSMS

    https://www.brentozar.com/archive/2010/09/sql-server-dba-scripts-how-to-find-slow-sql-server-queries/

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.