<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>10.0 Plan Cache Flush</title><link>http://blogs.msdn.com/sqlprogrammability/archive/2007/01/17/10-0-plan-cache-flush.aspx</link><description>In SQL Server 2005, certain database maintenance operations or certain dbcc commands such as “dbcc freeproccache” or “dbcc freesystemcache” will clear the plan cache for the instance of SQL Server. Clearing the plan cache causes a recompilation of all</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: 10.0 Plan Cache Flush</title><link>http://blogs.msdn.com/sqlprogrammability/archive/2007/01/17/10-0-plan-cache-flush.aspx#1554202</link><pubDate>Tue, 30 Jan 2007 04:27:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1554202</guid><dc:creator>shus</dc:creator><description>&lt;p&gt;Plan Cache Flushing - We recommend doing the following instead of attaching/detaching the DBs of those partners: &lt;/p&gt;
&lt;p&gt;1) Redirect or bring down the front-end server (web server/services or application server) for those partners &lt;/p&gt;
&lt;p&gt;2) Putting the DB in RESTRICTED_USER mode &lt;/p&gt;
&lt;p&gt;3) If you must bring the DB on/off, you should put the databases that will likely to be brought on/off line in a separate DB instance from the DB instances of those that will be always online. &lt;/p&gt;
&lt;p&gt;SQL 2000 allows you to detach a DB without flushing the whole proc cache, but it does it incorrectly under certain situations. SQL 2005 fixed this problem by flushing the whole plan cache. Currently, due to resource constraints, we do not have plans to do DB specific plan cache flushing. We certainly will keep your feedback in mind going forward.&lt;/p&gt;
&lt;p&gt;For the parameter sniffing problem – If you use one of the suggestions above, the parameter sniffing problem will be reduced. The other things you can do are: &lt;/p&gt;
&lt;p&gt;1) Use plan guide for those queries &lt;/p&gt;
&lt;p&gt;2) Use “OPTIMIZE FOR” query hint &lt;/p&gt;
&lt;p&gt;3) Use “with recompile” (limited for stored procs or use plan guide) &lt;/p&gt;
&lt;p&gt;I would love to hear more detailed cases about the parameter sniffing problems. &lt;/p&gt;
&lt;p&gt;-Shus&lt;/p&gt;</description></item></channel></rss>