SQL Server中的「最大並行度」的配置建議

2021-09-07 19:27:36 字數 2637 閱讀 1615

原文:

sql server中的「最大並行度」的配置建議

sql server中的最大並行度(max degree of parallelism)如何設定呢? 設定max degree of parallelism有什麼好的建議和指導方針呢?

在微軟官方文件recommendations and guidelines for the "max degree of parallelism" configuration option in sql server有這方面的建議和指導方針

use the following guidelines when you configure the maxdop value.

sql server 2005 and later versions

server with single numa node

less than 8 logical processors

keep maxdop at or below # of logical processors

server with single numa node

greater than 8 logical processors

keep maxdop at 8

server with multiple numa nodes

less than 8 logical processors per numa node

keep maxdop at or below # of logical processors per numa node

server with multiple numa nodes

greater than 8 logical processors per numa node

keep maxdop at 8

個人覺得上面關於(max degree of parallelism)的建議、指導方針有點抽象、不太科學。因為不同的系統的負載可能不一樣。這樣乙個籠統的建議實在讓人覺得缺少合理的依據。

另外一種關於(max degree of parallelism)的推薦設定是根據系統型別(也可以理解為系統負載)來設定,具體建議如下所示:

oltp系統:

在純oltp系統上,它的事務較短,sql查詢時間短,但是非常頻繁。設定「maximum degree of parallelism」(maxdop)為1。這樣做可以確保查詢永遠不必使用並行方式執行,並且不會導致更多的

引擎開銷。

olap系統:

data-warehousing / reporting server: 因為查詢執行時間一般較長,建議設定「maximum degree of parallelism」(maxdop)為0。

這樣大多數查詢將會利用並行處理,執行時間較長的查詢也會受益於多

而提高效能。

混合系統

mixed system (oltp & olap):這樣環境會是乙個挑戰,必須找到正確的平衡點。一般採取了非常簡單的方法。設定「maximum degree of

parallelism」(maxdop)為2,這樣意味著查詢仍會使用並行操作但是僅利用2顆cpu。並且把「並行查詢閥值」(cost threshold for parallelism)設定為較高的值,這樣的話,不是所有的查詢都有資格使用並行,除了那些查詢成本較高的查詢………

cost threshold for parallelism選項可設定為 0 到 32767 之間的任何值。預設值為 5。

個人比較傾向於第二種(max degree of parallelism)設定的指導方針,混合系統設定max degree of parallelism,建議結合第一種推薦設定與第二種,然後結合等待事件cxpacket的情況,作出適當的調整。不要指望一成不變的推薦設定,這樣是不合理。只能根據比較大眾的推薦設定,然後結合自身系統的具體情況,作出適當的調整、優化。

對於numa與smp不太清楚的地方,可以參考下面資料。

傳統的多核運算是使用smp(symmetric multi-processor )模式:將多個處理器與乙個集中的儲存器和i/o匯流排相連。所有處理器只能訪問同乙個物理儲存器,因此smp系統有時也被稱為一致儲存器訪問(uma)結構體系,一致性意指無論在什麼時候,處理器只能為記憶體的每個資料保持或共享唯一乙個數值。很顯然,smp的缺點是可伸縮性有限,因為在儲存器和i/o介面達到飽和的時候,增加處理器並不能獲得更高的效能。

numa模式是一種分布式儲存器訪問方式,處理器可以同時訪問不同的儲存器位址,大幅度提高並行性。 numa模式下,處理器被劃分成多個"節點"(node), 每個節點被分配有的本地儲存器空間。 所有節點中的處理器都可以訪問全部的系統物理儲存器,但是訪問本節點內的儲存器所需要的時間,比訪問某些遠端節點內的儲存器所花的時間要少得多。

sql server 2005開始支援numa,可參考

sql server 2008的numa支援

。需要注意的是,硬體、作業系統、應用軟體 三者都要支援 numa ,才能充分利用這一特性

SQL Server中的「最大並行度」的配置建議

sql server中的最大並行度 max degree of parallelism 如何設定呢?設定max degree of parallelism有什麼好的建議和指導方針呢?在微軟官方文件recommendations and guidelines for the max degree of...

SQL Server中的「最大並行度」的配置建議

sql server中的最大並行度 max degree of parallelism 如何設定呢?設定max degree of parallelism有什麼好的建議和指導方針呢?在微軟官方文件recommendations and guidelines for the max degree of...

SQL Server中的「最大並行度」的配置建議

sql server中的最大並行度 max degree of parallelism 如何設定呢?設定max degree of parallelism有什麼好的建議和指導方針呢?在微軟官方文件recommendations and guidelines for the max degree of...