Skip to Main Content
Learn T-SQL Querying
book

Learn T-SQL Querying

by Pedro Lopes, Pam Lahoud
May 2019
Intermediate to advanced content levelIntermediate to advanced
484 pages
11h 23m
English
Packt Publishing
Content preview from Learn T-SQL Querying

Spools

Spools are expensive operators, but they are introduced in a query plan as an optimization, typically to compensate for inadequate indexes, or to optimize otherwise complex queries by significantly speeding up the overall runtime of a query. A Spool reads data and saves it in a worktable in TempDB. This process is used whenever the Query Optimizer knows that the density of a column is high (therefore having low selectivity) and the intermediate result is very complex to calculate. If this is the case, SQL Server computes the result once and stores it in a Spool so it can be searched later in the execution. Spools only exist while the query is being executed.

Conceptually, all physical Spool operators function the same way:

  1. Read all ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn T-SQL Querying - Second Edition

Learn T-SQL Querying - Second Edition

Pedro Lopes, Pam Lahoud
SQL Server T-SQL Recipes, Fourth Edition

SQL Server T-SQL Recipes, Fourth Edition

Jason Brimhall, Jonathan Gennick, Wayne Sheffield

Publisher Resources

ISBN: 9781789348811Supplemental Content