SQL Server执行计划 - 实际与估计

时间:2010-09-01 16:51:57

标签: sql-server optimization query-optimization

我正在阅读Grant Fritchey的优秀书籍SQL Server Execution Plans。在pg。 21他说,"When a query is submitted to the server, an estimated execution plan is created by the optimizer. Once that plan is created, and before it gets passed to the storage engine, the optimizer compares this estimated plan to the actual execution plan that already exist in the plan cache."他接着说这样做是因为生成查询计划的代价很高。

这听起来像SQL Sever将由优化器计算估计的计划,并且,如果估计的计划与计划缓存中的实际计划不匹配,则创建实际计划并将其存储在缓存中。因此,听起来计划缓存中是否存在现有计划,SQL Server将始终生成估计计划。如果它还是要这样做,为什么还要在缓存中存储任何东西呢?为什么不总是计算一个计划,因为它至少会做一次计划?我错过了什么吗?

感谢。

1 个答案:

答案 0 :(得分:1)

我读过更准确的this,恕我直言

格兰特的拍摄也是here

相关问题