您的位置:首页 > 其它

DISTINCT 列添加索引

2016-04-15 18:03 483 查看
添加索引后,没啥效要,这方面优化没啥效果,如果项目要用到DISTINCT进行去重,需要再去确认基表关联,确认业务。

SQL> select t.object_id from t_distinct_tb t ;

已选择50631行。

已用时间:  00: 00: 00.71

执行计划
----------------------------------------------------------
Plan hash value: 1512865825

-----------------------------------------------------------------------------------
| Id  | Operation         | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |               | 50086 |   635K|   161   (2)| 00:00:02 |
|   1 |  TABLE ACCESS FULL| T_DISTINCT_TB | 50086 |   635K|   161   (2)| 00:00:02 |
-----------------------------------------------------------------------------------

Note
-----
- dynamic sampling used for this statement

统计信息
----------------------------------------------------------
50  recursive calls
0  db block gets
4109  consistent gets
696  physical reads
0  redo size
732835  bytes sent via SQL*Net to client
37510  bytes received via SQL*Net from client
3377  SQL*Net roundtrips to/from client
0  sorts (memory)
0  sorts (disk)
50631  rows processed

SQL> select distinct t.object_id from t_distinct_tb t ;

已选择50631行。

已用时间:  00: 00: 00.56

执行计划
----------------------------------------------------------
Plan hash value: 3170339755

--------------------------------------------------------------------------------------------
| Id  | Operation          | Name          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |               | 50086 |   635K|       |   406   (3)| 00:00:05 |
|   1 |  HASH UNIQUE       |               | 50086 |   635K|  1976K|   406   (3)| 00:00:05 |
|   2 |   TABLE ACCESS FULL| T_DISTINCT_TB | 50086 |   635K|       |   161   (2)| 00:00:02 |
--------------------------------------------------------------------------------------------

Note
-----
- dynamic sampling used for this statement

统计信息
----------------------------------------------------------
4  recursive calls
0  db block gets
767  consistent gets
0  physical reads
0  redo size
732835  bytes sent via SQL*Net to client
37510  bytes received via SQL*Net from client
3377  SQL*Net roundtrips to/from client
0  sorts (memory)
0  sorts (disk)
50631  rows processed

SQL>
SQL> select distinct t.object_id from t_distinct_tb t ;

已选择50631行。

已用时间:  00: 00: 00.51

执行计划
----------------------------------------------------------
Plan hash value: 3170339755

--------------------------------------------------------------------------------------------
| Id  | Operation          | Name          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |               | 50086 |   635K|       |   406   (3)| 00:00:05 |
|   1 |  HASH UNIQUE       |               | 50086 |   635K|  1976K|   406   (3)| 00:00:05 |
|   2 |   TABLE ACCESS FULL| T_DISTINCT_TB | 50086 |   635K|       |   161   (2)| 00:00:02 |
--------------------------------------------------------------------------------------------

Note
-----
- dynamic sampling used for this statement

统计信息
----------------------------------------------------------
5  recursive calls
0  db block gets
768  consistent gets
0  physical reads
0  redo size
732835  bytes sent via SQL*Net to client
37510  bytes received via SQL*Net from client
3377  SQL*Net roundtrips to/from client
0  sorts (memory)
0  sorts (disk)
50631  rows processed
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: