官术网_书友最值得收藏!

Plan caching and reuse

As we have now established, the process of optimizing a query can consume a large quantity of resources and take a significant amount of time, so it makes sense to avoid that effort if possible whenever a query is executed. SQL Server caches nearly every plan that is created so that it can be reused when the same query is executed again. But not all execution plans are eligible for caching. For example, no DDL statements are cached, such as CREATE TABLE. As for DML statements, most simple forms that only have one possible execution plan are also not cached, such as INSERT INTO … VALUES.

There are several different methods for plan caching. The method we will use is typically based on how the query is called from the client. The different methods of plan caching that will be covered in this section are the following:

  • Stored procedures
  • Ad hoc plan caching
  • Parameterization (Simple and Forced)
  • The sp_executesql procedure
  • Prepared statements

主站蜘蛛池模板: 德昌县| 芜湖市| 绥江县| 商水县| 江都市| 房产| 嘉禾县| 温宿县| 株洲县| 若尔盖县| 珲春市| 蓝山县| 陆河县| 南皮县| 建德市| 兰考县| 定安县| 湟源县| 德令哈市| 佳木斯市| 垣曲县| 达拉特旗| 当雄县| 常德市| 城口县| 颍上县| 白玉县| 长兴县| 贡嘎县| 望江县| 木兰县| 赫章县| 常山县| 阿瓦提县| 禹城市| 滁州市| 永仁县| 韶山市| 芒康县| 卓尼县| 乌拉特中旗|