The change of index merge and and_equal in Oracle

Source: Internet
Author: User
Tags hash range oracle database

And_equal is a specific operation supported by Oracle that can combine multiple Single-column indexes (index merge) to output query results.

At the same time and_equal can be enforced by hints, with a minimum of two indexes specified, up to 5.

The following execution plans are common and_equal execution methods:

Sql> Select/*+ and_equal (T1 IU II) * * Username,password from T1 where username= ' Eygle ' and user_id=58;

USERNAME PASSWORD

------------------------------ ------------------------------

Eygle b726e09fe21f8e83

Execution plan

----------------------------------------------------------

Plan Hash value:1425017857

------------------------------------------------------------------------------------

| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |

------------------------------------------------------------------------------------

| 0 |      SELECT STATEMENT |     |    1 |     47 | 2 (0) | 00:00:01 |

|* 1 | TABLE ACCESS by INDEX rowid|     T1 |    1 |     47 | 2 (0) | 00:00:01 |

|   2 |      and-equal |       |       |            |          | |

|* 3 | INDEX RANGE SCAN |     II |       1 |     | 1 (0) | 00:00:01 |

|* 4 | INDEX RANGE SCAN |     IU |       1 |     | 1 (0) | 00:00:01 |

------------------------------------------------------------------------------------

predicate information (identified by Operation ID):

---------------------------------------------------

1-filter ("USERNAME" = ' eygle ' and "user_id" =58)

3-access ("user_id" =58)

4-access ("USERNAME" = ' eygle ')

However, starting with Oracle 10g, the and_equal operation was discarded (depricated) and Oracle no longer supports it. The meaning of abandonment here is not to be removed completely, but to say no further improvement, through hints still can force to implement the and_equal operation of the index merge.

The output above is from Oracle 10.2.0.4, and when using the rule hint, Oracle chooses And_equal, so it is no longer supported because the method is too restrictive and is far less flexible than the composite index:

Sql> select * from V$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0-prod

Pl/sql Release 10.2.0.4.0-production

CORE 10.2.0.4.0 Production

TNS for 32-bit windows:version 10.2.0.4.0-production

Nlsrtl Version 10.2.0.4.0-production

Sql> Select/*+ Rule */Username,password from T1 where username= ' Eygle ' and user_id=58;

USERNAME PASSWORD

------------------------------ ------------------------------

Eygle b726e09fe21f8e83

Execution plan

----------------------------------------------------------

Plan Hash value:3072843751

--------------------------------------------

| Id | Operation | Name |

--------------------------------------------

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

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.