Posts Tagged ‘inner join’
今天同事遇到一个mysql语句执行慢的问题,叫我帮忙看看,具体语句如下:
select Products.ProductID,Name from Products
where Products.ProductID in
(
select ProductID from Price
INNER JOIN vendors ON (price.VendorID = vendors.VendorID)
where ( price.ExpiryDate > now() or YEAR(Price.ExpiryDate) = 1 )
and vendors.Status = ‘1′
and Price.MemberID=@memberID and Price.Disable=’false’ and IsHistory=0
)
and Disable=’false’
他说单独执行括号内的子查询,速度很快,没有那个子查询速度也很快,但合并起来后速度就很慢!
Page 1 of 11