标准化SQL多个AND / Where

时间:2015-03-16 16:05:56

标签: sql sql-server sql-server-2008

我正在尝试使以下SQL更有效,但尚未成功超出我的以下内容。这将在大约2分钟内运行,返回800行的平均值。我不能使用临时表。有什么建议吗?

Select POP.Account_Number, IP.IP_Id_Src, 
 POP.Ip_Name_Full, INFO_Default_Hmp.Date_Solicitation, 
 INFO.BAL_PRIN_AMT, UDD.USER_DEFINED_5V_14, 
 POP.Process_Stop_Code, POP.Mail_Code

 FROM POP, IP, INFO, INFO_Default_Hmp, 
 INFO_Participation_Item, UDD

 WHERE (INFO.Account_Number=POP.Account_Number 
 AND INFO.Appl_Id=POP.Appl_Id 
 AND INFO.Bank_Number=POP.Bank_Number 
 AND INFO_Default_Hmp.Bank_Number=POP.Bank_Number 
 AND INFO_Default_Hmp.Account_Number=POP.Account_Number 
 AND INFO_Default_Hmp.Appl_Id=POP.Appl_Id 
 AND POP.Bank_Number=INFO_Participation_Item.Bank_Number 
 AND POP.Appl_Id=INFO_Participation_Item.Appl_Id 
 AND POP.Account_Number=INFO_Participation_Item.Account_Number 
 AND INFO_Participation_Item.Involved_Party_Id_Investor=IP.Involved_Party_Id_Investor 
 AND UDD.Account_Number=POP.Account_Number 
 AND UDD.Bank_Number=POP.Bank_Number 
 AND POP.Appl_Id=UDD.Appl_Id)  
 AND ((POP.Appl_Id='FL' 
 AND POP.Account_Status_Code='A' 
 AND INFO.Bal_Prin_Amt>0 
 AND UDD.User_Defined_5v_14='S1'))

1 个答案:

答案 0 :(得分:0)

最大限度地使用经常过滤和连接的列的索引,尤其是int字段。

另外,通过将该标记添加到帖子中,让我们知道您正在使用哪个RDBMS