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=1 and tblWebBrand.Overrideactive = 1 AND tblProductDetail.sex=1 group by dbo.tblProductDetail.EuroStopPLU,tblProductDetail.sex, dbo.tblProductDetail.id,dbo.tblProductDetail.PLU, dbo.tblProductDetail.price, dbo.tblProductDetail.ColourID, dbo.tblProductDetail.Description order by newid()