When using common subexpression spools in execution plans, notably for windowed aggregate functions, surprisingly high logical reads for large tables have been observed. This behavior raises concerns about the efficiency of such spools.
Unlike traditional spool tables, logical reads for worktables, which are internal structures used for aggregation, are counted differently. Instead of measuring hashed pages, worktable logical reads are incremented for each row read. This unique counting method results in seemingly high counts, despite worktables being highly efficient.
In your specific case, the formula you discovered, "Worktable logical reads = 1 NumberOfRows 2 NumberOfGroups 4," holds true due to the specific behavior of these spools:
While tracing page reads is not an option for worktables, understanding these unique counting mechanisms can help explain the observed high logical reads.
For further clarification, refer to:
The above is the detailed content of Why Are My Windowed Aggregate Queries Showing Unexpectedly High Logical Reads When Using Common Subexpression Spools?. For more information, please follow other related articles on the PHP Chinese website!