首页 > 数据库技术 > 详细

SQL Server查询执行过程

时间:2020-09-08 21:50:34      阅读:70      评论:0      收藏:0      [点我收藏+]

1.查询过程

技术分享图片

1.1.query parse

确认语法是否正确

1.2.query binding

确认对象(表,列等)是否正确

1.3.query optimization

生成执行计划,大多数会生成full cost-based plan(完全基于成本的),少部分生成trivial plan()

基于成本的计划需要3个条件

  • Query processor tree
  • statistics

统计信息影响到基数,选择性,其由以下部分组成
1.the header – general data about a given set of statistics
2.the density graph – the selectivity, uniqueness, of the data, and, most importantly
3.a histogram – a tabulation of counts of the occurrence of a particular value, taken from
up to 200 data points that are chosen to best represent the complete data in the table.
内存压力或执行计划长期未被使用被新的计划挤出plan cache,手动执行下面的命令也会导致释放plan cache

sys.dm_exec_query_stats  sql_handle和plan_handle
dbcc freeproccache(<plan_handle>)
DBCC FLUSHPROCINDB(db_id)
  • Constraints

1.4.query execution phase

SQL Server查询执行过程

原文:https://www.cnblogs.com/ls11736/p/13628096.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!