Execution Plan Basic

https://www.simple-talk.com/sql/performance/execution-plan-basics/


Estimated execution plan uses the query processor tree and the statistics it has about the data, and applying the model, it works out what it thinks will be the optimal way to execute the query – that is, it generates an execution plan.

关于重用执行计划的这段很重要:

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 toactual execution plans that already exist in the plan cache . If an actual plan is found that matches the estimated one, then the optimizer will reuse the existing plan, since it's already been used before by the query engine.This reuse avoids the overhead of creating actual execution plans for large and complex queries or even simple plans for small queries called thousands of times in a minute.

也就是说,永远都需要计算estimated execution plan,重用的只是存储在plan cache中的actual execution plan。

但是为什么计算actual execution plan开销很大呢?文中没有提及actual execution plan的具体内容所以不太清楚。

你可能感兴趣的:(Execution Plan Basic)