TL;DR - Stored Procdure containing two select queries dealing with 33 million records took me 45 seconds to execute without a transaction, 48 seconds with.
Disclaimer: I wrote a stored procedure for about 4 hours and came across a somewhat measurable answer to this question (NOTE: It's not that significant!) Gaps in query logic are intentionally omitted due to the sensitivity of the data I was working with.
Methodology: This procedure was developed using two queries - one doing most of the heavy lifting, and the other calculating one additional field on its own so it doesn't try to calculate a field more than it needs to. I've broken it down into two steps:
1) I wrote 2 Common Table Expressions with 1 SQL SELECT into a Temporary Table, then Queried it again. I had to do this because the requirements asked of me were to implement a couple scalar valued functions that would have otherwise attempted to run the function on over 33 million records instead of 355.
2) I attached a scalar valued function AFTER the first query so it didn't try to look in the 30 million records (It made a huge difference, if you care).
Query: For readership purposes, I've cut out a large part of the query (The case statement).
CREATE PROC GET_PAYMENT_SUMS_BY_CLIENT
AS
--Required for reporting in a specific Business Intelligence later; Optional
SET FMTONLY OFF;
BEGIN TRANSACTION
--Query 1
--This CTE checks over 30 million records
WITH CTE1 AS(
SELECT CASE VARIABLE
--170 case conditions go here
END AS TheType,
Amount,
PK1 FROM TABLE1),
--THIS CTE Pivots the sums to get the data in the style I want it in
CTE2 AS(
SELECT PK1, [PIVOT1], [PIVOT2], [PIVOT3]
FROM
(SELECT * FROM CTE1) AS BaseTable --Alias was just to get it to execute
)
PIVOT(
SUM(Amount)
FOR TheType IN ([PIVOT1], [PIVOT2], [PIVOT3])
) AS PivotTable
)
)
SELECT TABLE2.NAME, CTE2.* INTO #TEMPORARY_TABLE
FROM CTE2
JOIN TABLE2 ON CTE2.PK1 = TABLE2.PK2
--Query 2
--Written to force the function to look at 355 records instead of 33 million
SELECT *, dbo.SCALAR_VALUED_FUNCTION(PK2) FROM #TEMPORARY_TABLE
COMMIT TRANSACTION
Findings:
With Transaction - If the Transaction logic is used, the resulting query from this set takes 48 seconds to process more than 33 million records in a case statement containing 170 lines, pivot the data by sum, place the data into a temporary table, and attach a scalar valued function AFTER the first query has run.
Without Transaction - If the commented lines in the code are left commented, all of the aforementioned steps are accomplished in 45 seconds. This is about 7% faster than with a Transaction block: 3/45 = 0.0666.... ~ 7% faster.
Conclusion:
While my efforts cannot tell you if doing the same query for 10 records will yield the same proportion of difference, it can tell you that it begins to matter more when you begin to larger data sets and/or more complicated queries.
I have this information has served a purpose for someone out there!