Logical query-processing phases
Logical query-processing phases in brief
(1) FROM
This phase identifies the query’s source tables and processes table operators.
Each table operator applies a series of subphases.
For example, the phases involved in a join are
(1-J1) Cartesian Product, (1-J2) ON Predicate, (1-J3) Add Outer Rows.
This phase generates virtual table VT1.
(1-J1) Cartesian Product
This phase performs a Cartesian product (cross join)
between the two tables involved in the table operator, generating VT1-J1.
(1-J1) Cartesian Product This
This phase filters the rows from VT1-J1 based on the predicate
that appears in the ON clause (<on_predicate>).
Only rows for which the predicate evaluates to TRUE are inserted into VT1-J2.
(1-J3) Add Outer Rows
If OUTER JOIN is specified (as opposed to CROSS JOIN or INNER JOIN),
rows from the preserved table or tables for which a match was not found
are added to the rows from VT1-J2 as outer rows, generating VT1-J3.
(2) WHERE
This phase filters the rows from VT1 based on the predicate that appears in the WHERE clause (<where_predicate>).
Only rows for which the predicate evaluates to TRUE are inserted into VT2.
(3) GROUP BY
This phase arranges the rows from VT2 in groups based on the set of expressions
(aka, grouping set) specified in the GROUP BY clause, generating VT3. Ultimately,
there will be one result row per qualifying group.
(4) HAVING
This phase filters the groups from VT3 based on the predicate that
appears in the HAVING clause (<having_predicate>). Only groups for
which the predicate evaluates to TRUE are inserted into VT4.
(5) SELECT
This phase processes the elements in the SELECT clause, generating VT5.
(5-1) Evaluate Expressions
This phase evaluates the expressions in the SELECT list, generating VT5-1.
(5-2) DISTINCT
This phase removes duplicate rows from VT5-1, generating VT5-2.
(6) ORDER BY
This phase orders the rows from VT5-2 according to the list specified in the ORDER BY clause,
generating the cursor VC6. Absent an ORDER BY clause, VT5-2 becomes VT6.
(7) TOP | OFFSET-FETCH
This phase filters rows from VC6 or VT6 based on the top or offset-fetch specification,
generating VC7 or VT7, respectively. With TOP, this phase filters the specified
number of rows based on the ordering in the ORDER BY clause, or based on arbitrary order
if an ORDER BY clause is absent. With OFFSET-FETCH, this phase skips the specified number of rows,
and then filters the next specified number of rows, based on the ordering in the ORDER BY clause.
The OFFSET-FETCH filter was introduced in SQL Server 2012.
to be end
最新文章
- handlebars模板替换
- 软件测试作业1--描述Error
- Android之Intent深入
- IOS第五天(2:用户登录,回车的监听(代理模式UITextFieldDelegate)) 和关闭键盘
- iOS 学习笔记 七 (2015.03.29)code snippet操作
- 转载---SQL Server XML基础学习<;1>;之--FOR XML PATH
- WinRAR5.31 注册码
- # 团队作业8——第二次项目冲刺(Beta阶段)--5.27 seventh day
- ajax之XML简介
- Asp.Net Web API(六)
- python将数据写入excel代码,python与office交互
- MIP 技术交流分享(3月15日)
- docker搭建gitlab服务器(Centos7)
- HDU4857 逃生 拓扑排序
- java.lang.UnsatisfiedLinkError: dlopen failed: library ";libsqlite.so"; not found
- win10 x64中 windbg x64 安装配置符号库
- SQL Server 查询性能优化——覆盖索引
- python接口自动化-token参数关联登录(二)
- 在WebGL场景中管理多个卡牌对象的实验
- javascript实现对html便签等字符的转义