Middle+
What hints are used in Oracle to speed up queries?
sobes.tech AI
Answer from AI
In Oracle, various hints are used to speed up queries, which influence the query optimizer. Some commonly used hints:
- /*+ INDEX(table_name index_name) */ — forces the use of a specific index.
- /*+ FULL(table_name) */ — forces a full table scan.
- /*+ NO_MERGE(table_name) */ — prevents merging of views or subqueries.
- /*+ LEADING(table1 table2) */ — sets the join order of tables.
- /*+ USE_NL(table1 table2) */ — uses nested loops for joins.
- /*+ PARALLEL(table_name, degree) */ — enables parallel execution of the query.
Example of using a hint:
SELECT /*+ INDEX(emp emp_dept_idx) */ * FROM emp WHERE dept_id = 10;
Hints help the optimizer choose a more efficient execution plan, especially in complex queries or with non-standard data.