Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 KEEPFIXED PLAN and KEEP PLAN

Author  Topic 

carumuga
Posting Yak Master

174 Posts

Posted - 2009-02-05 : 03:03:35
Hi,

Can anyone tell me when to use KEEPFIXED PLAN and KEEP PLAN query hint with examples.

I know that KEEPFIXED PLAN can be used when there is a change in the statistics i.e when there is huge volume of data changes in the index columns.

AvanthaSiriwardana
Yak Posting Veteran

78 Posts

Posted - 2009-02-05 : 03:15:54
Hi Carumuga
Hope this will help you.


http://technet.microsoft.com/en-us/library/cc917694.aspx


Avantha Siriwardana
Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-05 : 07:04:39
They are especially used when you are using lots of Temp table inside stored procedure so it won't recompile.
Go to Top of Page

tonymorell10
Yak Posting Veteran

90 Posts

Posted - 2009-02-05 : 09:25:51
Be careful when using these query hints. Both hints will reduce recompiles. However, they may also prevent a better plan from being created.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-05 : 09:50:03
quote:
Originally posted by tonymorell10

Be careful when using these query hints. Both hints will reduce recompiles. However, they may also prevent a better plan from being created.



That depends on how statistics are upto- date.
Go to Top of Page

carumuga
Posting Yak Master

174 Posts

Posted - 2009-02-06 : 02:12:46
My question is when to use KEEP PLAN query hint as both hints reduces recompiles, any differences between these two.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-06 : 08:47:23
As I said, KEEP PLAN is used for Temp tables and KEEP FIXED PLAN for Ad-hoc queries.Both are used to avoid recompilations.
Go to Top of Page
   

- Advertisement -