Browse Source

sql优化提高查询效率

feature/dangjian
sunyuchao 4 years ago
parent
commit
f32d7ff9eb
  1. 14
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml

14
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml

@ -2222,8 +2222,14 @@
epdc_item a
LEFT JOIN (
select h.id,h.item_id,h.created_time,h.state
from epdc_item_handle_process h
where h.del_flag = '0'
<!-- 此处关联主表增加主表查询条件为了提升查询效率 -->
from epdc_item ei
inner join epdc_item_handle_process h on ei.id = h.item_id
where ei.is_people = '1'
and ei.del_flag = '0'
AND ei.event_id is NULL
AND ei.issue_id is NULL
and h.del_flag = '0'
and h.created_time = (
select max(created_time)
from epdc_item_handle_process
@ -2233,8 +2239,8 @@
GROUP BY h.item_id
)b ON a.id = b.item_id
WHERE
a.del_flag = '0'
AND a.is_people = '1'
a.is_people = '1'
AND a.del_flag = '0'
AND a.event_id is NULL
AND a.issue_id is NULL
<if test="deptId != null and deptId != ''">

Loading…
Cancel
Save