I never get very excited about the percentages - the thing has to add up to 100% somehow! ... however I do get worked up about the SCANs and LOGICAL I/O. Here's what I use to see what's-what (ignore the Physical stats, the Scans and Logical I/O need to be as low as you can get them):-- Comment in the SHOWPLAN for Query Plan, OR the STATISTICS for logical stats-- SET SHOWPLAN_TEXT ONGO-- SET STATISTICS IO ON; SET STATISTICS TIME ON-- ... put query here - e.g.:SELECT * FROM Northwind.dbo.ProductsSET STATISTICS IO OFF; SET STATISTICS TIME OFFGOSET SET SHOWPLAN_TEXT OFFGO
If you put a:BEGIN TRANSACTIONbefore your UPDATE statement and aROLLBACKafter it you could try a few scenarios without mucking up the data at all.-- 1 --UPDATE U SET CommissionEarned = @Commission FROM Apps AS UWHERE AppID in ( SELECT TheAppID FROM @AppStats WHERE IdentityAppID >= @lowerLimit AND IdentityAppID <= @upperLimit )-- 2 --UPDATE U SET CommissionEarned = @Commission FROM Apps AS U JOIN @AppStats on TheAppID = AppID AND IdentityAppID >= @lowerLimit AND IdentityAppID <= @upperLimit-- 3 --DECLARE @TempAppStat TABLE( TheAppID int NOT NULL, PRIMARY KEY ( TheAppID ))--INSERT INTO @TempAppStat(TheAppID)SELECT TheAppIDFROM @AppStatsWHERE IdentityAppID >= @lowerLimit AND IdentityAppID <= @upperLimit--UPDATE U SET CommissionEarned = @Commission FROM Apps AS U JOIN @TempAppStats on TheAppID = AppID
Sorry if you know all this already.Kristen