日期:2014-05-16 浏览次数:20367 次
以下是测试:
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 | ---------------------------------------------
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 | ---------------------------------------------
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 | ---------------