30 methods of SQL statement optimization (1/4)

Source: Internet
Author: User
1./*+all_rows*/


It is shown that the cost-based optimization method is chosen for the statement block, and the optimal throughput is achieved to minimize resource consumption.
For example:

Select/*+all+_rows*/emp_no,emp_nam,dat_in from Bsempms where emp_no= ' Scott ';


2./*+first_rows*/
It is shown that the cost-based optimization method is chosen for the statement block, and the optimal response time is obtained to minimize the resource consumption.
For example:

Select/*+first_rows*/emp_no,emp_nam,dat_in from Bsempms where emp_no= ' Scott ';

3./*+choose*/
Indicates that if the data dictionary has access to the statistical information of the table, it will be based on the cost optimization method and obtain the best throughput;
Indicates that if there is no statistical information in the data dictionary to access the table, an optimization method based on rule cost is proposed.
For example:

Select/*+choose*/emp_no,emp_nam,dat_in from Bsempms where emp_no= ' Scott ';

4./*+rule*/
It shows that the rule-based optimization method is chosen for the statement block.
For example:

Select/*+ Rule * * emp_no,emp_nam,dat_in from Bsempms where emp_no= ' Scott ';

5./*+full (table) * *
Indicates a method for selecting a global scan on a table.
For example:

Select/*+full (A) * * * Emp_no,emp_nam from Bsempms a where emp_no= ' Scott ';

6./*+rowid (table) * *
The prompt explicitly indicates that the specified table is accessed according to ROWID.
For example:

Select/*+rowid (BSEMPMS) * * from Bsempms where rowid>= ' aaaaaaaaaaaaaa '
and emp_no= ' Scott ';

7./*+cluster (table) * *
Tip explicitly indicates the access method that selects a cluster scan for a specified table, which is only valid for a cluster object.
For example:

Select/*+cluster */bsempms.emp_no,dpt_no from BSEMPMS,BSDPTMS
where dpt_no= ' tec304 ' and bsempms.dpt_no=bsdptms.dpt_no;

8./*+index (Table index_name) * *
Indicates the scanning method for selecting indexes on a table.
For example:

Select/*+index (Bsempms sex_index) use sex_index because there are fewmale the Bsempms/from Bsempms where sex= ' m ';

9./*+INDEX_ASC (Table index_name) * *
Indicates a scan method that selects index ascending for the table.
For example:

Select/*+INDEX_ASC (Bsempms pk_bsempms) */from Bsempms where dpt_no= ' Scott ';

Home 1 2 3 4 last page

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.