首页 > 数据库技术 > 详细

SQL优化

时间:2016-06-08 12:25:45      阅读:302      评论:0      收藏:0      [点我收藏+]

原句,执行时间:2.78s
UPDATE pro_ProductEvaluate
SET hasPic = 1
WHERE
ID IN (
SELECT
c.ID
FROM
(
SELECT
a.ID
FROM
pro_ProductEvaluate a
INNER JOIN pro_ProductEvaluateImage b ON a.ID = b.pro_ProductEvaluateID
WHERE
1 = 1
AND a.CreateTime >= ‘2016-06-03 01:05:00‘
AND a.hasPic IS NULL
AND b.State = 1
) c
)

 

 

优化后:执行时间:0.38s
update pro_ProductEvaluate
set hasPic=1
where CreateTime>= ‘2016-06-03 01:05:00‘ and hasPic is null
and exists(
select 1 from pro_ProductEvaluateImage b
where b.State=1 and pro_ProductEvaluate.id=b.pro_ProductEvaluateID
)

SQL优化

原文:http://www.cnblogs.com/hankyoon/p/5569468.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!