“回表”一般就是指执行计划里显示的“TABLE ACCESS BY INDEX ROWID”。 例如select的字段里有索引不包含的列, SQL> select ename from emp where empno =1;
Execution Plan ---------------------------------------------------------- Plan hash value: 4066871323
---------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 1 | | 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 1 | |* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 1 | ----------------------------------------------------------------------
Predicate Information (identified by operation id): ---------------------------------------------------
2 - access("EMPNO"=1)
再例如,虽然只查询索引里的列,但是需要回表过滤掉其他行。 SQL> select empno from emp where empno =1 and ename='hao';
Execution Plan ---------------------------------------------------------- Plan hash value: 4066871323
---------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 1 | |* 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 1 | |* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 1 | ----------------------------------------------------------------------
Predicate Information (identified by operation id): ---------------------------------------------------
1 - filter("ENAME"='hao') 2 - access("EMPNO"=1) |
|
|
“回表”一般就是指执行计划里显示的“TABLE ACCESS BY INDEX ROWID”。 例如select的字段里有索引不包含的列, SQL> select ename from emp where empno =1;
Execution Plan ---------------------------------------------------------- Plan hash value: 4066871323
---------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 1 | | 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 1 | |* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 1 | ----------------------------------------------------------------------
Predicate Information (identified by operation id): ---------------------------------------------------
2 - access("EMPNO"=1)
再例如,虽然只查询索引里的列,但是需要回表过滤掉其他行。 SQL> select empno from emp where empno =1 and ename='hao';
Execution Plan ---------------------------------------------------------- Plan hash value: 4066871323
---------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 1 | |* 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 1 | |* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 1 | ----------------------------------------------------------------------
Predicate Information (identified by operation id): ---------------------------------------------------
1 - filter("ENAME"='hao') 2 - access("EMPNO"=1) |
|
|
“回表”一般就是指执行计划里显示的“TABLE ACCESS BY INDEX ROWID”。
例如select的字段里有索引不包含的列,
SQL> select ename from emp where empno =1;
Execution Plan
----------------------------------------------------------
Plan hash value: 4066871323
----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 8 | 1 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 1 |
|* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 1 |
----------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO"=1)
再例如,虽然只查询索引里的列,但是需要回表过滤掉其他行。
SQL> select empno from emp where empno =1 and ename='hao';
Execution Plan
----------------------------------------------------------
Plan hash value: 4066871323
----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 8 | 1 |
|* 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 8 | 1 |
|* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 1 |
----------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("ENAME"='hao')
2 - access("EMPNO"=1)