- 最后登录
- 2016-6-27
- 在线时间
- 134 小时
- 威望
- 351
- 金钱
- 2586
- 注册时间
- 2012-3-16
- 阅读权限
- 60
- 帖子
- 188
- 精华
- 6
- 积分
- 351
- UID
- 309
|
2#
发表于 2012-5-9 14:21:02
根据执行计划,主要是这个视图v_arap_detail 性能比较差,视图的代码和执行计划如下:
SELECT DISTINCT zb.vouchid, fb.fb_oid, fb.dfbbje AS jfbbje,
fb.dfybje AS jfybje, fb.jfbbje AS dfbbje,
fb.jfybje AS dfybje, zb.djbh, zb.djdl, djlx.djlxbm,
djlx.djlxmc, zb.djkjnd, zb.djkjqj, zb.shrq djrq,
SUBSTR (zb.djrq, 0, 4) iyear, SUBSTR (zb.djrq, 6,
2) imonth, zb.djzt,
zb.dwbm, fb.accountid, fb.szxmid,
CASE
WHEN SUBSTR (subj.costcode, 0, 2) = '07'
THEN '0403002'
WHEN SUBSTR (subj.costcode, 0, 2) = '08'
THEN '0403002'
WHEN SUBSTR (subj.costcode, 0, 2) = '20'
THEN '0403001'
ELSE costcode
END costcode,
subj.costname, accid.accidcode, accid.beginbmny,
accid.beginymny, accidname, defdoc1.pk_defdoc pk_defdoc1,
defdoc1.doccode acode, defdoc1.docname aname,
defdoc4.pk_defdoc pk_defdoc4, defdoc4.doccode projcode,
defdoc4.docname projname, defdoc20.pk_defdoc pk_defdoc20,
defdoc20.doccode areacode, defdoc20.docname areaname,
corpdef.pk_defdoc pk_corpdefdoc,
corpdef.doccode corpareacode, corpdef.docname corpareaname
FROM arap_djzb zb INNER JOIN arap_djfb fb
ON zb.vouchid = fb.vouchid
LEFT JOIN arap_djlx djlx
ON zb.djdl = djlx.djdl
AND zb.dwbm = djlx.dwbm
AND zb.djlxbm = djlx.djlxbm
LEFT JOIN bd_costsubj subj ON subj.pk_costsubj = fb.szxmid
LEFT JOIN bd_accid accid ON accid.pk_accid = fb.accountid
LEFT JOIN bd_defdoc defdoc1 ON defdoc1.pk_defdoc =
accid.def1
LEFT JOIN bd_defdoc defdoc20
ON defdoc20.pk_defdoc = accid.def20
LEFT JOIN bd_corp corp ON corp.pk_corp = zb.dwbm
LEFT JOIN bd_defdoc corpdef ON corpdef.pk_defdoc =
corp.def1
LEFT JOIN bd_defdoc defdoc4 ON defdoc4.pk_defdoc =
accid.def2
WHERE NVL (zb.dr, 0) = 0
AND NVL (fb.dr, 0) = 0
AND zb.djzt = 2
AND zb.djdl IN ('fk', 'sk', 'fj', 'sj', 'hj')
AND qcbz = 'N';
Plan
SELECT STATEMENT ALL_ROWSCost: 107,548 Bytes: 416,026,342 Cardinality: 578,618
24 HASH UNIQUE Cost: 107,548 Bytes: 416,026,342 Cardinality: 578,618
23 HASH JOIN RIGHT OUTER Cost: 19,844 Bytes: 416,026,342 Cardinality: 578,618
1 TABLE ACCESS FULL TABLE NC152.ARAP_DJLX Cost: 6 Bytes: 3,496 Cardinality: 184
22 NESTED LOOPS OUTER Cost: 19,831 Bytes: 405,032,600 Cardinality: 578,618
19 HASH JOIN RIGHT OUTER Cost: 19,822 Bytes: 366,843,812 Cardinality: 578,618
2 TABLE ACCESS FULL TABLE NC152.BD_CORP Cost: 11 Bytes: 3,522 Cardinality: 587
18 HASH JOIN RIGHT OUTER Cost: 19,804 Bytes: 363,372,104 Cardinality: 578,618
3 TABLE ACCESS FULL TABLE NC152.BD_COSTSUBJ Cost: 13 Bytes: 311,256 Cardinality: 2,358
17 NESTED LOOPS OUTER Cost: 19,783 Bytes: 286,994,528 Cardinality: 578,618
14 NESTED LOOPS OUTER Cost: 19,731 Bytes: 248,805,740 Cardinality: 578,618
11 NESTED LOOPS OUTER Cost: 19,678 Bytes: 210,616,952 Cardinality: 578,618
8 HASH JOIN RIGHT OUTER Cost: 19,626 Bytes: 172,428,164 Cardinality: 578,618
4 TABLE ACCESS FULL TABLE NC152.BD_ACCID Cost: 22 Bytes: 143,585 Cardinality: 2,209
7 HASH JOIN Cost: 19,596 Bytes: 134,817,994 Cardinality: 578,618
5 TABLE ACCESS FULL TABLE NC152.ARAP_DJZB Cost: 2,817 Bytes: 21,143,000 Cardinality: 211,430
6 TABLE ACCESS FULL TABLE NC152.ARAP_DJFB Cost: 11,672 Bytes: 76,956,460 Cardinality: 578,620
10 TABLE ACCESS BY INDEX ROWID TABLE NC152.BD_DEFDOC Cost: 1 Bytes: 66 Cardinality: 1
9 INDEX UNIQUE SCAN INDEX (UNIQUE) NC152.PK_BD_DEFDOC Cost: 1 Cardinality: 1
13 TABLE ACCESS BY INDEX ROWID TABLE NC152.BD_DEFDOC Cost: 1 Bytes: 66 Cardinality: 1
12 INDEX UNIQUE SCAN INDEX (UNIQUE) NC152.PK_BD_DEFDOC Cost: 1 Cardinality: 1
16 TABLE ACCESS BY INDEX ROWID TABLE NC152.BD_DEFDOC Cost: 1 Bytes: 66 Cardinality: 1
15 INDEX UNIQUE SCAN INDEX (UNIQUE) NC152.PK_BD_DEFDOC Cost: 1 Cardinality: 1
21 TABLE ACCESS BY INDEX ROWID TABLE NC152.BD_DEFDOC Cost: 1 Bytes: 66 Cardinality: 1
20 INDEX UNIQUE SCAN INDEX (UNIQUE) NC152.PK_BD_DEFDOC Cost: 1 Cardinality: 1
PS:相关的表都做了分析 |
|