12 Execution Plan
"Execution Plan" Is Used By "Query Optimizer" Component To Ensure The Best Usage Of Resources (Memory & Cpu)
the above execution plans also give recommendations about missing indexes for a specific query. also, query execution stats.
but for complete set of recommendations we use dta tool [database engine tuning advisor tool].
12.1 Types of Execution Plans Statistics (query statistics) :
12.1.1 Estimated Execution Plan
12.1.2 Live Execution Plan
12.1.3 Actual Execution Ption;
12.1.4 generated after the query execution
12.2 Possible Plan Types:
12.2.1 Table Scan
12.2.2 Index scan :
12.2.3 index seek :
12.2.4 spooling :
required data is loaded to tempdb for faster calculations, comparisons, loops, audits, etc..
12.3 Query Cost Types:
12.3.1 IO cost
12.3.2 CPU cost
12.3.3 sub tree cost
reduce the number of sub queries and self joins, if possible.
also ensure to check the health of the database.
recompile the long running stored procedures.
12.3.4 operator cost
ex: merge join option is faster compared to hash join option.
for higher operator cost, it is advisable to ensure stats updates and sp recompilations.
** avoid nested loops in the execution plans. for this, we "merge join" option.