병렬 쿼리 테스트할 때 시작 파라메터에 -P값으로 코어 수 조정했었는데, DBCC OPTIMIZER_WHATIF를 사용하면 세션 단위로 시뮬레이팅할 수 있는 DBCC 명령어가 있다.
/* DBCC OPTIMIZER_WHATIF http://devondba.blogspot.kr/2014/03/dbcc-optimizerwhatif.html Parallelism in SQL Server Query Tuning - Itzik Ben-Gan http://sqlmag.com/sql-server/parallelism-sql-server-query-tuning Using Optimizer_WhatIF and StatsStream to Simulate a Production Environment https://www.simple-talk.com/sql/database-administration/using-optimizer_whatif-and-statsstream-to-simulate-a-production-environment/ -- SQL2012에 추가된 항목 LowCEThresholdFactorBy10 HighCEThresholdFactorBy10 CEThresholdFactorCrossover DMLChangeThreshold */ -- 결과를 클라이언트(SSMS)에 출력하기 위해 플래그 활성화 DBCC TRACEON (3604) -- Whatif 현재 상태 정보 반환 DBCC OPTIMIZER_WHATIF(Status) WITH NO_INFOMSGS; /* Optimizer what-if status (10가지 항목) --------------------------------------------------------- property_number current_value default_value property_name --------------------------------------------------------- 1 0 0 CPUs 2 0 0 MemoryMBs 3 0 0 Bits */ -- Reset 명령어 -- DBCC OPTIMIZER_WHATIF(ResetAll) WITH NO_INFOMSGS; -- 10가지 항목으로 시뮬레이팅 할 수 있는데, 그중 CPU와 메모리 값을 변경해 보자. -- 설정 : set the CPUs to 6 and the RAM to 32GB: DBCC OPTIMIZER_WHATIF(CPUs, 6) WITH NO_INFOMSGS; DBCC OPTIMIZER_WHATIF(MemoryMBs, 324768) WITH NO_INFOMSGS; -- 변경된 항목 확인 DBCC OPTIMIZER_WHATIF(Status) WITH NO_INFOMSGS; /* --------------------------------------------------------- Optimizer what-if status --------------------------------------------------------- property_number current_value default_value property_name --------------------------------------------------------- 1 6 0 CPUs 2 324768 0 MemoryMBs */ ------------------------------------------------------------------------------------- -- cpu, memory에 따른 실행 계획 비교 ------------------------------------------------------------------------------------- -- CASE 1 )코어 6개, 메모리 32G의 경우 실행계획 보기 SELECT * FROM Sales.SalesOrderDetail s INNER JOIN Production.Product p ON s.ProductID = p.ProductID ORDER BY p.Style OPTION (RECOMPILE); --REALLY IMPORTANT OTHERWISE IT MAY USE A CACHED PLAN -- CASE 2 ) 코어 1개 --USE DBCC OPTIMIZER_WHATIF Change to 1 core DBCC OPTIMIZER_WHATIF(ResetAll) WITH NO_INFOMSGS; DBCC OPTIMIZER_WHATIF(CPUs, 1) WITH NO_INFOMSGS; --confirm status again DBCC OPTIMIZER_WHATIF(Status) WITH NO_INFOMSGS; SELECT * FROM Sales.SalesOrderDetail s INNER JOIN Production.Product p ON s.ProductID = p.ProductID ORDER BY p.Style OPTION (RECOMPILE); --REALLY IMPORTANT OTHERWISE IT MAY USE A CACHED PLAN