Query in Sleep status
Is th开发者_运维技巧ere any way we can we find the query for the spid which is in sleep status? How can we find that why it is in sleep or suspend status? Please let me know.
A sleeping SPID is simply a client connection with no active query to the SQL Server. There will be no query associated with the SPID in this state.
You may see these as a result of applications using connection pooling where it would otherwise be expensive to keep opening and closing connections. The connection pool retains open connections that await further queries or batches. Without knowing your setup it is possible the sleeping SPIDs are associated with open connections in a pool.
Alternatively your client/application may not be closing connections after it's work is done. If you are getting blocking issues, a sleeping SPID can lock resources if it has opened a transaction and not committed or rolled back.
If the sleeping connections are not causing any adverse problems (i.e. hundreds overloading the server) then it is not an issue and best left alone.
精彩评论