============
Plan Table
============
------------------------------------------------------------------------+-----------------------------------+---------------+
| Id | Operation | Name | Rows | Bytes | Cost | Time | Pstart| Pstop |
------------------------------------------------------------------------+-----------------------------------+---------------+
| 0 | SELECT STATEMENT | | | | 608 | | | |
| 1 | SORT AGGREGATE | | 1 | 25 | | | | |
| 2 | TABLE ACCESS BY GLOBAL INDEX ROWID | FW_DHSQ | 1 | 25 | 4 | 00:00:01 | ROW LOCATION| ROW LOCATION|
| 3 | INDEX RANGE SCAN | IDX_FW_DHSQ_KHSQBS| 1 | | 3 | 00:00:01 | | |
| 4 | VIEW | | 3 | 477 | 608 | 00:00:08 | | |
| 5 | COUNT STOPKEY | | | | | | | |
| 6 | CONCATENATION | | | | | | | |
| 7 | FILTER | | | | | | | |
| 8 | FILTER | | | | | | | |
| 9 | NESTED LOOPS SEMI | | 1 | 193 | 247 | 00:00:03 | | |
| 10 | NESTED LOOPS | | 1 | 183 | 239 | 00:00:03 | | |
| 11 | NESTED LOOPS | | 1 | 168 | 238 | 00:00:03 | | |
| 12 | NESTED LOOPS | | 1 | 87 | 236 | 00:00:03 | | |
| 13 | PARTITION LIST ALL | | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 14 | TABLE ACCESS FULL | FW_DHSQ | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 15 | TABLE ACCESS FULL | FW_QXYWFJXX | 62 | 3844 | 118 | 00:00:02 | | |
| 16 | TABLE ACCESS BY GLOBAL INDEX ROWID | FW_KFGDXX | 1 | 81 | 2 | 00:00:01 | ROW LOCATION| ROW LOCATION|
| 17 | INDEX UNIQUE SCAN | PK_FW_KFGDXX | 1 | | 1 | 00:00:01 | | |
| 18 | INDEX UNIQUE SCAN | PK_FW_KHSQ | 1 | 15 | 1 | 00:00:01 | | |
| 19 | VIEW | VW_NSO_1 | 1 | 10 | 8 | 00:00:01 | | |
| 20 | FILTER | | | | | | | |
| 21 | CONNECT BY WITH FILTERING | | | | | | | |
| 22 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 1 | 20 | 2 | 00:00:01 | | |
| 23 | INDEX UNIQUE SCAN | PK_XT_ZZ | 1 | | 1 | 00:00:01 | | |
| 24 | NESTED LOOPS | | 3 | 96 | 6 | 00:00:01 | | |
| 25 | CONNECT BY PUMP | | | | | | | |
| 26 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 3 | 60 | 4 | 00:00:01 | | |
| 27 | INDEX RANGE SCAN | IDX_XT_ZZ_SJZZBM | 3 | | 1 | 00:00:01 | | |
| 28 | FILTER | | | | | | | |
| 29 | FILTER | | | | | | | |
| 30 | NESTED LOOPS SEMI | | 1 | 193 | 217 | 00:00:03 | | |
| 31 | NESTED LOOPS | | 1 | 183 | 209 | 00:00:03 | | |
| 32 | NESTED LOOPS | | 1 | 168 | 208 | 00:00:03 | | |
| 33 | NESTED LOOPS | | 1 | 87 | 206 | 00:00:03 | | |
| 34 | PARTITION LIST ALL | | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 35 | TABLE ACCESS FULL | FW_DHSQ | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 36 | TABLE ACCESS FULL | FW_QXYWFJXX | 62 | 3844 | 88 | 00:00:02 | | |
| 37 | TABLE ACCESS BY GLOBAL INDEX ROWID | FW_KFGDXX | 1 | 81 | 2 | 00:00:01 | ROW LOCATION| ROW LOCATION|
| 38 | INDEX UNIQUE SCAN | PK_FW_KFGDXX | 1 | | 1 | 00:00:01 | | |
| 39 | INDEX UNIQUE SCAN | PK_FW_KHSQ | 1 | 15 | 1 | 00:00:01 | | |
| 40 | VIEW | VW_NSO_1 | 1 | 10 | 8 | 00:00:01 | | |
| 41 | FILTER | | | | | | | |
| 42 | CONNECT BY WITH FILTERING | | | | | | | |
| 43 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 1 | 20 | 2 | 00:00:01 | | |
| 44 | INDEX UNIQUE SCAN | PK_XT_ZZ | 1 | | 1 | 00:00:01 | | |
| 45 | NESTED LOOPS | | 3 | 96 | 6 | 00:00:01 | | |
| 46 | CONNECT BY PUMP | | | | | | | |
| 47 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 3 | 60 | 4 | 00:00:01 | | |
| 48 | INDEX RANGE SCAN | IDX_XT_ZZ_SJZZBM | 3 | | 1 | 00:00:01 | | |
| 49 | FILTER | | | | | | | |
| 50 | FILTER | | | | | | | |
| 51 | NESTED LOOPS SEMI | | 1 | 193 | 143 | 00:00:02 | | |
| 52 | NESTED LOOPS | | 1 | 183 | 135 | 00:00:02 | | |
| 53 | NESTED LOOPS | | 1 | 168 | 134 | 00:00:02 | | |
| 54 | NESTED LOOPS | | 1 | 87 | 132 | 00:00:02 | | |
| 55 | PARTITION LIST ALL | | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 56 | TABLE ACCESS FULL | FW_DHSQ | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 57 | TABLE ACCESS FULL | FW_QXYWFJXX | 62 | 3844 | 14 | 00:00:01 | | |
| 58 | TABLE ACCESS BY GLOBAL INDEX ROWID | FW_KFGDXX | 1 | 81 | 2 | 00:00:01 | ROW LOCATION| ROW LOCATION|
| 59 | INDEX UNIQUE SCAN | PK_FW_KFGDXX | 1 | | 1 | 00:00:01 | | |
| 60 | INDEX UNIQUE SCAN | PK_FW_KHSQ | 1 | 15 | 1 | 00:00:01 | | |
| 61 | VIEW | VW_NSO_1 | 1 | 10 | 8 | 00:00:01 | | |
| 62 | FILTER | | | | | | | |
| 63 | CONNECT BY WITH FILTERING | | | | | | | |
| 64 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 1 | 20 | 2 | 00:00:01 | | |
| 65 | INDEX UNIQUE SCAN | PK_XT_ZZ | 1 | | 1 | 00:00:01 | | |
| 66 | NESTED LOOPS | | 3 | 96 | 6 | 00:00:01 | | |
| 67 | CONNECT BY PUMP | | | | | | | |
| 68 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 3 | 60 | 4 | 00:00:01 | | |
| 69 | INDEX RANGE SCAN | IDX_XT_ZZ_SJZZBM | 3 | | 1 | 00:00:01 | | |
------------------------------------------------------------------------+-----------------------------------+---------------+
Predicate Information:
----------------------
3 - access("D"."KHSQBS"=:B1)
4 - filter("ROWNUM_">0)
5 - filter(ROWNUM<=10)
7 - filter(ROWNUM<=10)
8 - filter(TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss')<=SYSDATE@!)
14 - filter("D"."GJSJ" IS NOT NULL)
15 - filter(("A"."YDQY"='3' AND "A"."DDXCSJ" IS NOT NULL AND ("A"."DDXCSJ"-"D"."GJSJ")*24*60>120))
16 - filter(("B"."YWLBDM"='01' AND "B"."GZDZTDM"='3' AND "B"."ZFBZ"='0' AND "B"."GDSJ">=TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "B"."GDSJ"<=SYSDATE@!))
17 - access("A"."KFGZDBS"="B"."KFGZDBS")
18 - access("C"."KHSQBS"="D"."KHSQBS")
18 - filter("B"."KHSQBS"="C"."KHSQBS")
19 - filter("B"."SLZZBM"="ZZBM")
20 - filter("Z"."ZTBZ"='1')
21 - access("Z"."SJZZBM"=PRIOR NULL)
23 - access("Z"."ZZBM"='0609')
27 - access("Z"."SJZZBM"="connect$_by$_pump$_009"."PRIOR Z.ZZBM")
28 - filter(ROWNUM<=10)
29 - filter(TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss')<=SYSDATE@!)
35 - filter("D"."GJSJ" IS NOT NULL)
36 - filter(("A"."YDQY"='2' AND "A"."DDXCSJ" IS NOT NULL AND ("A"."DDXCSJ"-"D"."GJSJ")*24*60>90 AND (LNNVL("A"."YDQY"='3') OR LNNVL(("A"."DDXCSJ"-"D"."GJSJ")*24*60>120))))
37 - filter(("B"."YWLBDM"='01' AND "B"."GZDZTDM"='3' AND "B"."ZFBZ"='0' AND "B"."GDSJ">=TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "B"."GDSJ"<=SYSDATE@!))
38 - access("A"."KFGZDBS"="B"."KFGZDBS")
39 - access("C"."KHSQBS"="D"."KHSQBS")
39 - filter("B"."KHSQBS"="C"."KHSQBS")
40 - filter("B"."SLZZBM"="ZZBM")
41 - filter("Z"."ZTBZ"='1')
42 - access("Z"."SJZZBM"=PRIOR NULL)
44 - access("Z"."ZZBM"='0609')
48 - access("Z"."SJZZBM"="connect$_by$_pump$_009"."PRIOR Z.ZZBM")
49 - filter(ROWNUM<=10)
50 - filter(TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss')<=SYSDATE@!)
56 - filter("D"."GJSJ" IS NOT NULL)
57 - filter(("A"."DDXCSJ" IS NOT NULL AND "A"."YDQY"='1' AND ("A"."DDXCSJ"-"D"."GJSJ")*24*60>45 AND (LNNVL("A"."YDQY"='2') OR LNNVL(("A"."DDXCSJ"-"D"."GJSJ")*24*60>90)) AND (LNNVL("A"."YDQY"='3') OR LNNVL(("A"."DDXCSJ"-"D"."GJSJ")*24*60>120))))
58 - filter(("B"."YWLBDM"='01' AND "B"."GZDZTDM"='3' AND "B"."ZFBZ"='0' AND "B"."GDSJ">=TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "B"."GDSJ"<=SYSDATE@!))
59 - access("A"."KFGZDBS"="B"."KFGZDBS")
60 - access("C"."KHSQBS"="D"."KHSQBS")
60 - filter("B"."KHSQBS"="C"."KHSQBS")
61 - filter("B"."SLZZBM"="ZZBM")
62 - filter("Z"."ZTBZ"='1')
63 - access("Z"."SJZZBM"=PRIOR NULL)
65 - access("Z"."ZZBM"='0609')
69 - access("Z"."SJZZBM"="connect$_by$_pump$_009"."PRIOR Z.ZZBM")
分析执行计划很容易发现CBO对该sql进行了or展开,且每一个or的分支执行计划都几乎一样,所以只需分析一个or的分支即可。
| 9 | NESTED LOOPS SEMI | | 1 | 193 | 247 | 00:00:03 | | |
| 10 | NESTED LOOPS | | 1 | 183 | 239 | 00:00:03 | | |
| 11 | NESTED LOOPS | | 1 | 168 | 238 | 00:00:03 | | |
| 12 | NESTED LOOPS | | 1 | 87 | 236 | 00:00:03 | | |
| 13 | PARTITION LIST ALL | | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 14 | TABLE ACCESS FULL | FW_DHSQ | 1 | 25 | 118 | 00:00:02 | 1 | 12 |
| 15 | TABLE ACCESS FULL | FW_QXYWFJXX | 62 | 3844 | 118 | 00:00:02 | | |
| 16 | TABLE ACCESS BY GLOBAL INDEX ROWID | FW_KFGDXX | 1 | 81 | 2 | 00:00:01 | ROW LOCATION| ROW LOCATION|
| 17 | INDEX UNIQUE SCAN | PK_FW_KFGDXX | 1 | | 1 | 00:00:01 | | |
| 18 | INDEX UNIQUE SCAN | PK_FW_KHSQ | 1 | 15 | 1 | 00:00:01 | | |
| 19 | VIEW | VW_NSO_1 | 1 | 10 | 8 | 00:00:01 | | |
| 20 | FILTER | | | | | | | |
| 21 | CONNECT BY WITH FILTERING | | | | | | | |
| 22 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 1 | 20 | 2 | 00:00:01 | | |
| 23 | INDEX UNIQUE SCAN | PK_XT_ZZ | 1 | | 1 | 00:00:01 | | |
| 24 | NESTED LOOPS | | 3 | 96 | 6 | 00:00:01 | | |
| 25 | CONNECT BY PUMP | | | | | | | |
| 26 | TABLE ACCESS BY INDEX ROWID | XT_ZZ | 3 | 60 | 4 | 00:00:01 | | |
| 27 | INDEX RANGE SCAN | IDX_XT_ZZ_SJZZBM | 3 | | 1 | 00:00:01 | | |
谓词信息:
14 - filter("D"."GJSJ" IS NOT NULL)
15 - filter(("A"."YDQY"='3' AND "A"."DDXCSJ" IS NOT NULL AND ("A"."DDXCSJ"-"D"."GJSJ")*24*60>120))
16 - filter(("B"."YWLBDM"='01' AND "B"."GZDZTDM"='3' AND "B"."ZFBZ"='0' AND "B"."GDSJ">=TO_DATE(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "B"."GDSJ"<=SYSDATE@!))
先全分区扫描FW_DHSQ表,之后与FW_QXYWFJXX表的连接,连接方式居然是NL(因为连接条件不是等值连接,所以不能进行hash join),且FW_QXYWFJXX表的扫描方式是也是全表扫描,也就是说全表扫描FW_DHSQ表经过谓词过滤后的返回多少记录数就会全表扫描FW_QXYWFJXX多少次。这里初步的判断是FW_DHSQ是一个分区表,但是CBO对FW_DHSQ全分区扫描再经过filter("D"."GJSJ" IS NOT NULL)之后的CARD居然只有1?感觉不太可能。非常可疑。
If a First K Rows mode query gets a suboptimal query execution plan with OR expansion and full table scans, with low estimated cardinalities and cost then you may have encountered this bug.
Product (Component) Oracle Server (Rdbms) Range of versions believed to be affected (Not specified) Versions confirmed as being affected
- 11.2.0.3
Platforms affected Generic (all / most platforms affected)
The fix for 15996520 is first included in
- 12.2 (Future Release)
- 12.1.0.2 (Server Patch Set)
- 11.2.0.4 (Server Patch Set)
- 11.2.0.3 Patch 16 on Windows Platforms
该数据库正好是11.2.0.3
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31347199/viewspace-2118035/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31347199/viewspace-2118035/