View Single Post
  #1 (permalink)  
Old 11-24-08, 06:52
paul_anthony paul_anthony is offline
Registered User
 
Join Date: Sep 2005
Posts: 10
Slow query missing indexes?

Hi Guys,

I've a query that runs on two different machines with two different result. One machine it takes 12 seconds - the other it is almost instant. I think perhaps I have missing indexes on one server - anyone any advice on speeding the query up?

Alternatively any tools for mirroring database setups would be useful. Would the output of the execution plan make any sense to anyone?

I've attempting to script the indexes / primary / foreign keys between the two - to no avail.

Really tearing the hair out now as to where the bottle neck is.


PHP Code:
SELECT distinct top 8 dbo.tblProductDetail.EuroStopPLU As ssEuro,
newid(), dbo.tblProductDetail.PLU,  
dbo.tblProductDetail.ColourID,
dbo.tblProductDetail.id as ProductID 
FROM dbo
.tblOrderLines 
INNER JOIN dbo
.tblProductDetail ON dbo.tblOrderLines.ProductID dbo.tblProductDetail.ID INNER JOIN dbo.tblProductMaster ON tblProductMaster.ID=tblProductDetail.ProductMasterID INNER JOIN tblWebBrand ON tblProductMaster.WebBrandID=tblWebBrand.ID WHERE (dbo.tblOrderLines.OrderID IN (SELECT DISTINCT orderID FROM tblOrderLines WHERE productID 2548)) AND (dbo.tblOrderLines.ProductID <> 2548) AND (dbo.tblProductDetail.Active 1) AND (dbo.tblProductDetail.StockExceedsBuffer 1) AND tblWebBrand.Active=and tblWebBrand.Overrideactive AND tblProductDetail.sex=1 group by dbo.tblProductDetail.EuroStopPLU,tblProductDetail.sexdbo.tblProductDetail.id,dbo.tblProductDetail.PLUdbo.tblProductDetail.pricedbo.tblProductDetail.ColourIDdbo.tblProductDetail.Description order by newid() 
Reply With Quote