问题现象
通过SPR日志发现 打开节点-后台任务日志节点sql调用严重。
通过nmc查看,后台线程耗时20s ,基本都卡在sql层面
一直在执行如下sql
select
l.pk_workingtasklog
from
pub_workingtasklog l
inner join
pub_alertregistry r
on l.pkregistry = r.pk_alertregistry
where
l.tasktype in (
1 , 2
)
and r.groupid in (
'0001A210000000001JRQ' , 'GLOBLE00000000000000'
)
order by
l.endtime desc
看下执行计划
1 Plan hash value: 2019149088
2
3 -------------------------------------------------------------------------------------------------------
4 | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
5 -------------------------------------------------------------------------------------------------------
6 | 0 | SELECT STATEMENT | | 789K| 80M| | 34015 (1)| 00:06:49 |
7 | 1 | SORT ORDER BY | | 789K| 80M| 90M| 34015 (1)| 00:06:49 |
8 |* 2 | HASH JOIN | | 789K| 80M| | 14873 (1)| 00:02:59 |
9 |* 3 | VIEW | index$_join$_002 | 100 | 4200 | | 6 (17)| 00:00:01 |
10 |* 4 | HASH JOIN | | | | | | |
11 | 5 | INLIST ITERATOR | | | | | | |
12 |* 6 | INDEX RANGE SCAN | I_PUB_ALTRGS_2 | 100 | 4200 | | 2 (0)| 00:00:01 |
13 | 7 | INDEX FAST FULL SCAN| PK_PUB_ALERTREGIST | 100 | 4200 | | 4 (0)| 00:00:01 |
14 |* 8 | TABLE ACCESS FULL | PUB_WORKINGTASKLOG | 1254K| 77M| | 14858 (1)| 00:02:59 |
15 -------------------------------------------------------------------------------------------------------
16
17 Predicate Information (identified by operation id):
18 ---------------------------------------------------
19
20 2 - access("L"."PKREGISTRY"="R"."PK_ALERTREGISTRY")
21 3 - filter("R"."GROUPID"='0001A210000000001JRQ' OR "R"."GROUPID"='GLOBLE00000000000000')
22 4 - access(ROWID=ROWID)
23 6 - access("R"."GROUPID"='0001A210000000001JRQ' OR "R"."GROUPID"='GLOBLE00000000000000')
24 8 - filter("L"."TASKTYPE"=1 OR "L"."TASKTYPE"=2)
问题分析
走了全表扫描解决方案
create index i_PUB_WORKINGTASKLOG _1 on PUB_WORKINGTASKLOG (pkregistry,tasktype) tablespace nnc_index01 nologging parallel 4;
create index i_pub_alertregistry_1 on pub_alertregistry(pk_alertregistry,groupid) tablespace nnc_index01 nologging parallel 4;