請(qǐng)高手解決... sql 優(yōu)化問題。
?
SELECT formResourceName,t.id, p.workflow_name workflowName,p.workflow_type workflowType,p.process_definition_id processDefinitionId
,i.process_instance_id processInstanceId,i.create_time processInstanceCreateTime,i.orderId,i.author,i.author_name authorName,i.flag processInstanceFlag
,t.task_id taskId,t.handle_time handleTime,
(case when handle_result='0' then '不通過' when handle_result='1' then '通過' when handle_result='2' then
'創(chuàng)建' when handle_result='3' then '撤回' else '通過' end) as handleResult,
handle_comments handleComment ,t.handler ,t.handler_name handlerName
from workflow_trans t
left join workflow_instance i on t.process_instance_id=i.process_instance_id
left join workflow_template p on i.process_definition_id=p.process_definition_id
WHERE i.status<>'DELETE'
AND
t.id IN
(SELECT max(id) FROM workflow_trans GROUP BY process_instance_id,formResourceName) -- 這里排除重復(fù)數(shù)據(jù)
?
用id in? 數(shù)據(jù)很慢。 如何優(yōu)化?
sql 優(yōu)化
素胚勾勒不出你
2018-12-07 10:54:33