ORDERED好理解,就是表示根据 from 后面表的顺序join,从左到右,左边的表做驱动表。
use_nl(t1,t2):表示对表t1、t2关联时采用嵌套循环连接,其并不能让优化器确定谁是驱动表或谁是被驱动的表。
USE_NL(),先看看oracle doc怎么说:
In this statement, the USE_NL hint explicitly chooses a nested loops join with the customers table as the inner table:
SELECT /*+ ORDERED USE_NL(customers) to get first row faster */ accounts.balance, customers.last_name, customers.first_name FROM accounts, customers WHERE accounts.customer_id = customers.customer_id;
customers 作为inner table,也就是说作为被驱动表。驱动表称为outer table。
如果指定的表是outer table(驱动表),则优化器会忽略这个hint。
如果非要强制它作为inner table,可以配上ordered参数。
oradered 表示根据from 后面表的顺序,从左到右join,左表做驱动表,3个或3个以上最有用。
也就是说use_nl如果只带了一个表名作为参数,则该表为被驱动表。
如果带了2个以上的参数,Oracle并没有指出use_nl(a,b)中哪个是驱动表,所以常使用ordered或者full()或者index()来强化我们的目标。
以下是测试:
hr@ORCL> select first_name,departments.department_id from employees,departments where employees.department_id=departments.department_id; Execution Plan ---------------------------------------------------------- Plan hash value: 169719308 --------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 106 | 1484 | 3 (0)| 00:00:01 | | 1 | NESTED LOOPS | | 106 | 1484 | 3 (0)| 00:00:01 | | 2 | TABLE ACCESS FULL| EMPLOYEES | 107 | 1070 | 3 (0)| 00:00:01 | |* 3 | INDEX UNIQUE SCAN| DEPT_ID_PK | 1 | 4 | 0 (0)| 00:00:01 | ---------------------------------------------------------------------------------
此处优化器选择employees作为驱动表,因为departments上有索引,而且索引正好建立在连接列上。
hr@ORCL> select /*+ use_nl(employees) */ first_name,departments.department_id from employees,departments where employees.department_id=departments.department_id; Execution Plan ---------------------------------------------------------- Plan hash value: 169719308 --------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 106 | 1484 | 3 (0)| 00:00:01 | | 1 | NESTED LOOPS | | 106 | 1484 | 3 (0)| 00:00:01 | | 2 | TABLE ACCESS FULL| EMPLOYEES | 107 | 1070 | 3 (0)| 00:00:01 | |* 3 | INDEX UNIQUE SCAN| DEPT_ID_PK | 1 | 4 | 0 (0)| 00:00:01 | ---------------------------------------------------------------------------------
由于employees是作为驱动表,优化器会忽略hint提示。
hr@ORCL> select /*+ ordered use_nl(employees) */ first_name,departments.department_id from departments,employees where employees.department_id=departments.department_id; Execution Plan ---------------------------------------------------------- Plan hash value: 2677871237 ------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 106 | 1484 | 8 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| EMPLOYEES | 4 | 40 | 1 (0)| 00:00:01 | | 2 | NESTED LOOPS | | 106 | 1484 | 8 (0)| 00:00:01 | | 3 | INDEX FULL SCAN | DEPT_ID_PK | 27 | 108 | 1 (0)| 00:00:01 | |* 4 | INDEX RANGE SCAN | EMP_DEPARTMENT_IX | 10 | | 0 (0)| 00:00:01 | -------------------------------------------------------------------------------------------------
现在是departments作为驱动表了。
相关推荐
介绍了oracle中的hint,常用的 ordered、use_nl、use_hash、index、full 五种, 给出使用实例和适用场景
SQL语句优化过程优化策略 ...SELECT /*+ORDERED USE_NL(BSEMPMS)*/ BSDPTMS.DPT_NO,BSEMPMS.EMP_NO,BSEMPMS.EMP_NAM FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO; 23. /*+USE_MERGE(TABLE)*/
6.4.1 use_hash,use_nl和use_merge hint 127 6.4.2 no_use_hash hint 132 6.4.3 no_use_merge hint 133 6.4.4 no_use_nl hint 133 6.5 并行执行相关的hint 134 6.5.1 parallel hint 134 6.5.2 no_parallel hint 134...
use_nl hint指示查询优化器使用nested loops方式连接指定表和其他行源,并且将强制指定表作为inner表。 在mysql中就有之对应的straight_join,由于mysql只支持nested loops的连接方式,所以这里的straight_join类似...
6.4.1 use_hash,use_nl和use_merge hint 127 6.4.2 no_use_hash hint 132 6.4.3 no_use_merge hint 133 6.4.4 no_use_nl hint 133 6.5 并行执行相关的hint 134 6.5.1 parallel hint 134 6.5.2 no_parallel hint 134...
§7.1 应用系统环境规划和Oracle系统安装考虑 91 §7.1.1 操作系统安装考虑 91 §7.1.2 Oracle系统安装考虑 92 §7.2 关于创建多个Oracle实例问题 93 §7.3 Oracle系统安装后的优化基础工作 94 §7.3.1 Oracle系统...
但是聪明的Oracle DBA和开发人员能够改变表的搜索限制参数或者使用ordered提示来手工指定表的连接顺序,从而显著地减少优化和执行新查询所需的时间。消耗在准备新的SQL语句的时间是Oracle SQL语句执行时间的最重要的...
OrderedDictionary, 这里库提供OrderedDictionary和MutableOrderedDictionary子类 命令行目存储在NSDictionary中的对象的顺序未定义。 通常,可以以通过一组键/值对循环,并按照插入的顺序返回对象。 这个库提供了两...
这个函数可以方便地从大量变量中采样成对相关。 输入参数: N:定义数字的范围(从 1 到 N) pair_num:对的数量有序:1 表示有序对,0 表示无序。 默认值为 0。 self_pair: 1 允许自配对(例如,3-3 是自配对)。...
ordered-map:保留插入顺序的C ++哈希映射和哈希集
资源来自pypi官网。 资源全名:orderedset-1.2.tar.gz
java ordered接口应用,和gradle配置下部署了一个spring boot项目,并且写了一个例子,解压直接部署就可以用
gem 'ordered_find' 然后执行: $ bundle 或者自己安装: $ gem install ordered_find 用法 SomeModel.ordered_find([1, 3, 2, 1]) => [#, #, #, #] 或者 SomeModel.ordered_find(1, 3, 2) SomeModel....
M13OrderedDictionary, 带有有序对象和键的NSDictionary M13OrderedDictionaryM13OrderedDictionary是NSArray和NSDictionary之间的交叉。 它包含一个有序的对象和键列表。 所有这些都可以通过索引或者键访问。 这里...
资源分类:Python库 所属语言:Python 资源全名:ordered_argparse-1.0.10-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Oracle必须花费大量的时间来剖析多表格的合并,用以确定表格合并的最佳顺序。如果SQL表达式涉及七个乃至更多的表格合并,那么有时就会...使用ordered提示会跳过非常耗时和耗资源的剖析操作,并加快Oracle SQL的执行。
这个 repository 旨在让更多人看到后可以更好的理解 google cartographer 这个项目的代码,不过由于我的项目主要是用到 2d 这一块,所以我删减掉了 mapping_3d 这个文件夹的内容,并将代码中少量用到3d的部分挪到了 ...
1. /*+ INDEX */ 和 /*+ INDEX(TABLE INDEX1, index2) */ 和 /*+ INDEX(tab1.col1 tab2.col2) */ 和 /*+ NO_INDEX */ 和 /*+ NO_INDEX(TABLE INDEX1, index2) */ 2. /*+ ORDERED */ 3. /*+ PARALLEL(table1,DEGREE) ...
last event might point to some random place in the list as it s the last queued event. We expect that the new event is close to this.
You may only reproduce, install and use the software product for use with only one developer. If you have multiple validly licensed copies of the software product, you may reproduce, install and use ...