[ 登录注册 ]

语言

举例一个比较好的表连接的执行计划

2017-07-14 10:37:59 admin 返回上一页

标签:执行计划   oracle   

SQL> var loc varchar2(30)SQL> exec :loc:='South San Francisco'PL/SQL procedure successfully completed.SQL> SELECT2  emp.last_nameemp.first_namej.job_titled.department_namel.cityl.state_provincel.postal_codel.street_address3  emp.emailemp.phone_numberemp.hire_dateemp.salarymgr.last_name4  from hr.employees emphr.employees mgrhr.departments dhr.locations5  lhr.jobs j6  where l.city =:loc7  and emp.manager_id=mgr.employee_id8  and emp.department_id=d.department_id9  and d.location_id=l.location_id10  and emp.job_id=j.job_id;--每次都是以嵌套循环来完成整个的查询流程,这就是一个最好的执行计划45 rows selected.Execution Plan----------------------------------------------------------Plan hash value: 4121168346<span style="font-size:10px;">-----------------------------------------------------------------------------------------------------| Id  | Operation                       | Name              | Rows  | Bytes | Cost (%CPU)| Time     |-----------------------------------------------------------------------------------------------------|   0 | SELECT STATEMENT                |                   |    15 |  2580 |     8   (0)| 00:00:01 ||   1 |  NESTED LOOPS                   |                   |    15 |  2580 |     8   (0)| 00:00:01 ||   2 |   NESTED LOOPS                  |                   |    15 |  2400 |     6   (0)| 00:00:01 ||   3 |    NESTED LOOPS                 |                   |    15 |  1995 |     5   (0)| 00:00:01 ||   4 |     NESTED LOOPS                |                   |     4 |   268 |     3   (0)| 00:00:01 ||   5 |      TABLE ACCESS BY INDEX ROWID| LOCATIONS         |     1 |    48 |     2   (0)| 00:00:01 ||*  6 |       INDEX RANGE SCAN          | LOC_CITY_IX       |     1 |       |     1   (0)| 00:00:01 ||   7 |      TABLE ACCESS BY INDEX ROWID| DEPARTMENTS       |     4 |    76 |     1   (0)| 00:00:01 ||*  8 |       INDEX RANGE SCAN          | DEPT_LOCATION_IX  |     4 |       |     0   (0)| 00:00:01 ||   9 |     TABLE ACCESS BY INDEX ROWID | EMPLOYEES         |     4 |   264 |     1   (0)| 00:00:01 ||* 10 |      INDEX RANGE SCAN           | EMP_DEPARTMENT_IX |    10 |       |     0   (0)| 00:00:01 ||  11 |    TABLE ACCESS BY INDEX ROWID  | JOBS              |     1 |    27 |     1   (0)| 00:00:01 ||* 12 |     INDEX UNIQUE SCAN           | JOB_ID_PK         |     1 |       |     0   (0)| 00:00:01 ||  13 |   TABLE ACCESS BY INDEX ROWID   | EMPLOYEES         |     1 |    12 |     1   (0)| 00:00:01 ||* 14 |    INDEX UNIQUE SCAN            | EMP_EMP_ID_PK     |     1 |       |     0   (0)| 00:00:01 |-----------------------------------------------------------------------------------------------------</span>Predicate Information (identified by operation id):---------------------------------------------------6 - access("L"."CITY"=:LOC)8 - access("D"."LOCATION_ID"="L"."LOCATION_ID")10 - access("EMP"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")12 - access("EMP"."JOB_ID"="J"."JOB_ID")14 - access("EMP"."MANAGER_ID"="MGR"."EMPLOYEE_ID")Statistics----------------------------------------------------------2035  recursive calls0  db block gets669  consistent gets19  physical reads0  redo size3923  bytes sent via SQL*Net to client407  bytes received via SQL*Net from client4  SQL*Net roundtrips to/from client24  sorts (memory)0  sorts (disk)45  rows processed

举例一个比较好的表连接的执行计划布布扣bubuko.com

举例一个比较好的表连接的执行计划

标签:执行计划   oracle   


文章来源:http://www.bozhiyue.com/yuyan/2017/0714/1484290.html
返回上一页    返回分类 上一篇:   下一篇:
相关