解釋 SQL Server 的狀態值 Runnable、Running、Suspended、Sleeping

  • 341
  • 0

參考: https://www.cnblogs.com/WizardWu/p/13649548.html

status 欄位的值,有這幾種 : Pending, Runnable, Running, Suspended, Sleeping, Dormant, Background, Spinlock

  • "pending" (等待),代表這個 process,既沒有 Thread 可用,也沒有 CPU 可用,正在同時等待這兩項系統資源。
  • "runnable",代表這個 process,有 Thread 可用,但沒有 CPU 可用,所以它正在等待 CPU 這項系統資源。
  • "running",代表這個 process,有 Thread 可用,有 CPU 可用。
  • "suspended" (暫停),代表這個 process,正在「等待」別的 process 執行,等待的系統資源可能是 Disk I/O 或資料庫的 Lock。
    版工註:若這個 process 執行的 SELECT 沒加上 NOLOCK 關鍵字,而別的 process 正在進行「交易」或寫入 (會加 Lock),則這個 SELECT 的 process 就會呈現 "suspended" 的狀態。
  • "sleeping",代表這個 process,目前沒在做任何事,正在等待進一步的指令。
  • "dormant" (暫時擱置),代表 SQL Server 正在對這個 process 做 reset。
  • "background",代表這個 process 正在 SQL Server 背景執行。 即使你看到有很多 "background" process 正在執行,也不必擔心。
  • "spin lock",essentially means that query is in kind of running mode where it is busy waiting in cpu for its own turn.