通俗的例子解释SQL的各种运行状态
2012-07-24 10:13
274 查看
The SQL Server SQLOS uses schedulersto manage the execution of user requests. SQLOS Schedulers map to CPUs. Assuminga 4-CPU Server, there would be 4 SQLOS schedulers by default. The following diagrams depict
a simplifiedversion of execution model using a single SQLOS scheduler. The execution model in Figure 1 depicts how SQL Serveruser requests or sessions (denoted by SPIDs) are scheduled for execution.
Figure 1: Execution Model – Running, runnable and suspendedstatus, Runnable Queue and Wait List
Figure 2 shows how SQL Server sessionsrotate between the following statuses:Running(only one session can be running or executing, per scheduler),Runnable
(sessions waiting for CPU), orSuspended. SPIDs with suspended statuses are placedin Waiter List until the requested resources are available. If a running sessionneeds a data page that is not in cache, or needs a page that is blocked
byanother user’s lock, the session is moved to the wait list. The next SPID or session_idin the runnable queue is scheduled to start running.
Figure 2: Execution Model – How status changes affect SPIDs
The status change sequence of events is as follows:
SPID60 needs a page not in cache. Thus its status changes from Running to Suspended with wait type IO_Completion
SPID60 moved to Waiter List
SPID51 moves from Runnable queue with a runnable status to Running status, SPID64 then moves to the top of the Runnable queue
SPID56 is waiting for a parallel process to complete. When the parallel process is completed, the status for SPID56 changes from Suspended with wait type CXPACKET to Runnable
SPID56 moved to the bottom of the Runnable queue
Figure 3 depicts execution “after”session_ids (or SPIDs) have rotated clockwise due to status changes.
Figure 3: Execution Model – After status change
The wait list means a thread has to wait for aresource. Example of resource waits includes IOs to complete, a lock to bereleased, a memory grant, and so on. When the sessionis moved to the wait list, a wait type is assigned and time is accumulated.When the
resource becomes available, the thread is moved to the runnable queueand it executes as soon as the CPU is available. The clockwise rotation between running,runnable and suspended states continues until the user request is completed.
具体参考微软白皮书:Performance_Tuning_Waits_Queues.doc
a simplifiedversion of execution model using a single SQLOS scheduler. The execution model in Figure 1 depicts how SQL Serveruser requests or sessions (denoted by SPIDs) are scheduled for execution.
Figure 1: Execution Model – Running, runnable and suspendedstatus, Runnable Queue and Wait List
Figure 2 shows how SQL Server sessionsrotate between the following statuses:Running(only one session can be running or executing, per scheduler),Runnable
(sessions waiting for CPU), orSuspended. SPIDs with suspended statuses are placedin Waiter List until the requested resources are available. If a running sessionneeds a data page that is not in cache, or needs a page that is blocked
byanother user’s lock, the session is moved to the wait list. The next SPID or session_idin the runnable queue is scheduled to start running.
Figure 2: Execution Model – How status changes affect SPIDs
The status change sequence of events is as follows:
SPID60 needs a page not in cache. Thus its status changes from Running to Suspended with wait type IO_Completion
SPID60 moved to Waiter List
SPID51 moves from Runnable queue with a runnable status to Running status, SPID64 then moves to the top of the Runnable queue
SPID56 is waiting for a parallel process to complete. When the parallel process is completed, the status for SPID56 changes from Suspended with wait type CXPACKET to Runnable
SPID56 moved to the bottom of the Runnable queue
Figure 3 depicts execution “after”session_ids (or SPIDs) have rotated clockwise due to status changes.
Figure 3: Execution Model – After status change
The wait list means a thread has to wait for aresource. Example of resource waits includes IOs to complete, a lock to bereleased, a memory grant, and so on. When the sessionis moved to the wait list, a wait type is assigned and time is accumulated.When the
resource becomes available, the thread is moved to the runnable queueand it executes as soon as the CPU is available. The clockwise rotation between running,runnable and suspended states continues until the user request is completed.
具体参考微软白皮书:Performance_Tuning_Waits_Queues.doc
相关文章推荐
- 各种帮助查询数据库以及运行状态的SQL查询语句
- mysql 从库I/O及SQL thread 状态解释
- 域名各种状态的解释说明
- sql左联右联内联的通俗解释
- java多线程基础(1)-由调度方式引入线程各种运行状态
- SQL复制订阅(发布作业名称)作业被DBA用户拒绝,订阅日志读取器代理自动停止,订阅状态未运行。
- Activity具体解释(生命周期、以各种方式启动Activity、状态保存,全然退出等)
- 运行cmd状态下MySQL导入导出.sql文件
- 运行cmd状态下MySQL导入导出.sql文件
- 各种数据库如何运行sql文件?
- Sql server 日记 (查看Sql server JOB 运行状态)
- PB 数据库连接以及sql语句运行信息返回代码解释大全
- IBM-DB2中运行e-sql例子程序makefi…
- Activity详细解释(生命周期、以各种方式启动Activity、状态保存,等完全退出)
- 各种垃圾回收算法的通俗解释(转)
- [数据库测试]强烈推荐一个python ODBC数据源插件,可支持Oracle,Db2,Mysql,Sql-server以及各种数据库版本,附例子和测试程序
- 各种垃圾回收算法的通俗解释
- 运行sklearn-theano的一个例子:benchmark (卷积的各种参数设置)
- Bugzilla各种状态详细解释
- http各种状态解释