为何 这段SQL查询一个AND 条件就会卡死?

栏目:k3wise知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

为何 这段SQL查询一个AND 条件就会卡死?

SELECT DISTINCT t_BOSqlgxhb.FID,t_BOSqlgxhb.FClassTypeID ,t_BOSqlgxhbEntry.FEntryID,t_BOSqlgxhbEntry.FIndex,t_User.FName FROM t_BOSqlgxhb
INNER JOIN t_BOSqlgxhbEntry ON t_BOSqlgxhb.FID=t_BOSqlgxhbEntry.FID
LEFT JOIN t_Item_3013 ON t_BOSqlgxhb.FGX=t_Item_3013.FItemID AND t_Item_3013.FItemID<>0
LEFT JOIN t_User ON t_BOSqlgxhb.FBiller=t_User.FUserID AND t_User.FUserID<>0
LEFT JOIN t_User t_User2 ON t_BOSqlgxhb.FModifier=t_User2.FUserID AND t_User2.FUserID<>0
LEFT JOIN t_ICItem t_ICItem1 ON t_BOSqlgxhbEntry.FBase9=t_ICItem1.FItemID AND t_ICItem1.FItemID<>0
LEFT JOIN t_ICItem ON t_BOSqlgxhbEntry.FitemID=t_ICItem.FItemID AND t_ICItem.FItemID<>0
LEFT JOIN t_Item t_ICItem_FBaseProperty1 ON t_ICItem.F_121=t_ICItem_FBaseProperty1.FItemID AND t_ICItem_FBaseProperty1.FItemID<>0
LEFT JOIN t_Item t_ICItem_FBaseProperty2 ON t_ICItem.F_150=t_ICItem_FBaseProperty2.FItemID AND t_ICItem_FBaseProperty2.FItemID<>0
LEFT JOIN t_Item t_ICItem_FBaseProperty10 ON t_ICItem.F_141=t_ICItem_FBaseProperty10.FItemID AND t_ICItem_FBaseProperty10.FItemID<>0
LEFT JOIN t_Item t_ICItem_FBaseProperty11 ON t_ICItem.F_131=t_ICItem_FBaseProperty11.FItemID AND t_ICItem_FBaseProperty11.FItemID<>0
LEFT JOIN t_Measureunit ON t_BOSqlgxhbEntry.Funit=t_Measureunit.FItemID AND t_Measureunit.FItemID<>0
LEFT JOIN t_Emp ON t_BOSqlgxhbEntry.FEmp=t_Emp.FItemID AND t_Emp.FItemID<>0
LEFT JOIN t_Emp t_Emp2 ON t_BOSqlgxhbEntry.FEmp2=t_Emp2.FItemID AND t_Emp2.FItemID<>0
LEFT JOIN t_Emp t_Emp1 ON t_BOSqlgxhbEntry.Fbanz=t_Emp1.FItemID AND t_Emp1.FItemID<>0
LEFT JOIN t_Emp t_Emp4 ON t_BOSqlgxhbEntry.FBase5=t_Emp4.FItemID AND t_Emp4.FItemID<>0
LEFT JOIN t_Emp t_Emp3 ON t_BOSqlgxhbEntry.Fzhuren=t_Emp3.FItemID AND t_Emp3.FItemID<>0
WHERE (
t_Item_3013.FName Like '%铂大铸造-重力浇铸%' AND
t_ICItem.FName Like '%A6091%' AND
t_BOSqlgxhb.FHBDate BETWEEN '2017-08-01' AND '2017-08-31 23:59:59'
--AND t_User.FName = '卢若卡'
) AND t_BOSqlgxhb.FClassTypeID=200000013 Order By t_BOSqlgxhb.FID,t_BOSqlgxhbEntry.FIndex

以上SQL 如果--AND t_User.FName = '卢若卡' 注释 执行正常
如果注释去掉 则卡死,很久不能返回结果。。请教各位原因。谢谢各位帮助!


回复大家。在 user 表里建了N多索引后问题竟然可以了。。。还是不明白啊
1,注释掉查询出来有多少数据
2,t_User表有多少数据
用SQL执行计划看一下

为何 这段SQL查询一个AND 条件就会卡死?

SELECT DISTINCT t_BOSqlgxhb.FID,t_BOSqlgxhb.FClassTypeID ,t_BOSqlgxhbEntry.FEntryID,t_BOSqlgxhbEntry.FIndex,t_User.FName ...
点击下载文档
标签: # K/3 WISE-BOS
分享:
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息