查询花更多时间 [英] query Taking more time

查看:112
本文介绍了查询花更多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下查询花费更多时间,有时结果设置在15秒内,有时需要4分钟(结果集 行31553)

below query taking more time, sometime result set within 15 sec, sometime taking 4min ( resultset  row 31553)




select * from product_details(nolock)pd join product p(nolock) 在p.id = pd.pid,其中coalesce(pd.vendor_id,p.vendor_id)= 1072 

sp_spaceused product_details  --1812383             

sp_spaceused产品  --1483188             

sp_spaceused product_details  --1812383             
sp_spaceused product  --1483188             

在id上有索引,vndor_id

have index on id,vndor_id

推荐答案

WHERE子句中使用的合并函数 可防止使用现有索引。


与快速运行的执行计划相比,您是否检查了执行计划?
The used coalesce function in the WHERE clause prevents the usage of an existing index.
Have you checked the execution plan when it's slow compared with the one when it runs quick?


这篇关于查询花更多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆