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

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

主站蜘蛛池模板: 西和县| 霞浦县| 南漳县| 红桥区| 舒兰市| 通河县| 方正县| 西昌市| 常德市| 茶陵县| 泗水县| 霍山县| 丰镇市| 蓝田县| 扶沟县| 平武县| 五大连池市| 凤山市| 来凤县| 泊头市| 桓台县| 大英县| 仁怀市| 佛学| 五大连池市| 兖州市| 三原县| 民勤县| 塔河县| 定南县| 任丘市| 阜平县| 平原县| 聊城市| 云和县| 浦城县| 从化市| 咸宁市| 横峰县| 公安县| 建昌县|