theresatan
Programmer
Hi,
I am reading an article about performence using Northwind as sample DB and the scripts at the bottom. It said:
Although the same data is returned by both queries, Query Analyzer indicated that the second version took around 40% less SQL Server resources to run than the first
I want to know where the '40%' come from
Code Example 1:
SELECT Ord.OrderID, Ord.OrderDate,
( SELECT MAX(OrdDet.UnitPrice)
FROM Northwind.dbo.[Order Details] AS OrdDet
WHERE Ord.OrderID = OrdDet.OrderID) AS MaxUnitPrice
FROM Northwind.db
rders AS Ord
Code Example 2:
SELECT Ord.OrderID, Ord.OrderDate,
MAX(OrdDet.UnitPrice) as maxUnitPrice
FROM Northwind.dbo.[Order Details] AS OrdDet
inner join
Northwind.db
rders AS Ord
on Ord.OrderID = OrdDet.OrderID
group by Ord.OrderID, Ord.OrderDate
Thanks!
Theresa
I am reading an article about performence using Northwind as sample DB and the scripts at the bottom. It said:
Although the same data is returned by both queries, Query Analyzer indicated that the second version took around 40% less SQL Server resources to run than the first
I want to know where the '40%' come from
Code Example 1:
SELECT Ord.OrderID, Ord.OrderDate,
( SELECT MAX(OrdDet.UnitPrice)
FROM Northwind.dbo.[Order Details] AS OrdDet
WHERE Ord.OrderID = OrdDet.OrderID) AS MaxUnitPrice
FROM Northwind.db
Code Example 2:
SELECT Ord.OrderID, Ord.OrderDate,
MAX(OrdDet.UnitPrice) as maxUnitPrice
FROM Northwind.dbo.[Order Details] AS OrdDet
inner join
Northwind.db
on Ord.OrderID = OrdDet.OrderID
group by Ord.OrderID, Ord.OrderDate
Thanks!
Theresa