Explain plan for struct and array in Oracle

Source: Internet
Author: User

The previous article introduced how to explain the struct and array in Oracle,

  1. Explain plan
  2. Select * from table (dept_array (department_type (
  3. 1, -- DNO number (10 ),
  4. 'Name', -- name varchar2 (50 ),
  5. 'Location' -- location varchar2 (50)
  6. ) T
  7. Join Table2 T2 on T. DNO = t2.dno;
  8. Select * from table (dbms_xplan.display );

The running result contains the following data:

  1. Plan_table_output
  2. 1 plan hash value: 1748000095
  3. 2
  4. 3 Cores ----------------------------------------------------------------------------------------------
  5. 4 | ID | operation | Name | rows | bytes | cost (% CPU) | time |
  6. 5 Cores ----------------------------------------------------------------------------------------------
  7. 6 | 0 | SELECT statement |8168| 16336 | 24 (0) | 00:00:01 |
  8. 7 | 1 | collection iterator constructor fetch |
  9. 8 bytes ----------------------------------------------------------------------------------------------

By default, the number of data rows in array is 8168. However, the number of rows in array varies depending on different scenarios. Use cardinality hint to let optimizer know the number of rows in the array.

  1. Explain plan
  2. Select/* + cardinality (T10) */* From table (dept_array (department_type (
  3. 1, -- DNO number (10 ),
  4. 'Name', -- name varchar2 (50 ),
  5. 'Location' -- location varchar2 (50)
  6. ) T
  7. Join Table2 T2 on T. DNO = t2.dno;
  8. Select * from table (dbms_xplan.display );

Running result:

  1. Plan_table_output
  2. 1 plan hash value: 1748000095
  3. 2
  4. 3 Cores ----------------------------------------------------------------------------------------------
  5. 4 | ID | operation | Name | rows | bytes | cost (% CPU) | time |
  6. 5 Cores ----------------------------------------------------------------------------------------------
  7. 6 | 0 | SELECT statement |10| 20 | 24 (0) | 00:00:01 |
  8. 7 | 1 | collection iterator constructor fetch |
  9. 8 bytes ----------------------------------------------------------------------------------------------

The number 10 is the maximum number of rows in array.

 

Refer:

The cardinality hint when you are using PL/SQL collections in SQL

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.