{"id":12114,"date":"2019-05-10T00:58:27","date_gmt":"2019-05-10T00:58:27","guid":{"rendered":"https:\/\/dbtut.com\/?p=12114"},"modified":"2019-05-10T00:58:28","modified_gmt":"2019-05-10T00:58:28","slug":"optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/","title":{"rendered":"Optimize for ad hoc workloads and Parameterization in SQL Server"},"content":{"rendered":"<p>In this article, we will examine what happens when we enable Optimize for ad hoc workloads and when we use parameterization. We will see what will happen when we use the two features together and separately.<\/p>\n<p>Optimize for ad hoc workloads is a feature that is introduced with SQL Server 2008. If you enable Optimize for ad hoc workloads, it creates only a small Compiled Plan Stub for single-use queries, rather than creating the entire query plan on the plan cache. The entire Query plan is created when the query is executed&nbsp; second time.<\/p>\n<h3>Enable optimize for ad hoc workloads<\/h3>\n<p>We can enable this feature on sql server as follows. Queries must be executed one by one or use GO between queries.<\/p>\n<pre class=\"lang:default decode:true\">sp_configure 'show advanced options',1\nreconfigure<\/pre>\n<pre class=\"lang:default decode:true \">sp_configure 'optimize for ad hoc workloads',1\nreconfigure<\/pre>\n<p>SQL Server is using simple parameterization by default. But you can also set to forced parameterization.<\/p>\n<h3>Enable Forced Parameterization<\/h3>\n<p>You can change the parameterization type with the help of the following query.<\/p>\n<pre class=\"lang:default decode:true\">USE [master]\nGO\nALTER DATABASE [AdventureWorks2012] SET PARAMETERIZATION FORCED WITH NO_WAIT\nGO\n<\/pre>\n<h3>Why we Enable Forced Parameterization<\/h3>\n<p>Suppose application sends queries as unparameterized(<strong>ad hoc<\/strong>) and we cannot change the application to send the queries with parameters. In this case, we can enable forced parameterization.<\/p>\n<h2>Optimized For ad hoc workloads and Parameterization Scenarios<\/h2>\n<p>Now let&#8217;s see what happens when enabling and disabling the optimized ad hoc workloads with simple or forced parameterization.<\/p>\n<h3>Scenario 1: Optimize for ad hoc workloads disabled and SQL Server use simple parameterization<\/h3>\n<p>Clean the Cache with the following query. You should not do this in the production environment.<\/p>\n<pre class=\"lang:default decode:true \">DBCC FREEPROCCACHE\nDBCC DROPCLEANBUFFERS<\/pre>\n<p>We will run our queries in the AdwentureWorks database. So we&#8217;re running the following query.<\/p>\n<pre class=\"lang:default decode:true \">USE AdventureWorks\nGO<\/pre>\n<p>Let&#8217;s run the following 3 queries one by one after clearing the cache.<\/p>\n<pre class=\"lang:default decode:true \">SELECT * FROM HumanResources.Shift\n\nSELECT * FROM HumanResources.Shift\n\nwhere ModifiedDate='2002-06-01 00:00:00.000'\n \nSELECT * FROM HumanResources.Shift\n\nwhere ISNULL(ModifiedDate,'1\/1\/2003')&gt;'1\/1\/1990'<\/pre>\n<p>After running the queries above, we&#8217;re running the following query to see if the query plans of our queries were created, and also size of query plans if they were created.<\/p>\n<pre class=\"lang:default decode:true \">SELECT p.size_in_bytes,p.cacheobjtype,p.objtype,qp.query_plan,t.text\n\nFROM sys.dm_exec_cached_plans p\n\nCROSS APPLY sys.dm_exec_query_plan(p.plan_handle) qp\n\nCROSS APPLY sys.dm_exec_sql_text(p.plan_handle) t\n\nwhere t.text like '%HumanResources%<\/pre>\n<p>While optimizing for ad hoc workloads is disabled and simple parameterization is enabled, we get a result as follows;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.veritabani.gen.tr\/wp-content\/uploads\/2016\/09\/422.png\" width=\"713\" height=\"93\"><\/p>\n<p>As you can see, all query plans have created. We only see that there is a difference in a query.<\/p>\n<pre class=\"lang:default decode:true \">SELECT * FROM HumanResources.Shift where ModifiedDate='2002-06-01 00:00:00.000'<\/pre>\n<p>A query plan has been created for both the parameterized state and the unparameterized state of the above query. But for another query which have a where condition, a query plan for the parameterized state is not created while the query plan of the unparameterized state is created. This means, it could not parameterized this query.<\/p>\n<p>Because we used simple parameterization, it was only able to parameterize the query which have a simple where condition. But it was unable to parameterize the other query that has a complex where condition.<\/p>\n<p>That is, in some cases, simple parameterization may not be able to parameterize queries that have a complex where condition.<\/p>\n<p>After making the necessary settings(clean cache,enable or disable optimize for ad hoc workloads, etc) to perform each step below, we will run the above scripts repeatedly.<\/p>\n<h3>Scenario 2: Optimize for ad hoc workloads enabled and SQL Server use simple parameterization<\/h3>\n<p>When we run the queries again, we get a result as follows.<\/p>\n<p>As you can see, it only created a query plan for the query it can be parameterized. It just created the &#8220;Compiled Plan Stub&#8221; for the remaining queries.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.veritabani.gen.tr\/wp-content\/uploads\/2016\/09\/455-1.png\" width=\"719\" height=\"99\"><\/p>\n<p>While &#8220;Optimize for ad hoc workloads&#8221; is enabled and simple parameterization is enabled, we execute the same queries for the second time without clearing the cache and we get a result as follows. As we have seen, when we run the queries second time, we got the same result with the first scenario.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.veritabani.gen.tr\/wp-content\/uploads\/2016\/09\/198-1.png\" width=\"721\" height=\"103\"><\/p>\n<h3>Scenario 3: Optimize for ad hoc workloads disabled and SQL Server use forced parameterization<\/h3>\n<p>After clearing Cache, we execute the same queries again. As you can see, all query plans were created. Unlike the first scenario, it have created a query plan for all the queries which have a where condition. Because this time it use forced parameterization.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.veritabani.gen.tr\/wp-content\/uploads\/2016\/09\/675.png\" width=\"806\" height=\"114\"><\/p>\n<h3>Scenario 4: Optimize for ad hoc workloads enabled and SQL Server use forced parameterization<\/h3>\n<p>After clearing Cache, we execute the same queries again.<\/p>\n<p>As you can see, unlike the second scenario, it has created a query plan for the parameterized states of all queries which have a where condition.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.veritabani.gen.tr\/wp-content\/uploads\/2016\/09\/334.png\" width=\"778\" height=\"125\"><\/p>\n<p>While &#8220;Optimize for ad hoc workloads&#8221; is enabled and &#8220;forced parameterization&#8221; is enabled, we execute the same queries second time without clearing the cache and we get a result as follows. The result is the same with the third scenario.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.veritabani.gen.tr\/wp-content\/uploads\/2016\/09\/132-1.png\" width=\"802\" height=\"121\"><\/p>\n<p>Examples were performed in SQL Server 2012 Enterprise Edition. I got the same results when I performed with SQL Server 2008 R2 Enterprise Edition and Standard Edition and SQL Server 2008 Standard Edition.<\/p>\n<h2>Conclusion<\/h2>\n<p>The purpose of &#8220;Optimize for Ad Hoc Workloads&#8221; is not to create query plans for the queries that executed only once. Thus, the query plan is not created unnecessarily in memory for single use queries.<\/p>\n<p>I do not prefer using &#8220;forced parameterization&#8221; together with &#8220;optimized for Ad Hoc Workloads&#8221;. Because, if the query can be parameterized, the query plan will be created when the query is first executed. So in this case, enabling &#8220;optimized for ad hoc workloads&#8221; has no meaning. Instead of using forced parameterization, it is better to parameterize queries from your applications.<\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_12114\" class=\"pvc_stats all  \" data-element-id=\"12114\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will examine what happens when we enable Optimize for ad hoc workloads and when we use parameterization. We will see what will happen when we use the two features together and separately. Optimize for ad hoc workloads is a feature that is introduced with SQL Server 2008. If you enable Optimize &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_12114\" class=\"pvc_stats all  \" data-element-id=\"12114\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":12124,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[4031,4023,4024,4013,4012,4014,4010,4032,4037,4008,4009,4022,4025,4011,4029,4028,4020,4015,4019,4021,4026,4027,4034,4035,4033,4038,4030,4016,4018,4017],"class_list":["post-12114","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql","tag-bind-variables-in-sql-server","tag-compiled-plan-stub","tag-enable-forced-parameterization","tag-enable-forced-parameterization-in-sql-server","tag-enable-optimize-for-ad-hoc-workloads","tag-enable-optimize-for-ad-hoc-workloads-in-sql-server","tag-forced-parameterization-in-sql-server","tag-increase-sql-server-performance","tag-optimize-ad-hoc-queries-in-sql-server","tag-optimize-for-ad-hoc-workloads","tag-parameterization-in-sql-server","tag-parameterized-query-execution-plan","tag-set-forced-parameterization","tag-simple-parameterization-in-sql-server","tag-sql-server-bind-variable-force","tag-sql-server-force-bind-variable","tag-sql-server-forced-parameterization","tag-sql-server-optimize-for-ad-hoc-workloads","tag-sql-server-parameterization","tag-sql-server-parameterized-query","tag-sql-server-performance","tag-sql-server-query-performance","tag-sql-server-query-tuning","tag-sql-server-query-tuning-without-changing-query","tag-sql-server-tuning","tag-tune-ad-hoc-queries-in-sql-server","tag-what-is-a-bind-variable-in-sql-server","tag-what-is-ad-hoc-in-sql-server","tag-what-is-sql-server-parameterization","tag-why-should-i-enable-forced-parameterization"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Optimize for ad hoc workloads and Parameterization in SQL Server - Database Tutorials<\/title>\n<meta name=\"description\" content=\"Optimize for ad hoc workloads and Parameterization in SQL Server\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Optimize for ad hoc workloads and Parameterization in SQL Server - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"Optimize for ad hoc workloads and Parameterization in SQL Server\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-10T00:58:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-10T00:58:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png\" \/>\n\t<meta property=\"og:image:width\" content=\"615\" \/>\n\t<meta property=\"og:image:height\" content=\"411\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dbtut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbtut\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\"},\"author\":{\"name\":\"dbtut\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\"},\"headline\":\"Optimize for ad hoc workloads and Parameterization in SQL Server\",\"datePublished\":\"2019-05-10T00:58:27+00:00\",\"dateModified\":\"2019-05-10T00:58:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\"},\"wordCount\":868,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png\",\"keywords\":[\"bind variables in sql server\",\"compiled plan stub\",\"Enable Forced Parameterization\",\"enable forced parameterization in sql server\",\"Enable Optimize for Ad Hoc Workloads\",\"enable optimize for ad hoc workloads in sql server\",\"Forced Parameterization in SQL Server\",\"increase sql server performance\",\"optimize ad hoc queries in sql server\",\"Optimize for ad hoc workloads\",\"Parameterization in SQL Server\",\"parameterized query execution plan\",\"Set Forced Parameterization\",\"Simple Parameterization in SQL Server\",\"sql server bind variable force\",\"sql server force bind variable\",\"sql server forced parameterization\",\"sql server optimize for ad hoc workloads\",\"sql server parameterization\",\"sql server parameterized query\",\"sql server performance\",\"sql server query performance\",\"sql server query tuning\",\"sql server query tuning without changing query\",\"sql server tuning\",\"tune ad hoc queries in sql server\",\"What is a bind variable in SQL Server\",\"What is ad hoc in SQL Server?\",\"What is SQL Server parameterization?\",\"why should I enable forced parameterization\"],\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\",\"name\":\"Optimize for ad hoc workloads and Parameterization in SQL Server - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png\",\"datePublished\":\"2019-05-10T00:58:27+00:00\",\"dateModified\":\"2019-05-10T00:58:28+00:00\",\"description\":\"Optimize for ad hoc workloads and Parameterization in SQL Server\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png\",\"width\":615,\"height\":411},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Optimize for ad hoc workloads and Parameterization in SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\",\"name\":\"dbtut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"caption\":\"dbtut\"},\"description\":\"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.\",\"sameAs\":[\"http:\/\/NurullahCAKIR\"],\"url\":\"https:\/\/dbtut.com\/index.php\/author\/dbtut\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Optimize for ad hoc workloads and Parameterization in SQL Server - Database Tutorials","description":"Optimize for ad hoc workloads and Parameterization in SQL Server","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:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"Optimize for ad hoc workloads and Parameterization in SQL Server - Database Tutorials","og_description":"Optimize for ad hoc workloads and Parameterization in SQL Server","og_url":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/","og_site_name":"Database Tutorials","article_published_time":"2019-05-10T00:58:27+00:00","article_modified_time":"2019-05-10T00:58:28+00:00","og_image":[{"width":615,"height":411,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png","type":"image\/png"}],"author":"dbtut","twitter_card":"summary_large_image","twitter_misc":{"Written by":"dbtut","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/"},"author":{"name":"dbtut","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408"},"headline":"Optimize for ad hoc workloads and Parameterization in SQL Server","datePublished":"2019-05-10T00:58:27+00:00","dateModified":"2019-05-10T00:58:28+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/"},"wordCount":868,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png","keywords":["bind variables in sql server","compiled plan stub","Enable Forced Parameterization","enable forced parameterization in sql server","Enable Optimize for Ad Hoc Workloads","enable optimize for ad hoc workloads in sql server","Forced Parameterization in SQL Server","increase sql server performance","optimize ad hoc queries in sql server","Optimize for ad hoc workloads","Parameterization in SQL Server","parameterized query execution plan","Set Forced Parameterization","Simple Parameterization in SQL Server","sql server bind variable force","sql server force bind variable","sql server forced parameterization","sql server optimize for ad hoc workloads","sql server parameterization","sql server parameterized query","sql server performance","sql server query performance","sql server query tuning","sql server query tuning without changing query","sql server tuning","tune ad hoc queries in sql server","What is a bind variable in SQL Server","What is ad hoc in SQL Server?","What is SQL Server parameterization?","why should I enable forced parameterization"],"articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/","url":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/","name":"Optimize for ad hoc workloads and Parameterization in SQL Server - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png","datePublished":"2019-05-10T00:58:27+00:00","dateModified":"2019-05-10T00:58:28+00:00","description":"Optimize for ad hoc workloads and Parameterization in SQL Server","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-19.png","width":615,"height":411},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/10\/optimize-for-ad-hoc-workloads-and-parameterization-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"Optimize for ad hoc workloads and Parameterization in SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408","name":"dbtut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","caption":"dbtut"},"description":"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.","sameAs":["http:\/\/NurullahCAKIR"],"url":"https:\/\/dbtut.com\/index.php\/author\/dbtut\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/12114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=12114"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/12114\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/12124"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=12114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=12114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=12114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}