optimize for unknown for SQL Server 2005?

梦想与她 提交于 2019-12-06 08:03:15

问题


I was listening to the SO podcast and they mentioned Optimize For Unknown for SQL server 2008, they also mentioned that there was something similar for SQL Server 2005. Anyone know what this is?


回答1:


As @Mladen Prajdic mentioned, OPTIMIZE FOR UNKNOWN was only introduced in SQL Server 2008.

If you have reasonable knowledge of your query workload, OPTIMIZE FOR can be used to improve query plan caching:

http://blogs.msdn.com/sqlprogrammability/archive/2008/11/26/optimize-for-unknown-a-little-known-sql-server-2008-feature.aspx

http://decipherinfosys.wordpress.com/2007/10/23/optimize-for-query-hint-in-sql-server-2005/




回答2:


I came across this question... I know it's almost a year old. But Inside a stored procedure you can use a local parameter to mimic the behavior of OPTIMIZE FOR UNKNOWN. See this related stackoverflow question.




回答3:


in sql server 2005 you don't have the unknown option. so the only thing you can do is specify a value of somekind.



来源:https://stackoverflow.com/questions/650914/optimize-for-unknown-for-sql-server-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!