explain select count(0) from ( select distinct RES.ID_, RES.NAME_, ART.ASSIGNEE_, A0.TEXT_ as 'status', RES.START_TIME_, RES.END_TIME_, RES.BUSINESS_KEY_ from ACT_HI_PROCINST RES left outer join ACT_RE_PROCDEF DEF on RES.PROC_DEF_ID_ = DEF.ID_ inner join ACT_HI_VARINST A0 on RES.PROC_INST_ID_ = A0.PROC_INST_ID_ and a0.TASK_ID_ is null and A0.NAME_ = '@global_process_status' and A0.VAR_TYPE_ = 'integer' inner join ACT_HI_VARINST A1 on RES.PROC_INST_ID_ = A0.PROC_INST_ID_ and a0.TASK_ID_ is null and A1.NAME_ = '@process_form_structure' and A1.VAR_TYPE_ = 'string' left join ACT_RU_TASK ART on RES.ID_ = art.PROC_INST_ID_ where (exists ( select LINK.USER_ID_ from ACT_HI_IDENTITYLINK LINK where USER_ID_ in ("1") and LINK.PROC_INST_ID_ = RES.ID_))) table_count 怎么加索引
时间: 2023-07-27 09:07:00 浏览: 152
PID_EASY_EXPLAIN.rar_easy _pid
首先需要确认哪些列在查询中使用频繁,可以使用 EXPLAIN 分析查询语句,找到慢查询的具体原因。
在这个查询中,以下列被使用了:
- ACT_HI_PROCINST.START_TIME_
- ACT_HI_PROCINST.END_TIME_
- ACT_HI_PROCINST.BUSINESS_KEY_
- ACT_RU_TASK.ASSIGNEE_
因此,可以考虑在这些列上创建索引来优化查询性能。具体如下:
```
CREATE INDEX idx_act_hi_procinst_start_end_time ON ACT_HI_PROCINST (START_TIME_, END_TIME_);
CREATE INDEX idx_act_hi_procinst_business_key ON ACT_HI_PROCINST (BUSINESS_KEY_);
CREATE INDEX idx_act_ru_task_assignee ON ACT_RU_TASK (ASSIGNEE_);
```
注意,索引并不是万能的,需要根据实际情况进行优化和调整。
阅读全文