[20201110]FBI Bug reprise.txt --//2015年的老帖子,链接:https://jonathanlewis.wordpress.com/2015/01/12/fbi-bug-reprise/ --//好奇测试看看。 1.建立例子: SCOTT@book> @ ver1 PORT_STRING VERSION BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production rem rem Script: descending_bug_04.sql rem Author: Jonathan Lewis rem Dated: Jan 2015 rem create table t1 nologging as with generator as ( select --+ materialize rownum id from dual connect by level <= 1e4 ) select rownum id, cast(dbms_random.string('U',2) as char(2)) c1, cast(dbms_random.string('U',2) as char(2)) c2, cast(dbms_random.string('U',2) as char(2)) c3, cast(dbms_random.string('U',2) as char(2)) c4, rpad('x',100) padding from generator v1, generator v2 where rownum <= 1e5 -- > comment to avoid wordpress formatting issue ; begin dbms_stats.gather_table_stats( ownname => user, tabname =>'T1', method_opt => 'for all columns size 1' ); end; / create index t1_iasc on t1(c1, c2, c3, c4) nologging; create index t1_idesc on t1(c1, c2 desc, c3, c4) nologging; 2.测试: SCOTT@book> alter session set statistics_level = all; Session altered. $ cat aaa.sql select * from t1 where (C1 = 'DE' and C2 > 'AB') or (C1 = 'DE' and C2 >= 'AB' and C3 > 'AA' ) or (C1 = 'DE' and C2 >= 'AB' and C3 >= 'AA' and C4 >= 'BB') order by C1, C2, C3, C4 ; Plan hash value: 263105257 -------------------------------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | 24 (100)| | 144 |00:00:00.01 | 147 | | | | | 1 | SORT ORDER BY | | 1 | 148 | 17464 | 24 (5)| 00:00:01 | 144 |00:00:00.01 | 147 | 46080 | 46080 |40960 (0)| | 2 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 148 | 17464 | 23 (0)| 00:00:01 | 144 |00:00:00.01 | 147 | | | | |* 3 | INDEX RANGE SCAN | T1_IDESC | 1 | 21 | | 2 (0)| 00:00:01 | 144 |00:00:00.01 | 3 | | | | -------------------------------------------------------------------------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 2 - SEL$1 / T1@SEL$1 3 - SEL$1 / T1@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("C1"='DE') filter(((SYS_OP_UNDESCEND("T1"."SYS_NC00007$")>'AB' AND "T1"."SYS_NC00007$"<SYS_OP_DESCEND('AB')) OR ("C3">'AA' AND SYS_OP_UNDESCEND("T1"."SYS_NC00007$")>='AB' AND "T1"."SYS_NC00007$"<=SYS_OP_DESCEND('AB')) OR ("C4">='BB' AND SYS_OP_UNDESCEND("T1"."SYS_NC00007$")>='AB' AND "C3">='AA' AND "T1"."SYS_NC00007$"<=SYS_OP_DESCEND('AB')))) --//嗯,我的测试的执行计划与原链接不一样,使用的是T1_IDESC降序索引。cost与链接一致。难道真实的情况就是使用T1_IDESC索引吗? SCOTT@book> alter index t1_idesc invisible; Index altered. --//重复执行: Plan hash value: 2707920069 --------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | --------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | 150 (100)| | 144 |00:00:00.01 | 148 | | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 148 | 17464 | 150 (0)| 00:00:02 | 144 |00:00:00.01 | 148 | |* 2 | INDEX RANGE SCAN | T1_IASC | 1 | 148 | | 2 (0)| 00:00:01 | 144 |00:00:00.01 | 4 | --------------------------------------------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / T1@SEL$1 2 - SEL$1 / T1@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("C1"='DE') filter((("C2">'AB' AND SYS_OP_DESCEND("C2")<SYS_OP_DESCEND('AB')) OR ("C3">'AA' AND "C2">='AB' AND SYS_OP_DESCEND("C2")<=SYS_OP_DESCEND('AB')) OR ("C4">='BB' AND "C2">='AB' AND "C3">='AA' AND SYS_OP_DESCEND("C2")<=SYS_OP_DESCEND('AB')))) --//仔细看过滤条件很奇怪,会使用SYS_OP_DESCEND函数。 --//删除索引看看。 SCOTT@book> drop index t1_idesc; Index dropped. --//重复执行 Plan hash value: 2707920069 --------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | --------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | 150 (100)| | 144 |00:00:00.01 | 148 | | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 148 | 17464 | 150 (0)| 00:00:02 | 144 |00:00:00.01 | 148 | |* 2 | INDEX RANGE SCAN | T1_IASC | 1 | 148 | | 2 (0)| 00:00:01 | 144 |00:00:00.01 | 4 | --------------------------------------------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / T1@SEL$1 2 - SEL$1 / T1@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("C1"='DE') filter(("C2">'AB' OR ("C3">'AA' AND "C2">='AB') OR ("C4">='BB' AND "C2">='AB' AND "C3">='AA'))) --//奇怪现在就不出现使用SYS_OP_DESCEND函数的情况。真心搞不懂oracle优化器如何工作的。 3.继续: SCOTT@book> create index t1_idesc on t1(c1, c2 desc, c3, c4) nologging; Index created. $ cat aaa.sql select /*+ first_rows */ * from t1 where (C1 = 'DE' and C2 > 'AB') or (C1 = 'DE' and C2 >= 'AB' and C3 > 'AA' ) or (C1 = 'DE' and C2 >= 'AB' and C3 >= 'AA' and C4 >= 'BB') order by C1, C2, C3, C4 ; Plan hash value: 2707920069 --------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | --------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | 150 (100)| | 144 |00:00:00.01 | 148 | | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 148 | 17464 | 150 (0)| 00:00:02 | 144 |00:00:00.01 | 148 | |* 2 | INDEX RANGE SCAN | T1_IASC | 1 | 148 | | 2 (0)| 00:00:01 | 144 |00:00:00.01 | 4 | --------------------------------------------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / T1@SEL$1 2 - SEL$1 / T1@SEL$1 Outline Data ------------- /*+ BEGIN_OUTLINE_DATA IGNORE_OPTIM_EMBEDDED_HINTS OPTIMIZER_FEATURES_ENABLE('11.2.0.4') DB_VERSION('11.2.0.4') FIRST_ROWS OUTLINE_LEAF(@"SEL$1") INDEX_RS_ASC(@"SEL$1" "T1"@"SEL$1" ("T1"."C1" "T1"."C2" "T1"."C3" "T1"."C4")) END_OUTLINE_DATA */ Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("C1"='DE') filter((("C2">'AB' AND SYS_OP_DESCEND("C2")<SYS_OP_DESCEND('AB')) OR ("C3">'AA' AND "C2">='AB' AND SYS_OP_DESCEND("C2")<=SYS_OP_DESCEND('AB')) OR ("C4">='BB' AND "C2">='AB' AND "C3">='AA' AND SYS_OP_DESCEND("C2")<=SYS_OP_DESCEND('AB')))) --//执行计划并没有出现CONCATENATION的情况。放弃太复杂了。
[20201110]FBI Bug reprise.txt
来源:这里教程网
时间:2026-03-03 16:16:20
作者:
编辑推荐:
- SQL Server数据库mdf文件中了勒索病毒*.mdf.[helpbackup@email.tg].Devos03-03
- [20201110]FBI Bug reprise.txt03-03
- 将目前已有的AM即时通用户全部开通Mobox企业网盘for oracle03-03
- [20201111]PL SQL function 和一致性.txt03-03
- G006-ORACLE-INS-SIFS-01 ORACLE 19C SIFS Ins ON RHEL 8.203-03
- G008-ORACLE-DG ORACLE 19C Active Data Guard DML Redirection03-03
- 查看oracle数据库中,哪些表的字段是null值比较多03-03
- Oracle GoldenGate Veridata 12.2.1.4安装配置使用全手册03-03
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- SQL Server数据库mdf文件中了勒索病毒*.mdf.[helpbackup@email.tg].Devos
- G006-ORACLE-INS-SIFS-01 ORACLE 19C SIFS Ins ON RHEL 8.2
- G008-ORACLE-DG ORACLE 19C Active Data Guard DML Redirection
- 查看oracle数据库中,哪些表的字段是null值比较多
查看oracle数据库中,哪些表的字段是null值比较多
26-03-03 - Oracle数据库服务器dbf文件中了勒索病毒,扩展名被篡改为.CC7H
Oracle数据库服务器dbf文件中了勒索病毒,扩展名被篡改为.CC7H
26-03-03 - 数据库范式
数据库范式
26-03-03 - 沙龙回顾丨开发者掌握这些背后的技术路径,可助力企业智能化升级
沙龙回顾丨开发者掌握这些背后的技术路径,可助力企业智能化升级
26-03-03 - Oracle的awr报告分析
Oracle的awr报告分析
26-03-03 - DDD 在京东 DevOps 项目协作领域的落地实战
DDD 在京东 DevOps 项目协作领域的落地实战
26-03-03 - Oracle DG同步失败故障处理(二)
Oracle DG同步失败故障处理(二)
26-03-03
