本帖最后由 purple 于 2012-6-25 14:47 编辑
我写了一个自定义过滤sql(列出所有登陆用户参与(抄送或审批)某表单流程的记录):
var userid =getWebUser().getId();
var sql="SELECT * FROM TLK_FM_DISPATCH where id in(select doc.id from GALLOPSOA.T_DOCUMENT doc,GALLOPSOA.T_FLOW_INTERVENTION pen,GALLOPSOA.T_FLOWSTATERT fs,GALLOPSOA.T_NODERT node,GALLOPSOA.T_ACTORRT actor where doc.id = pen.id and doc.id =fs.docid and fs.id =node.flowstatert_id and node.id = actor.nodert_id and doc.issubdoc is null and doc.parent is null and doc.state is not null and doc.statelabel is not null and actor.actorid ='";
sql += userid;
sql += "' UNION select doc.id from GALLOPSOA.T_DOCUMENT doc,GALLOPSOA.T_ACTORHIS ahis,GALLOPSOA.T_RELATIONHIS rhis,GALLOPSOA.T_FLOW_INTERVENTION pen,GALLOPSOA.T_FLOWSTATERT fs where doc.id=rhis.docid and rhis.id = ahis.nodehis_id and doc.id = pen.id and doc.id =fs.docid and doc.issubdoc is null and doc.parent is null and doc.state is not null and doc.statelabel is not null and ahis.actorid='";
sql += userid ;
sql +="')";
sql;
但是系统具体在外面包含了3层无用的sql
11:24:49,260 INFO AbstractDocStaticTblDAO:1228 - MY SQL: SELECT * FROM (SELECT * FROM (SELECT * FROM TLK_FM_DISPATCH where id in(select doc.id from GALLOPSOA.T_DOCUMENT doc,GALLOPSOA.T_FLOW_INTERVENTION pen,GALLOPSOA.T_FLOWSTATERT fs,GALLOPSOA.T_NODERT node,GALLOPSOA.T_ACTORRT actor where doc.id = pen.id and doc.id =fs.docid and fs.id =node.flowstatert_id and node.id = actor.nodert_id and doc.issubdoc is null and doc.parent is null and doc.state is not null and doc.statelabel is not null and actor.actorid ='11e1-af7b-ac37c5d3-a3b2-4960a74ab202' UNION select doc.id from GALLOPSOA.T_DOCUMENT doc,GALLOPSOA.T_ACTORHIS ahis,GALLOPSOA.T_RELATIONHIS rhis,GALLOPSOA.T_FLOW_INTERVENTION pen,GALLOPSOA.T_FLOWSTATERT fs where doc.id=rhis.docid and rhis.id = ahis.nodehis_id and doc.id = pen.id and doc.id =fs.docid and doc.issubdoc is null and doc.parent is null and doc.state is not null and doc.statelabel is not null and ahis.actorid='11e1-af7b-ac37c5d3-a3b2-4960a74ab202')) table_orderby WHERE DOMAINID ='11e1-ae18-d04ada40-a3b2-4960a74ab202' ORDER BY table_orderby.ID ) AS TB LIMIT 0,15
这极大的降低了系统效率。 |