重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 875|回复: 0
打印 上一主题 下一主题

sql server 性能调优 资源等待之 CXPACKET

[复制链接]
跳转到指定楼层
楼主
发表于 2023-5-24 09:01:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jiawang 于 2023-5-24 09:29 编辑

  
cxpacket
   CXPACKET is one of the famous wait type that database administrators are experiencing. Before moving into the details of CXPACKET wait type, first let us discuss about the waits in SQL Server in brief.
   CXPACKET是数据库管理员正在经历的著名的等待类型之一。
在进入CXPACKET等待类型的细节之前,首先让我们简要讨论一下SQL Server中的等待。
   SQL Server is a mini operating system. When SQL Server is executing any task and if for any reason it has to wait for resources to execute the task, it will wait in a list until it gets the relevant resources. This list is called Waiter list or suspended list. This is not a queue as whenever that task is ready with required resources it will move to the runnable queue which means that it is ready to execute whenever the processor is free to execute. Depending on the type of the wait, there are more than 200 wait types. CXPACKET, WRITELOG, ASYNC_NETWORK_IO are the most common wait types. This is very brief discussion about waits. For any case where this is not clear, it will be better to get more details from other sources as this article is not intend to discuss about waits in detail.
   SQL Server是一个小型操作系统。 当SQL Server执行任何任务时,如果由于某种原因必须等待资源来执行任务,它将在列表中等待,直到获得相关资源为止。 此列表称为服务员列表或暂挂列表。 这不是队列,因为只要该任务准备好所需的资源,它将移至可运行队列,这意味着只要处理器有空执行,它就可以执行。 根据等待的类型,有200多种等待类型。 CXPACKET,WRITELOG,ASYNC_NETWORK_IO是最常见的等待类型。

   The CXPACKET wait type is the one of the most common wait type if not the most. According to the survey done at sqlskils.com, out of the waits that are occurring in the surveyed systems, more than 25% are CXPACKET wait types. That tells you how frequent CXPACKET wait type is.
   CXPACKET等待类型是最常见的等待类型之一(如果不是最多的话)。 根据sqlskils.com进行的调查,在被调查系统中发生的等待中,超过25%是CXPACKET等待类型。

   CXPACKET occurs when a parallel operation is created for a task. The query processor may determine that a particular operation can be performed more efficiently by using multiple threads depending on the cost of the query. At the execution time, the query execution portion of the query processor decide what parallelism to use. For example, if you are executing a query which deals with a large portion of a table, multiple threads are required. This is a common phenomenon when queries running in a fact table in a data warehouse system as typical query in a fact table needs a large portion of the data to be extracted. After identifying the number of threads needed to execute the query, it will decide which portion to be executed by which thread. Ideally, load will be divided equally among the threads. This scenario is displayed in the following diagram:
   为任务创建并行操作时,将发生CXPACKET。 查询处理器可以根据查询的成本确定通过使用多个线程可以更有效地执行特定操作。 在执行时,查询处理器的查询执行部分决定使用哪种并行性。 例如,如果您正在执行处理表的大部分的查询,则需要多个线程。 当在数据仓库系统中的事实表中运行的查询时,这是一种常见现象,因为事实表中的典型查询需要提取大部分数据。 确定执行查询所需的线程数后,它将决定由哪个线程执行哪个部分。

理想情况下,负载将在线程之间平均分配。 下图显示了这种情况:
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-26 10:36 , Processed in 0.107695 second(s), 22 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表