分类 | 说明 | 具体Hint |
初始化参数 | 可以覆盖在系统级或会话定义的部分的初始化参数 | all_rows,first_rows,cursor_sharing_exact, dynamic_sampling, gather_plan_statisitcs,no_cpu_costing,optimizer_features_enable,opt_param,(no_)result_cache,rule |
查询转化 | 在逻辑优化阶段控制查询转化技术的使用 | (no_)eliminate_join,no_expand,(no_)merge,(no_)outer_join_inner,(no_)push_pred,(no_)push_subq,no_query_transformation,(no_)rewrite,(no_)nunest,no_xmlindex_rewrite,no_xml_query_rewrite use_concat |
访问路径 | 控制访问数据的方法,比如是否使用索引等 | cluster,full,hash,(no_)index,index_asc,index_combine,index_desc,(no_)index_ffs,index_join,(no_)index_ss, index_ss_asc,index_ss_desc |
连接提示 | 不仅控制连接的方法,还控制连接表的顺序 | leading,(no_)nljbatching,ordered,(no_)start_transformation,(no_)swap_join_inputs,(no_)use_hash,(no_)use_merge,use_merge_cartesian,(no_)use_nl,use_nl_with_index |
并行处理 | 控制如何使用并行处理 | (no_)parallel,(no_)parallel_index,pq_distribute,(no_)px_join_filter |
其他 | 控制没有归到前几种分裂的其他一些特性的使用 | cardinality,(no_)append, (no_)cache,driving_site,model_min_analysis,(no_)monitor,qd_name |
cardinality: 模拟执行计划中 rows 列的数据,用以欺骗 Oracle,影响执行计划。
hint示例:
嵌套循环:
/*+ leading(t1)use_nl(t2) */ 其中use_nl表示强制用嵌套循环连接方式。Leading(t1)表示强制先访问tl表,也就是tl表作为驱动表。
强制使用索引:
/*+ INDEX (tab pk_tab)*/ tab是表名, pk_tab是索引名。
并行join:
/*+ parallel PQ_DISTRIBUTE(lce none broadcast)*/ 或 /*+ parallel PQ_DISTRIBUTE(lce none broadcast) full(lce) full(c)*/ 其中lce是小表
/*+ parallel PQ_DISTRIBUTE(a hash hash)*/ 如果两张表都是大表,建议 hash 分发