我是新来的。我有以下代码,其中内部和 SSID 包执行时间太长。
该声明旨在找到最好的律师(考虑到一些生产力和能力因素)并将其 ID 写入临时表......但它需要太长时间。
有什么建议么???我什至尝试过...禁用触发器
ALTER TABLE TB_TEMPLawyer DISABLE TRIGGER ALL
ALTER TABLE TB_LAWYERS DISABLE TRIGGER ALL
ALTER TABLE TB_PCRelation DISABLE TRIGGER ALL
ALTER TABLE TB_CASES DISABLE TRIGGER ALL
ALTER TABLE TB_TEMPaccount DISABLE TRIGGER ALL
INSERT INTO TB_TEMPLawyer
(LawyerAutoIDTEMP)
SELECT TOP (1) TB_LAWYERS.LawyerAutoID
FROM TB_PCRelation INNER JOIN
TB_CASES ON TB_PCRelation.PostalCode = TB_CASES.CustomerPostalCode INNER JOIN
TB_LAWYERS ON TB_PCRelation.PCLawyerID = TB_LAWYERS.LawyerID INNER JOIN
TB_TEMPaccount ON TB_CASES.Account = TB_TEMPaccount.TempAccount
WHERE (TB_CASES.LASYstatus = '2') AND (TB_CASES.LawyerID = 'NONE') AND (TB_LAWYERS.Activity = 'ACTIVE') AND
(TB_LAWYERS.Relation_Type = 'EXTERNAL') AND (TB_CASES.TotalMLUSBBexposure BETWEEN TB_LAWYERS.MINAmount AND
TB_LAWYERS.MAXamount) AND (TB_LAWYERS.CaseLimitMONTHLY >= TB_LAWYERS.CaseLimitMONTHLYactual) AND
(TB_LAWYERS.CaseLimitDAILY >= TB_LAWYERS.CaseLimitDAILYactual) AND (TB_LAWYERS.Productivity <> '0')
ORDER BY TB_LAWYERS.Productivity DESC
ALTER TABLE TB_TEMPLawyer ENABLE TRIGGER ALL
ALTER TABLE TB_LAWYERS ENABLE TRIGGER ALL
ALTER TABLE TB_PCRelation ENABLE TRIGGER ALL
ALTER TABLE TB_CASES ENABLE TRIGGER ALL
ALTER TABLE TB_TEMPaccount ENABLE TRIGGER ALL