LEFT JOIN 的查询速度?
加快使用 LEFT JOIN 的查询速度的一项技术涉及创建一个 TABLE 数据类型,插入第一个表(LEFT JOIN 左侧的表)中的所有行,然后使用第二个表中的值更新 TABLE 数据类型。此技术是一个两步的过程,但与标准的 LEFT JOIN 相比,可以节省大量时间;
这个两步的过程具体是如何做?
------解决方案--------------------Logical Query Processing Phases in Brief
Don’t worry too much if the description of the steps doesn’t seem to make much sense
for now. These are provided as a reference. Sections that come after the scenario example
will cover the steps in much more detail.
■ (1) FROM The FROM phase identifi es 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 Filter, (1-J3) Add Outer Rows.
The FROM 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-J2) ON Filter This phase fi lters 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 specifi ed (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 fi lters 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 column
list specifi ed in the GROUP BY clause, generating VT3. Ultimately, there will be one
result row per group.
■ (4) HAVING This phase fi lters 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.
■ (5-3) TOP This phase fi lters the specifi ed top number or percentage of rows from
VT5-2 based on the logical ordering defi ned by the ORDER BY clause, generating the
table VT5-3.
■ (6) ORDER BY This phase sorts the rows from VT5-3 according to the column list
specifi ed in the ORDER BY clause, generating the cursor VC6.
------解决方案--------------------1,看不懂楼主的意思;
2,5L 的内容是INSIDE SQL SERVER :T-SQL QUERY的内容,讲的是查询的处理步骤。