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

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

主站蜘蛛池模板: 蒙山县| 庐江县| 宣汉县| 上蔡县| 涿州市| 绥化市| 荣昌县| 丹棱县| 临夏市| 建宁县| 綦江县| 桂阳县| 桂阳县| 齐河县| 荣成市| 松溪县| 土默特左旗| 怀化市| 芜湖市| 永清县| 凤山县| 缙云县| 琼海市| 辉县市| 鸡西市| 阜宁县| 朝阳区| 项城市| 北宁市| 余庆县| 吉首市| 长治县| 越西县| 扬中市| 古蔺县| 深州市| 县级市| 秦安县| 松潘县| 新竹市| 新泰市|