|
经过测试,貌似12c没有这问题........人家早改了....LZ用的哪个版本,我也学习下oracle怎么改进的。- SQL> set autot trace exp
- SQL> select b.b,
- 2 max(b.id) , /*很快*/
- 3 min(b.id) min_used
- 4 from big b,
- 5 (select distinct e.a
- 6 from e
- 7 where e.a like '1%') m
- 8 where b.a>=3
- 9 and b.a<=4
- 10 and b.b= m.a
- 11 group by b.b;
- 已用时间: 00: 00: 00.00
- 执行计划
- ----------------------------------------------------------
- Plan hash value: 1357920637
- ------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 13 | 182 | 631 (2)| 00:00:01 |
- | 1 | HASH GROUP BY | | 13 | 182 | 631 (2)| 00:00:01 |
- |* 2 | HASH JOIN RIGHT SEMI| | 128K| 1751K| 629 (2)| 00:00:01 |
- |* 3 | TABLE ACCESS FULL | E | 500 | 1500 | 7 (0)| 00:00:01 |
- |* 4 | TABLE ACCESS FULL | BIG | 285K| 3069K| 621 (2)| 00:00:01 |
- ------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 2 - access("B"."B"="E"."A")
- 3 - filter(TO_CHAR("E"."A") LIKE '1%')
- 4 - filter("B"."A">=3 AND "B"."A"<=4)
- Note
- -----
- - automatic DOP: Computed Degree of Parallelism is 1 because of parallel threshold
- SQL> select b.b,
- 2 max(b.id) - /*很慢*/
- 3 min(b.id) min_used
- 4 from big b,
- 5 (select distinct e.a
- 6 from e
- 7 where e.a like '1%') m
- 8 where b.a>=3
- 9 and b.a<=4
- 10 and b.b= m.a
- 11 group by b.b;
- 已用时间: 00: 00: 00.00
- 执行计划
- ----------------------------------------------------------
- Plan hash value: 1357920637
- ------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 13 | 182 | 631 (2)| 00:00:01 |
- | 1 | HASH GROUP BY | | 13 | 182 | 631 (2)| 00:00:01 |
- |* 2 | HASH JOIN RIGHT SEMI| | 128K| 1751K| 629 (2)| 00:00:01 |
- |* 3 | TABLE ACCESS FULL | E | 500 | 1500 | 7 (0)| 00:00:01 |
- |* 4 | TABLE ACCESS FULL | BIG | 285K| 3069K| 621 (2)| 00:00:01 |
- ------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 2 - access("B"."B"="E"."A")
- 3 - filter(TO_CHAR("E"."A") LIKE '1%')
- 4 - filter("B"."A">=3 AND "B"."A"<=4)
- Note
- -----
- - automatic DOP: Computed Degree of Parallelism is 1 because of parallel threshold
- SQL> set autot off
- SQL> select b.b,
- 2 max(b.id) - /*很慢*/
- 3 min(b.id) min_used
- 4 from big b,
- 5 (select distinct e.a
- 6 from e
- 7 where e.a like '1%') m
- 8 where b.a>=3
- 9 and b.a<=4
- 10 and b.b= m.a
- 11 group by b.b;
- B MIN_USED
- ---------- ----------
- 1 999804
- 11 999978
- 12 999804
- 10 999978
- 已用时间: 00: 00: 00.09
复制代码 |
|