Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 5123

How long does a select hold a SCH-S lock?

$
0
0

Here's a situation.

A perfectly normal select statement finds maybe 20,000 rows to return to the client, but is apparently held up with ASYNC_NETWORK_IO waits.  It's in an SP, it's running read committed, and that one select is the whole SP.  Yet somehow it's apparently causing LCK_M_SCH_S waits, which I assume means it's holding a schema stability lock.  This is what it all looks like.

So does a select statement really need to hold a lock after it has gotten results and yet has not returned them all yet?  In this case there is no order-by, so it may have been streaming the results, which you'd think would be harmless but in this case was not, it ended up running/blocked for half an hour and blocked ten other SPIDs by the time we killed it.

SQL 2014, talking directly to the middle tier of a C# application, afaik.

Thanks,

Josh


Viewing all articles
Browse latest Browse all 5123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>