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

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

主站蜘蛛池模板: 长葛市| 晴隆县| 霍城县| 博爱县| 南川市| 神农架林区| 安远县| 嫩江县| 大名县| 凤冈县| 大悟县| 剑川县| 睢宁县| 沁源县| 布尔津县| 赣州市| 肇庆市| 屏山县| 天祝| 永修县| 米易县| 平凉市| 新泰市| 蓝田县| 武穴市| 苍溪县| 岳西县| 荆门市| 泸州市| 临清市| 光泽县| 榆树市| 牡丹江市| 汕尾市| 普兰县| 丽江市| 旬邑县| 宜宾市| 望谟县| 广宁县| 奉新县|