- 最后登录
- 2014-1-23
- 在线时间
- 5 小时
- 威望
- 8
- 金钱
- 79
- 注册时间
- 2012-4-23
- 阅读权限
- 10
- 帖子
- 11
- 精华
- 0
- 积分
- 8
- UID
- 376
|
1#
发表于 2014-1-17 10:13:07
|
查看: 4324 |
回复: 9
SQL语句如下:
SELECT dtl.corp_org_id org_id,
sub1.org_name_c branch_name,
SUM (
CASE
WHEN dtl.account_book_id = 0 THEN dtl.total_charge
ELSE 0
END)
/ 100
一次性退费
FROM cs.cs_app app
INNER JOIN cs.cs_app appr ON app.relat_app_id = appr.app_id
INNER JOIN rep.kd_app_bill_month dtl ON dtl.app_id = app.app_id
LEFT JOIN rep.kd_subscriber_connect_month sub1
ON sub1.subscriber_id = dtl.subscriber_id
WHERE app.app_action IN ('CS_CANCEL', 'CS_REVERSE')
AND dtl.busy_type = 2
AND appr.app_time < DATE '2013-12-01'
AND app.app_time BETWEEN DATE '2013-12-01' AND DATE '2013-12-31' + 1
GROUP BY dtl.corp_org_id, sub1.org_name_c;
库A的执行计划(慢,几分钟):
Plan
SELECT STATEMENT ALL_ROWSCost: 63,717 Bytes: 8,463 Cardinality: 91
11 HASH GROUP BY Cost: 63,717 Bytes: 8,463 Cardinality: 91
10 HASH JOIN OUTER Cost: 63,716 Bytes: 101,463 Cardinality: 1,091
8 TABLE ACCESS BY INDEX ROWID TABLE REP.KD_APP_BILL_MONTH Cost: 4 Bytes: 56 Cardinality: 2
7 NESTED LOOPS Cost: 62,093 Bytes: 86,189 Cardinality: 1,091
5 NESTED LOOPS Cost: 60,922 Bytes: 29,376 Cardinality: 576
2 TABLE ACCESS BY INDEX ROWID TABLE CS.CS_APP Cost: 59,769 Bytes: 20,736 Cardinality: 576
1 INDEX RANGE SCAN INDEX CS.IDX_CS_APP_APP_TIME Cost: 206 Cardinality: 76,566
4 TABLE ACCESS BY INDEX ROWID TABLE CS.CS_APP Cost: 2 Bytes: 15 Cardinality: 1
3 INDEX UNIQUE SCAN INDEX (UNIQUE) CS.IDX_PK_CS_APP Cost: 1 Cardinality: 1
6 INDEX RANGE SCAN INDEX REP.IDX_KD_APP_BILL_MONTH_APPID Cost: 2 Cardinality: 2
9 TABLE ACCESS FULL TABLE REP.KD_SUBSCRIBER_CONNECT_MONTH Cost: 1,603 Bytes: 21,743,960 Cardinality: 1,553,140
库B的执行计划(快,十几秒):
Plan
SELECT STATEMENT ALL_ROWSCost: 58,408 Bytes: 7,440 Cardinality: 80
11 HASH GROUP BY Cost: 58,408 Bytes: 7,440 Cardinality: 80
10 HASH JOIN OUTER Cost: 58,407 Bytes: 74,493 Cardinality: 801
8 TABLE ACCESS BY INDEX ROWID TABLE REP.KD_APP_BILL_MONTH Cost: 3 Bytes: 28 Cardinality: 1
7 NESTED LOOPS Cost: 56,799 Bytes: 63,279 Cardinality: 801
5 NESTED LOOPS Cost: 55,626 Bytes: 29,580 Cardinality: 580
2 TABLE ACCESS BY INDEX ROWID TABLE CS.CS_APP Cost: 54,464 Bytes: 20,880 Cardinality: 580
1 INDEX RANGE SCAN INDEX CS.IDX_CS_APP_APP_TIME Cost: 216 Cardinality: 76,569
4 TABLE ACCESS BY INDEX ROWID TABLE CS.CS_APP Cost: 2 Bytes: 15 Cardinality: 1
3 INDEX UNIQUE SCAN INDEX (UNIQUE) CS.IDX_PK_CS_APP Cost: 1 Cardinality: 1
6 INDEX RANGE SCAN INDEX REP.IDX_KD_APP_BILL_MONTH_APPID Cost: 2 Cardinality: 1
9 TABLE ACCESS FULL TABLE REP.KD_SUBSCRIBER_CONNECT_MONTH Cost: 1,588 Bytes: 21,765,408 Cardinality: 1,554,672
两台机器硬件配置完全相同,
请刘大帮忙分析下,是否还需要提供其它信息? |
|