Various stages in SQL Server query processing (SQL execution order)

Source: Internet
Author: User
Tags sql server query

Introduction to the Logical query processing phase

    1. from: performs a cartesian product (Cartesian product) (cross join) on the first two tables in the FROM clause, generating a virtual table VT1
    2. on: The applies an on filter to the VT1. Only those lines that make <join_condition> true are inserted into the VT2.
    3. OUTER (join): If you specify a OUTER join (relative to a cross join or (INNER join), keep the table (preserved Table: Left outer join marks the left table as a reserved table, right outer join marks the right table as a reserved table, a full outer join marks two tables as a reserved table) and no matching rows are found in the VT2 as an outer row. Generate VT3. If the FROM clause contains more than two tables, repeat steps 1 through 3 for the result table and the next table that you generated for the previous join until you have finished processing all the tables.
    4. Where: applies a where filter to VT3. Only rows that make <where_condition> true are inserted VT4.
    5. GROUP By: generates VT5 by grouping rows in VT4 by the list of columns in the GROUP BY clause.
    6. cube| ROLLUP: Inserts a Hyper-group (suppergroups) into VT5, generating VT6.
    7. has: has a having filter applied to VT6. Only groups that make
    8. Select: processes the select list, producing VT8.
    9. DISTINCT: removes duplicate rows from VT8, resulting in VT9.
    10. ORDER BY: generates a cursor (VC10) by sorting the rows in VT9 by the list of columns in the ORDER by clause.
    11. TOP: selects the specified number or scale of rows from the beginning of the VC10, generates the table VT11, and returns the caller.

Note: Step 10, this step is the first step and the only step that can be used to use column aliases in the select list.

Reference: http://tech.ddvip.com/2009-04/1239449159114603.html

Various stages in SQL Server query processing (SQL execution order)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.