Common OracleHINT usage

Source: Internet
Author: User
Welcome to the Oracle community forum and interact with 2 million technical staff. 1. * + ALL_ROWS * indicates to select an overhead-Based Optimization Method for the statement block and obtain the optimal throughput to minimize resource consumption. example: SELECT * + ALL + _ ROWS * EMP_NO, EMP_NAM, DAT_INFROMBSEMPMSWHEREEMP_NOSCOTT; 2. * + FIRST _

Welcome to the Oracle community forum and interact with 2 million technical staff> enter 1. /* + ALL_ROWS */indicates to select the overhead-Based Optimization Method for the statement block and obtain the optimal throughput to minimize resource consumption. example: SELECT/* + ALL + _ ROWS */EMP_NO, EMP_NAM, DAT_IN from bsempms where EMP_NO = 'Scott '; 2. /* + FIRST _

Welcome to the Oracle community forum and interact with 2 million technical staff> enter

1./* + ALL_ROWS */
It indicates that the overhead-based optimization method is selected for the statement block, and the optimal throughput is obtained to minimize the resource consumption.
For example:
SELECT/* + ALL + _ ROWS */EMP_NO, EMP_NAM, DAT_IN from bsempms where EMP_NO = 'Scott ';
2./* + FIRST_ROWS */
It indicates that the overhead-based optimization method is selected 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 */
It indicates that if the data dictionary contains statistics about the access table, the overhead-based optimization method is used to obtain the optimal throughput;
It indicates that if no statistical information of the Access Table is found in the data dictionary, the rule overhead-based optimization method is used;
For example:
SELECT/* + CHOOSE */EMP_NO, EMP_NAM, DAT_IN from bsempms where EMP_NO = 'Scott ';

4./* + RULE */
Indicates the rule-based Optimization Method for the statement block.
For example:
SELECT/* + RULE */EMP_NO, EMP_NAM, DAT_IN from bsempms where EMP_NO = 'Scott ';

5./* + FULL (TABLE )*/
Indicates the method used to globally scan the 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 Based on ROWID.
For example:
SELECT/* + ROWID (BSEMPMS) */* from bsempms where rowid> = 'aaaaaaaaaaaaaaa'
AND EMP_NO = 'Scott ';

7./* + CLUSTER (TABLE )*/
The prompt clearly indicates the access method for the selected cluster scan for the specified table, which is only valid for the 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 method used to scan the selected index on the table.
For example:
SELECT/* + INDEX (BSEMPMS SEX_INDEX) USE SEX_INDEX because there are fewmale bsempms */from bsempms where sex = 'M ';

9./* + INDEX_ASC (TABLE INDEX_NAME )*/
Indicates the method used to scan the index in ascending order.
For example:
SELECT/* + INDEX_ASC (BSEMPMS PK_BSEMPMS) */from bsempms where DPT_NO = 'Scott ';

10./* + INDEX_COMBINE */
Select a bitmap access path for the specified table. If INDEX_COMBINE does not provide an index as a parameter, a Boolean combination of the index is selected.
For example:
SELECT/* + INDEX_COMBINE (BSEMPMS SAL_BMI HIREDATE_BMI) */* FROM BSEMPMS
Where sal <5000000 AND HIREDATE

11./* + INDEX_JOIN (TABLE INDEX_NAME )*/
It is prompted that the command optimizer uses the index as the access path.
For example:
SELECT/* + INDEX_JOIN (BSEMPMS SAL_HMI HIREDATE_BMI) */SAL, HIREDATE
From bsempms where sal <60000;

12./* + INDEX_DESC (TABLE INDEX_NAME )*/
Indicates the method used to scan the table in descending order of indexes.
For example:
SELECT/* + INDEX_DESC (BSEMPMS PK_BSEMPMS) */from bsempms where DPT_NO = 'Scott ';

13./* + INDEX_FFS (TABLE INDEX_NAME )*/
Perform a quick full index scan for the specified table, instead of a full table scan.
For example:
SELECT/* + INDEX_FFS (BSEMPMS IN_EMPNAM) */* from bsempms where DPT_NO = 'tec305 ';

14./* + ADD_EQUAL TABLE INDEX_NAM1, INDEX_NAM2 ,...*/
The prompt is to clearly select the execution plan and combine the scanning of Several Single Column indexes.
For example:
SELECT/* + INDEX_FFS (BSEMPMS IN_DPTNO, IN_EMPNO, IN_SEX) */* from bsempms where EMP_NO = 'Scott 'AND DPT_NO = 'tdc306 ';

15./* + USE_CONCAT */
Convert the OR condition following the WHERE clause in the query to the union all clause.
For example:
SELECT/* + USE_CONCAT */* from bsempms where DPT_NO = 'tdc506 'and sex = 'M ';

16./* + NO_EXPAND */
For the or in-LIST query statement after the WHERE clause, NO_EXPAND will prevent it from being extended based on the optimizer.
For example:
SELECT/* + NO_EXPAND */* from bsempms where DPT_NO = 'tdc506 'and sex = 'M ';

17./* + NOWRITE */
Query Rewriting of query blocks is prohibited.

18./* + REWRITE */
The view can be used as a parameter.

19./* + MERGE (TABLE )*/
Merge View queries accordingly.
For example:
SELECT/* + MERGE (V) */A. EMP_NO, A. EMP_NAM, B. DPT_NO FROM BSEMPMS A (SELET DPT_NO
, AVG (SAL) AS AVG_SAL from bsempms B GROUP BY DPT_NO) V WHERE A. DPT_NO = V. DPT_NO
And a. SAL> V. AVG_SAL;

20./* + NO_MERGE (TABLE )*/
Views that can be merged are not merged.
For example:
SELECT/* + NO_MERGE (V) */. EMP_NO,. EMP_NAM, B. DPT_NO from bsempms a (SELECT DPT_NO, AVG (SAL) AS AVG_SAL from bsempms B GROUP BY DPT_NO) V WHERE. DPT_NO = V. DPT_NO and. SAL> V. AVG_SAL;

21./* + ORDERED */
According to the order in which the table appears in FROM, ORDERED connects ORACLE to the table in this order.
For example:
SELECT/* + ORDERED */. COL1, B. COL2, C. COL3 FROM TABLE1 A, TABLE2 B, TABLE3 C WHERE. COL1 = B. COL1 and B. COL1 = C. COL1;

22./* + USE_NL (TABLE )*/
Concatenates the specified table with the nested connected row source and uses the specified table as the internal table.
For example:
SELECT/* + ORDERED USE_NL (BSEMPMS) */BSDPTMS. Release, BSEMPMS. EMP_NO, BSEMPMS. EMP_NAM from bsempms, bsdptms where bsempms. DPT_NO = BSDPTMS. release;

23./* + USE_MERGE (TABLE )*/
The specified table is connected to other row sources by means of merged sort connections.
For example:
SELECT/* + USE_MERGE (BSEMPMS, BSDPTMS) */* from bsempms, bsdptms where bsempms. DPT_NO = BSDPTMS. DPT_NO;

24./* + USE_HASH (TABLE )*/
Connects the specified table to other row sources by means of hash connections.
For example:
SELECT/* + USE_HASH (BSEMPMS, BSDPTMS) */* from bsempms, bsdptms where bsempms. DPT_NO = BSDPTMS. DPT_NO;

25./* + DRIVING_SITE (TABLE )*/
Execute a query on a table in a different position than that selected by ORACLE.
For example:
SELECT/* + DRIVING_SITE (DEPT) */* from bsempms, DEPT @ bsdptms where bsempms. DPT_NO = DEPT. DPT_NO;

26./* + LEADING (TABLE )*/
Use the specified table as the first table in the connection order.

27./* + CACHE (TABLE )*/
When a full table scan is performed, the CACHE prompts that the retrieval block of the table can be placed in the nearest least recently used LRU list in the buffer CACHE.
For example:
SELECT/* + FULL (BSEMPMS) CAHE (BSEMPMS) */EMP_NAM from bsempms;

28./* + NOCACHE (TABLE )*/
When a full table scan is performed, the CACHE prompts that the retrieval block of the table can be placed in the nearest least recently used LRU list in the buffer CACHE.
For example:
SELECT/* + FULL (BSEMPMS) NOCAHE (BSEMPMS) */EMP_NAM from bsempms;

29./* + APPEND */
Insert directly to the end of the table to increase the speed.
Insert/* + append */into test1 select * from test4;

30./* + NOAPPEND */
By stopping parallel mode during the lifetime of the insert statement, you can start regular insert.
Insert/* + noappend */into test1 select * from test4;

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.