{"id":828,"date":"2012-03-27T10:00:45","date_gmt":"2012-03-27T14:00:45","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=828"},"modified":"2012-03-25T13:24:08","modified_gmt":"2012-03-25T17:24:08","slug":"optimizer-what-if-i-had-more-cpus","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/","title":{"rendered":"Optimizer, what if I had more CPUs?"},"content":{"rendered":"<div>\n<p>\nIn the March issue of SQL Server Pro Itzik Ben-Gan wrote about an undocumented DBCC command that was recently discovered in the wild by Eladio Rincon (<a href=\"http:\/\/www.sqlmag.com\/article\/sql-server\/options-affecting-parallelism-141505\" target=\"_blank\">http:\/\/www.sqlmag.com\/article\/sql-server\/options-affecting-parallelism-141505<\/a>).<br \/>\nItzik closed the article by expressing his hope to get this statement documented as it can be very helpfull to database professionals trying to performance tune<br \/>\na query on a none production system, that does not completely match the production environment.\n<\/p>\n<p>\nI agree with this opinion, and so I decided to spend some time investigating this functionality further.<\/p>\n<p><h3>Optimizer_WhatIf?<\/h3>\n<p>\nThe DBCC command is the OPTIMIZER_WHATIF cammand. DBCC HELP gives you the following information about it:\n<\/p>\n<p><pre>\r\ndbcc OPTIMIZER_WHATIF ({property\/cost_number | property_name} [, {integer_value | string_value} ])\r\n<\/pre>\n<\/p>\n<p>\nThis is &ndash; according to Google &ndash; the only publicly available information about this command. Eladio discovered it in use at a customer site.<br \/>\nThe customer was told by Microsoft that with the first parameter equal to one, the second would influence parallelism decisions of the optimizer.\n<\/p>\n<p>\nAfter reading Itziks article it seemed clear that the \"1\" meant \"number of schedulers\" or \"number of CPUs\".<br \/>\nThe above documentation snippet says that you can either specify a number or a name for the first parameter, so knowing the possible non-numeric values<br \/>\nfor it would be a start in understanding what else this command does.\n<\/p>\n<h3>Finding Strings<\/h3>\n<p>\nEvery windows programm has to somehow contain the strings it is using. SQL Server is no exception. A well designed program will have related strings close by each other.\n<\/p>\n<p>\nYou can use a program like <a href=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb896653\" target=\"_blank\">Mark Russinovich's Process Explorer<\/a><br \/>\nto get a list of all strings in the memory space of a running process.\n<\/p>\n<p>\nAs all statements (including DBCC commands) are strings, you can expect to find the possible values for the first parameter next to each other. With that thought in mind I went ahead and<br \/>\nsearched for strings containing \"CPU\" or \"scheduler\". I found this list of possible property_name values for SQL Server 2008 and SQL Server 2008 R2:<\/p>\n<pre>\r\nStatus\r\nResetAll\r\nCPUs\r\nMemoryMBs\r\nBits\r\nParallelCardThreshold\r\nParallelCostThreshold\r\nParallelCardCrossProd\r\n<\/pre>\n<p>In SQL Server 2012 these properties were added.<\/p>\n<pre>\r\nLowCEThresholdFactorBy10\r\nHighCEThresholdFactorBy10\r\nCEThresholdFactorCrossover\r\nDMLChangeThreshold\r\n<\/pre>\n<p>DBCC OPTIMIZER_WHATIF was available in SQL Server 2005 as well, but \"ResetAll\" and \"Status\" are not working, so I did not investigate further.\n<\/p>\n<h5>Warning<\/h5>\n<p>\nAll property names are case sensitive, even in a case insensitive installation! You also will not get an error message if an invalid name or value is passed in, so be careful.\n<\/p>\n<h3>Many More CPUs<\/h3>\n<p>\nThe third one, \"CPUs\" causes the functionality described by Itzik: If you run <\/p>\n<pre>DBCC OPTIMIZER_WHATIF(CPUs, 16) WITH NO_INFOMSGS;<\/pre>\n<p>the optimizer will subsequently optimizer all statements submitted in the same session as if the system had 16 CPUs.\n<\/p>\n<h3>Administrative Help<\/h3>\n<p>\nIf you run<\/p>\n<pre>DBCC OPTIMIZER_WHATIF(ResetAll) WITH NO_INFOMSGS;<\/pre>\n<p>all changes caused by this DBCC command to the current session are undone.\n<\/p>\n<p><pre>DBCC OPTIMIZER_WHATIF(Status) WITH NO_INFOMSGS;<\/pre>\n<p>finally gives you the currently set values and their defaults. It also returns the integer representation of each property:<\/p>\n<pre>\r\n---------------------------------------------------------\r\n\r\nOptimizer what-if status\r\n\r\n---------------------------------------------------------\r\n\r\nproperty_number current_value default_value property_name\r\n\r\n---------------------------------------------------------\r\n\r\n         1                  0             0 CPUs\r\n\r\n         2                  0             0 MemoryMBs\r\n\r\n         3                  0             0 Bits\r\n\r\n         4               1000          1000 ParallelCardThreshold\r\n\r\n         5                  1             1 ParallelCostThreshold\r\n\r\n         6                200           200 ParallelCardCrossProd\r\n\r\n         7                 50            50 LowCEThresholdFactorBy10\r\n\r\n         8                 12            12 HighCEThresholdFactorBy10\r\n\r\n         9             100000        100000 CEThresholdFactorCrossover\r\n\r\n        10                 10            10 DMLChangeThreshold\r\n<\/pre>\n<p>(As with all undocumented DBCC commands, you first need to run \"DBCC TRACEON (3604) WITH NO_INFOMSGS;\" in your session to get any output.)\n<\/p>\n<h3>Conclusion<\/h3>\n<p>\nThis DBCC command is a great tool, when you are trying to answer questions like: What if the optimizer had more (or less) CPUs available than there are in my current system.\n<\/p>\n<p>\nAs with all undocumented functionality however, don't use this in production unless advised to do so by Microsoft support.\n<\/p>\n<p>\nThis post covered only three of the possible values for the first parameter. The other ones will be addressed in future posts.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the March issue of SQL Server Pro Itzik Ben-Gan wrote about an undocumented DBCC command that was recently discovered in the wild by Eladio Rincon (http:\/\/www.sqlmag.com\/article\/sql-server\/options-affecting-parallelism-141505). Itzik closed the article by expressing his hope to get this statement documented <a href=\"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5,19,14],"tags":[],"class_list":["post-828","post","type-post","status-publish","format-standard","hentry","category-general","category-performance","category-sql-server-internals"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Optimizer, what if I had more CPUs? - sqlity.net<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Optimizer, what if I had more CPUs? - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"In the March issue of SQL Server Pro Itzik Ben-Gan wrote about an undocumented DBCC command that was recently discovered in the wild by Eladio Rincon (http:\/\/www.sqlmag.com\/article\/sql-server\/options-affecting-parallelism-141505). Itzik closed the article by expressing his hope to get this statement documented [more...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2012-03-27T14:00:45+00:00\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"Optimizer, what if I had more CPUs?\",\"datePublished\":\"2012-03-27T14:00:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/\"},\"wordCount\":562,\"commentCount\":0,\"articleSection\":[\"General\",\"Performance\",\"SQL Server Internals\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/\",\"name\":\"Optimizer, what if I had more CPUs? - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"datePublished\":\"2012-03-27T14:00:45+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/828\\\/optimizer-what-if-i-had-more-cpus\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Optimizer, what if I had more CPUs?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Optimizer, what if I had more CPUs? - sqlity.net","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/","og_locale":"en_US","og_type":"article","og_title":"Optimizer, what if I had more CPUs? - sqlity.net","og_description":"In the March issue of SQL Server Pro Itzik Ben-Gan wrote about an undocumented DBCC command that was recently discovered in the wild by Eladio Rincon (http:\/\/www.sqlmag.com\/article\/sql-server\/options-affecting-parallelism-141505). Itzik closed the article by expressing his hope to get this statement documented [more...]","og_url":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2012-03-27T14:00:45+00:00","author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"Optimizer, what if I had more CPUs?","datePublished":"2012-03-27T14:00:45+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/"},"wordCount":562,"commentCount":0,"articleSection":["General","Performance","SQL Server Internals"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/","url":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/","name":"Optimizer, what if I had more CPUs? - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"datePublished":"2012-03-27T14:00:45+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/828\/optimizer-what-if-i-had-more-cpus\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"Optimizer, what if I had more CPUs?"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-dm","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=828"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/828\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}