{"id":2853,"date":"2016-01-19T10:00:56","date_gmt":"2016-01-19T15:00:56","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=2853"},"modified":"2016-01-18T16:01:09","modified_gmt":"2016-01-18T21:01:09","slug":"temp-table-cache-bloat","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/","title":{"rendered":"Can A <span class=\"post-emph1\">Temp Table Name<\/span> Cause <span class=\"post-emph2\">Plan Cache Bloat<\/span>?"},"content":{"rendered":"<div>\n<p>\nI recently ran into a particularly odd behavior of SQL Server related to temporary tables. It took me a little digging to come up with an explanation for this, but I discovered something that most of us can learn from, so I decided to share it here.\n<\/p>\n<h3>Query Execution<\/h3>\n<p>\nEvery query in SQL Server it is processed in three phases. First, the query is parsed. During that phase, the general syntax of the query is checked. The result of this phase is a parse tree.\n<\/p>\n<p>\nThe second phase is done by the Algebrizer. It is responsible to resolve object names and check that the query &ldquo;makes sense&rdquo;. For example the correct use of the <span class=\"tt\">GROUP BY<\/span> clause is validated in this step. The output of this phase is called algebrized tree and it contains a representation of the query that is ready to be optimized. In other words, now SQL Server knows that the query can be executed (with some rare exceptions). But SQL Server does not yet know how to best execute the query.\n<\/p>\n<p>\nThat remaining question is answered in the third and most expensive phase, the optimization phase. During optimization SQL Server tries to find a good enough plan for the query. How query optimization works in detail is described very well by Paul White in his <a href=\"http:\/\/sqlblog.com\/blogs\/paul_white\/archive\/2012\/04\/28\/query-optimizer-deep-dive-part-1.aspx\">Query Optimizer Deep Dive<\/a>.\n<\/p>\n<h3>The Plan Cache<\/h3>\n<p>\nImportant for us here is, that the third phase, the one that gets the query ready to actually be executed, is resource intensive. To save resources, SQL Server caches the result of this phase for more complex queries and stored SQL modules. When the same query or stored procedure is executed the next time, the already prepared plan is found in the plan cache and reused, potentially saving a lot of CPU time.\n<\/p>\n<p>\nLet us look at an example. The following is a simple stored procedure:\n<\/p>\n<div>\n[sql]\nCREATE PROCEDURE dbo.UseATempTable<br \/>\nAS<br \/>\nBEGIN<br \/>\n  SET NOCOUNT ON;<\/p>\n<p>  CREATE TABLE #ATempTable(Id INT);<\/p>\n<p>  INSERT INTO #ATempTable(Id)<br \/>\n  VALUES(101),(123),(177);<\/p>\n<p>  DECLARE @r INT<br \/>\n  SELECT @r = SUM(Id) FROM #ATempTable AS ATT;<\/p>\n<p>  RETURN @r;<br \/>\nEND;<br \/>\n[\/sql]\n<\/p><\/div>\n<p>\nWhen this procedure is executed the first time, an entry in the plan cache is created. To make this entry visible we need to access the <span class=\"tt\">sys.dm_exec_cached_plans<\/span> DMV. I created the following view that returns the cache entries for just those procedures that are used in this and the following examples:\n<\/p>\n<div>\n[sql]\nCREATE VIEW dbo.PlanCacheReuse<br \/>\nAS<br \/>\nSELECT<br \/>\n    OBJECT_NAME(CAST(DEPA.objectid AS INT),CAST(DEPA.dbid AS INT)) procedure_name,<br \/>\n    DECP.usecounts,<br \/>\n    DECP.cacheobjtype,<br \/>\n    DECP.objtype,<br \/>\n    DEPA.optional_spid<br \/>\n  FROM sys.dm_exec_cached_plans AS DECP<br \/>\n CROSS APPLY (<br \/>\n   SELECT DEPAP.*<br \/>\n     FROM sys.dm_exec_plan_attributes(DECP.plan_handle) AS DEPAU<br \/>\n    PIVOT (MAX(DEPAU.value) FOR DEPAU.attribute IN (dbid,objectid,optional_spid)) AS DEPAP<br \/>\n )DEPA<br \/>\n WHERE DEPA.dbid = DB_ID()<br \/>\n   AND DEPA.objectid IN(<br \/>\n          OBJECT_ID(QUOTENAME(DB_NAME())+'.dbo.UseATempTable'),<br \/>\n          OBJECT_ID(QUOTENAME(DB_NAME())+'.dbo.UseAnExternalTempTable')<br \/>\n       );<br \/>\n[\/sql]\n<\/div>\n<p>\nThe output of the view looks like this, after the procedure <span class=\"tt\">dbo.UseATempTable<\/span> has been executed for the first time:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Procedure_Cache_Entry.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Procedure_Cache_Entry.jpg\" alt=\"A single procedure cache entry\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2860\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Procedure_Cache_Entry.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Procedure_Cache_Entry-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Procedure_Cache_Entry-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nIf you execute the same procedure again (and again), the same cached plan is reused as you can see when you look at the <span class=\"tt\">usecount<\/span> column:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Procedure_Cache_Entry.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Procedure_Cache_Entry.jpg\" alt=\"A multi-use procedure cache entry\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2856\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Procedure_Cache_Entry.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Procedure_Cache_Entry-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Procedure_Cache_Entry-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nIdeally, SQL Server has to compile each procedure only once and can use the cached plan for all subsequent executions. However, a few things can prevent re-use of a cached plan. The most obvious reason is that the plan had to be evicted from cache because the memory was needed for more frequently used objects. Another common cause is changing data. When more data is added to a database table, execution plans of queries accessing that table might become sub-optimal. SQL Server is relying on a few simple (and not so simple) heuristics to trigger a recompilation for cached plans that have the potential of being sub-optimal.\n<\/p>\n<h3>External Temp Tables<\/h3>\n<p>\nThere is one reason preventing plan reuse that few people know about: The use of external temporary tables. When you create a temporary table in SQL Server and then call a stored procedure from the same connection, that temporary table is visible and accessible within the procedure. That pattern is sometimes used to pass data back and forth between a procedure and the calling procedure. For more details on the scope of temporary tables, check out <a href=\"http:\/\/sqlity.net\/en\/1109\/temp-tables-scoping-eclipsing\/\">Temp Tables \u2013 Scoping and Eclipsing<\/a>.\n<\/p>\n<p>\nWhen a stored procedure is compiled that is accessing an external temp table, SQL Server has no guarantee that the next time this stored procedure is called it is called from the same connection. However, if it is called from a different connection, the accessed temp table might contain significantly more (or less) data making a different execution plan preferable.\n<\/p>\n<p>\nA simple way to deal with this situation is to force a recompilation every time a procedure that works with external temporary tables is executed. SQL Server is not going that route. Instead, SQL Server caches the procedure once for each connection. That can safe a significant amount of CPU resources when the procedure in question is called within a loop. Let us take a look at this procedure:\n<\/p>\n<div>\n[sql]\nCREATE PROCEDURE dbo.UseAnExternalTempTable<br \/>\nAS<br \/>\nBEGIN<br \/>\n  SET NOCOUNT ON;<\/p>\n<p>  INSERT INTO #ATempTable(Id)<br \/>\n  VALUES(101),(123),(177);<\/p>\n<p>  DECLARE @r INT<br \/>\n  SELECT @r = SUM(Id) FROM #ATempTable AS ATT;<\/p>\n<p>  RETURN @r;<br \/>\nEND;<br \/>\n[\/sql]\n<\/p><\/div>\n<p>\nThis procedure looks similar to the one we looked at before, but it expects the temp table <span class=\"tt\">#ATempTable<\/span> to exist when it is called. When you execute it a few times you see the same behavior that we have encountered before: A plan is created and cached  after the first execution,\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Cache_Entry_For_Procedure_Accessing_External_TempTable.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Cache_Entry_For_Procedure_Accessing_External_TempTable.jpg\" alt=\"A single cache entry for a procedure accessing an external temporary table\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2859\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Cache_Entry_For_Procedure_Accessing_External_TempTable.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Cache_Entry_For_Procedure_Accessing_External_TempTable-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Single_Cache_Entry_For_Procedure_Accessing_External_TempTable-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nand then reused in subsequent executions.\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Cache_Entry_For_Procedure_Accessing_External_TempTable.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Cache_Entry_For_Procedure_Accessing_External_TempTable.jpg\" alt=\"A multi-use cache entry for a procedure accessing an external temp table.\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2855\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Cache_Entry_For_Procedure_Accessing_External_TempTable.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Cache_Entry_For_Procedure_Accessing_External_TempTable-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Multi_Use_Cache_Entry_For_Procedure_Accessing_External_TempTable-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nBut you might have noticed that the SPID of the current connection is stored with the plan in the <span class=\"tt\">optional_spid<\/span> column. So, if you now execute the same procedure from a different connection, a new plan is created and cached\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs.jpg\" alt=\"Two cache entries for a procedure accessing an external temp table from separate connections\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2861\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nand then reused as long as you are calling again from that SPID.\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Multi_Use_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Multi_Use_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs.jpg\" alt=\"Two multi-use cache entries for a procedure accessing an external temp table from separate connections\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2854\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Multi_Use_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Multi_Use_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Two_Multi_Use_Cache_Entries_For_Procedure_Accessing_External_TempTable_From_Separate_SPIDs-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<h3>Is Your Plan Cache Bloated?<\/h3>\n<p>\nThe behavior described above can save a lot of resources in some situations, but it can also cause resources to be wasted. This is due to the eclipsing behavior described in <a href=\"http:\/\/sqlity.net\/en\/1109\/temp-tables-scoping-eclipsing\/\">Temp Tables \u2013 Scoping and Eclipsing<\/a>.\n<\/p>\n<p>\nWhen a procedure is accessing a temp table and a temp table with the same name already exists in the calling context, SQL Server does not know at optimization time whether that temp table will be the one accessed or if it will have been eclipsed at the time. Therefore, SQL Server assumes that the existing external temp table is the one that is accessed and optimizes the procedure for that one. This could cause a suboptimal plan to be chosen. But more importantly, that plan will be cached only for the connection it is called from. Let us look at this procedure:\n<\/p>\n<div>\n[sql]\nCREATE PROCEDURE dbo.AlsoUseATempTable<br \/>\nAS<br \/>\nBEGIN<br \/>\n  SET NOCOUNT ON;<\/p>\n<p>  CREATE TABLE #ATempTable(Id INT);<\/p>\n<p>  EXEC dbo.UseATempTable;<br \/>\nEND;<br \/>\n[\/sql]\n<\/p><\/div>\n<p>\nIt creates a temp table and then calls our first example procedure <span class=\"tt\">dbo.UseATempTable<\/span>. Even though that one is not going to access the pre-existing temp table, its execution plan is tied to the executing SPID:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Hinting_At_Problems.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Hinting_At_Problems.jpg\" alt=\"A reused temp table name is hinting at problems\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2858\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Hinting_At_Problems.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Hinting_At_Problems-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Hinting_At_Problems-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nSo when you call the outer procedure again from another connection, a new plan for the inner procedure will be cached:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\" alt=\"A reused temp table name causing cache bloat\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2857\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat-300x183.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nOn busy machines, SPIDs above 500 are not uncommon. So, if you have an often executed procedure pair like this you can end up with 500 or more copies of the execution plan. While a single execution plan is not huge, it might still take up more than a megabyte in the cache. Having to store 500 of them instead of just one can cause significant memory pressure on the cache, which will cause other queries to be evicted from the cache early. This will in turn cause additional work for SQL Server as it has to recompile those evicted queries again. That additional work can have a measurable impact on your SQL Server's performance.\n<\/p>\n<h3>How Does This Impact Me?<\/h3>\n<p>\nThe above scenario is more common than you might think. I often encounter temporary table that have a - let's say - common name. A typical example is the name <span class=\"tt\">#tmp<\/span>. Single letters like <span class=\"tt\">#o<\/span> are also often used. If you use temp table names like this, and you have a procedure that calls another one, you might be in trouble.\n<\/p>\n<p>\nHowever, there is a simple way to prevent this from happening (in most cases): Use good names. There are many reasons why an object name like <span class=\"tt\">#OrdersInDateRange<\/span> is better than <span class=\"tt\">#tmp<\/span>. Making the code easier to read and understand and therefore reducing maintenance cost is just one of them. Reducing the probability of unexpected plan caching issues due to name collisions is another one.\n<\/p>\n<h3>The Moral<\/h3>\n<p>\nIf you use descriptive names for your temporary tables will make life simpler, yours and SQL Server's. Using not so descriptive names on the other hand can hurt you in expected and in unexpected ways.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u201cUse descriptive object names.\u201d &#8211; Read on to discover how ignoring this best practice can cause plan cache bloat and in turn performance issues.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":2857,"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":true,"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,14],"tags":[261,106,262,263,15,265,266,264],"class_list":["post-2853","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","category-sql-server-internals","tag-cache","tag-internals","tag-plan-cache","tag-procedure-cache","tag-sql-server","tag-temp-tables","tag-temporary-objects","tag-temporary-tables"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Can A Temp Table Name Cause Plan Cache Bloat? - sqlity.net<\/title>\n<meta name=\"description\" content=\"\u201cUse descriptive object names.\u201d - Read on to discover how ignoring this best practice can cause plan cache bloat and performance issues.\" \/>\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\/2853\/temp-table-cache-bloat\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Can A Temp Table Name Cause Plan Cache Bloat? - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"\u201cUse descriptive object names.\u201d - Read on to discover how ignoring this best practice can cause plan cache bloat and performance issues.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/\" \/>\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=\"2016-01-19T15:00:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"768\" \/>\n\t<meta property=\"og:image:height\" content=\"468\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"Can A Temp Table Name Cause Plan Cache Bloat?\",\"datePublished\":\"2016-01-19T15:00:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/\"},\"wordCount\":1536,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\",\"keywords\":[\"cache\",\"internals\",\"plan cache\",\"procedure cache\",\"SQL Server\",\"temp tables\",\"temporary objects\",\"temporary tables\"],\"articleSection\":[\"General\",\"SQL Server Internals\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/\",\"name\":\"Can A Temp Table Name Cause Plan Cache Bloat? - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\",\"datePublished\":\"2016-01-19T15:00:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"\u201cUse descriptive object names.\u201d - Read on to discover how ignoring this best practice can cause plan cache bloat and performance issues.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg\",\"width\":768,\"height\":468,\"caption\":\"A reused temp table name causing cache bloat\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2853\\\/temp-table-cache-bloat\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Can A Temp Table Name Cause Plan Cache Bloat?\"}]},{\"@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":"Can A Temp Table Name Cause Plan Cache Bloat? - sqlity.net","description":"\u201cUse descriptive object names.\u201d - Read on to discover how ignoring this best practice can cause plan cache bloat and performance issues.","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\/2853\/temp-table-cache-bloat\/","og_locale":"en_US","og_type":"article","og_title":"Can A Temp Table Name Cause Plan Cache Bloat? - sqlity.net","og_description":"\u201cUse descriptive object names.\u201d - Read on to discover how ignoring this best practice can cause plan cache bloat and performance issues.","og_url":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2016-01-19T15:00:56+00:00","og_image":[{"width":768,"height":468,"url":"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg","type":"image\/jpeg"}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"Can A Temp Table Name Cause Plan Cache Bloat?","datePublished":"2016-01-19T15:00:56+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/"},"wordCount":1536,"commentCount":1,"image":{"@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg","keywords":["cache","internals","plan cache","procedure cache","SQL Server","temp tables","temporary objects","temporary tables"],"articleSection":["General","SQL Server Internals"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/","url":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/","name":"Can A Temp Table Name Cause Plan Cache Bloat? - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg","datePublished":"2016-01-19T15:00:56+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"\u201cUse descriptive object names.\u201d - Read on to discover how ignoring this best practice can cause plan cache bloat and performance issues.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#primaryimage","url":"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg","contentUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg","width":768,"height":468,"caption":"A reused temp table name causing cache bloat"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/2853\/temp-table-cache-bloat\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"Can A Temp Table Name Cause Plan Cache Bloat?"}]},{"@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":"https:\/\/sqlity.net\/wp-content\/uploads\/2015\/07\/Reused_TempTable_Name_Causing_Cache_Bloat.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-K1","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2853","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=2853"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2853\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media\/2857"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=2853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=2853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=2853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}