問題描述:生產環境一個數據庫從SQLSERVER 2008 R2升級到SQLSERVER 2012 ,同時更換硬件,但遷移後發現性能明顯降低,應用寫入、讀取性能降低的比較厲害;算法
向微軟尋求幫助後得出答案,原來這與SQLSERVER的安裝介質有關。sql
大體意思是說因爲NUMA架構能夠自行管理內存池,在安裝了CAL的EE後,因爲限制只能使用20個cores,一樣內存則只能管理到20個cores涉及到的NUMA的對應的內存空間(具體算法爲 限制內存=當前物理內存/NUMA數量*(總核數/20)),若是限制SQL Server的最大使用內存超過前面說的限制內存,則當使用內存大於限制內存須要再向操做系統再申請空間時,則會產生跨NUMA處理的狀況,致使大量消耗系統資源,引發性能降低;數據庫
http://blogs.msdn.com/b/saponsqlserver/archive/2012/06/15/sql-server-2012-enterprise-editions.aspx架構
這是我在網上找到的解釋,摘錄其中幾段(本人E文水平有限,翻譯不當之處敬請見諒)app
關於SQLSERVER EE的安裝介質(EE爲Enterprise Editions簡拼,企業版)socket
上面說到 即使是SQLSERVER EE,因爲受權方式的差別致使對processor cores的限制ide
For customers with Software Assurance on existing SQL EE Server licensessqlserver
An Enterprise Edition which is licensed per core and which does not have limits on the # of cores usable on a server性能
經過如下方式能夠檢查當前運行的SQL EE信息ui
一、sp_readerrorlog ,第一行顯示SQLSERVER 版本信息以下
2012-05-08 16:04:54.56 Server Microsoft SQL Server 2012 - 11.0.2100.60 (X64)
Feb 10 2012 19:39:15
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit)on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
二、select serverproperty('Edition') ,顯示版本信息以下
Enterprise Edition (64-bit)
如何判斷當前的SQL EE是基於per CAL仍是per core的呢?若是顯示的信息如上所示,那就是基於per CAL的,文中再次強調此模式下受限於20 cores;
Answer is: It is the CAL licensed one and with that the Enterprise Edition which is limited to 20 cores!!!
而若是顯示的信息以下所示,那就是基於per core的 則沒有限制;
The per-core licensed Enterprise Edition will show like this:
2012-05-18 23:57:29.77 Server Microsoft SQL Server 2012 - 11.0.2100.60 (X64)
Feb 10 2012 19:39:15
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
Executing:
select serverproperty('Edition')
which then could show this result:
Enterprise Edition: Core-based Licensing (64-bit)
關於20 cores的限制問題,須要區分CPU是否支持超線程而言
Other indications that there might be a limitation to 20 cores could be identified as well at the beginning of the SQL Server 2012 errorlog where we can find a message like:
SQL Server detected 4 sockets with 6 cores per socket and 6 logical processors per socket, 24 total logical processors; using 20 logical processors based on SQL Server licensing.
In the case above, we are looking at a server with the last generation of Intel processors which did not have Hyperthreading yet. Or in more modern Intel Servers with Hyperthreading it would look like:
SQL Server detected 4 sockets with 8 cores per socket and 16 logical processors per socket, 64 total logical processors; using 40 logical processors based on SQL Server licensing.
上文中的描述,根據SQL Server 2012 errorlog中的內容,咱們能夠看到
若是SQL Server 檢測到 4個插槽,每一個插槽有6個核,且有6個邏輯處理器(單線程),則總共爲24個邏輯處理器,受限於SQL Server licenseing,只能使用20個邏輯處理器;
對於超線程CPU:
若是SQL Server 檢測到 4個插槽,每一個插槽有8個核,且有16個邏輯處理器(單線程),則總共爲64個邏輯處理器,受限於SQL Server licenseing,只能使用40個邏輯處理器;
Another possibility of discovery is through the Microsoft MAP toolkit. Where to get it and how to use it is excellently described in this document: http://download.microsoft.com/download/F/F/2/FF29F6CC-9C5E-4E6D-85C6-F8078B014E9F/Determining_SQL_Server_2012_Core_Licensing_Requirements_at_SA_Renewal_Apr2012.pdf
另一種可能的發現是經過Microsoft MAP toolkit,能夠在如下這個文檔中獲得更準確的描述;
---------------------------華麗麗的分割線---------------------------------------
The limitation or the cap is enforced by the # of SQL Server schedulers. Usually SQL Server creates one scheduler thread for every logical CPU on a server. Each of those scheduler threads is administrating a pool of worker threads which execute requests or are in different other states. A scheduler only can have one thread running at maximum. If a scheduler thread over all of the time has one of worker threads running, it can leverage at maximum one logical CPU and not a bit more. If there are (as in the second situation above) only 40 schedulers active to schedule worker threads, the maximum number of CPU power we can use at any given time is 40 logical CPUs.
Querying sys.dm_os_schedulers with this query:
select * from sys.dm_os_schedulers
we will realize that the all the schedulers are ‘Visible’ for all the logical CPUs, but only 40 of them will be ‘Online’, whereas the others are ‘Offline’
If you disable Hyperthreading, the number of schedulers being Online will decline to 20, since one single core is now represented by one CPU thread only compared to two with Hyperthreading enabled. In cases where there are many more CPU threads or logical CPUs than the limit of the Server+CAL licensed SQL Server 2012 Enterprise Edition, one certainly can use affinity mask settings to chose the CPUs SQL Server shall use.
經過sys.dm_os_schedulers這個DMV能夠查詢到SQL Server調度線程的狀況;
如何在EE的兩個不一樣的產品間變動?在下面的連接中能夠找到答案