Oracle Performance Tuning Order table name to select the most effective learning notes

Source: Internet
Author: User
Tags one table time 0

Select the most efficient sequential table name (only valid rule-based optimizations)

The Oracle parser handles the table name from right-to-left from the FROM clause to the order, so the From is written in the final table (the underlying table, driving tables) will be processed first. In the case of including more than one table in the FROM clause, You must select a table with the fewest number of records to use as the underlying table. When Oracle processes multiple tables, it connects them in a sort and merge manner. First, scan the first table (the last table in the FROM clause) and order the records, and then scan the second table (the last second table in the FROM clause). Finally, all records retrieved from the second table are merged with the appropriate records from the first table.

Like what:

Table tab1:16,384 Records, table Tab2:1 Records

Select TAB2 as the base table (best method): Run time 0.96 seconds

Select TAB2 as the base table (poor method): Run time 26.09 seconds

Select COUNT (*) from TAB2,TAB1
If you have more than 3 tables connected to the query, you need to select the crosstab (intersection table) as the underlying table, which is the table referenced by the other table.
Like what:

The EMP table description describes the intersection of the location table and the category table.

SELECT * from location L,       CATEGORY C,      EMP E WHERE e.emp_no between and 2000AND e.cat_no = C.cat_noand E.LOCN = L.LOCN
will be more efficient than the following SQL:

SELECT * from EMP E, location L,       CATEGORY cwhere  e.cat_no = C.cat_noand E.LOCN = L.locnand e.emp_no between 1000 and 2000
Small bet
This digest is from Baidu Library, detailed link wood has found. I'm sorry.


Copyright: Author: jiankunking Resources: http://blog.csdn.net/jiankunking This article is copyrighted by the author and Csdn jointly owned. Welcome reprint. However, if the submit permission is not declared from this section, it must be persisted and connected to the original article page given the view location.

Oracle Performance Tuning Order table name to select the most effective learning notes

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.