Ian Boyd
2003-09-10 20:23:34 UTC
i'm looking at a query, trying to see why it takes so long.
An obvious culprit is where an Employees table (~1,500 rows) is being run
through "Lazy Spool" operator. The output of the operation is over 7 million
rows. There is then a join against these 7 million rows.
Is this normal?
The BOL says:
<quote>
The Lazy Spool logical operator stores each row from its input in a hidden
temporary object stored in the tempdb database. If the operator is rewound
(for example, by a Nested Loops operator) but no rebinding is needed, the
spooled data is used instead of rescanning the input. If rebinding is
needed, the spooled data is discarded and the spool object is rebuilt by
rescanning the (rebound) input.
The Lazy Spool operator will build its spool file in a lazy (noneager)
manner. Each time the spool's parent operator asks for a row, the spool
operator gets a row from its input operator and stores it in the spool.
</quote>
Looking for any possible explanation of this 1000x expansion is the number
of records, i see the line paraphrased line:
'Each time the operator asks for a row, it gets it from the input, and
stores it in the spool.'
Is this an indicator that our Employees table is being asked 7 million times
for a piece of information, and so it adds 7 million rows to the spool
table. If this is the case, then there would be duplicate rows in the spool
table. And that doesnt' seem right.
1,000 rows -> Table Spool/Lazy Spool ->7,000,000 rows ?
Does this seem right?
An obvious culprit is where an Employees table (~1,500 rows) is being run
through "Lazy Spool" operator. The output of the operation is over 7 million
rows. There is then a join against these 7 million rows.
Is this normal?
The BOL says:
<quote>
The Lazy Spool logical operator stores each row from its input in a hidden
temporary object stored in the tempdb database. If the operator is rewound
(for example, by a Nested Loops operator) but no rebinding is needed, the
spooled data is used instead of rescanning the input. If rebinding is
needed, the spooled data is discarded and the spool object is rebuilt by
rescanning the (rebound) input.
The Lazy Spool operator will build its spool file in a lazy (noneager)
manner. Each time the spool's parent operator asks for a row, the spool
operator gets a row from its input operator and stores it in the spool.
</quote>
Looking for any possible explanation of this 1000x expansion is the number
of records, i see the line paraphrased line:
'Each time the operator asks for a row, it gets it from the input, and
stores it in the spool.'
Is this an indicator that our Employees table is being asked 7 million times
for a piece of information, and so it adds 7 million rows to the spool
table. If this is the case, then there would be duplicate rows in the spool
table. And that doesnt' seem right.
1,000 rows -> Table Spool/Lazy Spool ->7,000,000 rows ?
Does this seem right?