【发布时间】:2017-03-05 06:45:27
【问题描述】:
EXPLAIN PLAN FOR
SELECT sightings.sighting_id, spotters.spotter_name,
sightings.sighting_date
FROM sightings
INNER JOIN spotters
ON sightings.spotter_id = spotters.spotter_id
WHERE sightings.spotter_id = 1255;
SELECT plan_table_output
FROM table(dbms_xplan.display('plan_table',null,'basic'));
id Operation Name
0 select statement
1 nested loops
2 table access by index rowid spotters
3 index unique scan pk_spotter_ID
4 table access full sightings
我试图了解这里到底发生了什么,这听起来对吗:
首先对 select 语句求值,输出中忽略 select 列表中的属性
然后嵌套循环计算 spotters.spotters_id =Sightings.spotter_id 上的内连接
按索引 rowid 的表访问从 spotters 表中检索具有第 3 步返回的 rowid 的行
索引唯一扫描,扫描 PK_SPOTTER_ID 索引中的 spotter_id 并在 spotters 表中查找 rowids 关联的行
表访问已满,然后完全扫描目击,直到找到Sighting_id = 1255
【问题讨论】:
-
看来你放错了执行计划
-
是的,对不起!我现在编辑了它
-
从下往上从左到右读取执行计划。
Id列不表示先执行操作。尽管执行计划以列表(表格)形式呈现给您,但它实际上是树形形式。所以你从树叶开始读它。 1.Index unique scan先到后 2.sightings table access full3.spotters被索引 rowid 访问 4.nested loop最后是 5.selectfind out more