[Oracle] table join

Source: Internet
Author: User

In the OLTP system, nested connections account for about 70%, hash connections account for 20%, and merge sorted connections account for 10%.

Nested connection

Algorithm: Nested join selects a small table as the driver table from two tables, and a large table as the driver table. First, access the driver table (only once ), then, access the driver table multiple times based on the number of rows returned by the driver table (the number of times the driver table accesses is equal to the number of rows returned by the driver table ).

Based on the above algorithm, we can know that to make the nested connection performance better, we must satisfy the following three conditions at the same time:

1) the number of rows returned by the driver table must be small enough (reducing the number of visits to the driver table );

2) The restrictions on the driver table must be indexed (Improving the performance of the driver table );

3) The connection conditions of the driven table must be indexed (Improving the Performance of accessing the driven table ).

As mentioned above, nested connections account for 70% in the OLTP system, because the OLTP system returns less data and is suitable for nested connections. Another reason is that there is almost no restriction on nested connections, all operations can be connected using nested connections, unlike hash connections and merge sort connections.

Hash connection

Algorithm: Hash join selects a small table from two tables as the driving table. The large table is the driving table. A hash table is constructed based on the driving table, then, each row of the driven table performs hash matching in the hash table. The driver table and the driver table are accessed once each time.

Based on the above algorithm, we can know that hash connectionsOnly supports equivalent connections.

To ensure good hash connection performance, make sure that the driver table is small enough so that the memory PGA can put down the hash table.

Merge sort join algorithm: The merge sort join algorithm sorts two tables first, and then compares and merges the tables according to the sorting results. The merging and sorting links do not have the concepts of the driver table and the driver table. There are many restrictions on merging sort connections. Supported values include <, but not like and <>
The maximum performance overhead of this connection method is 2 sorting, so it is rarely used in OLTP systems.

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.