Breaking News
Loading...
11/07/2014

Table Spool trong SQL Server



Trong execution, mặc dù ta thấy Table Spool operator lặp lại nhiều lần, nhưng nó căn bản là cùng 1 table. SQL Server tạo ra table Spool này, lưu data và sử dụng lại nhiều lần. Ta có thể chứng minh điều này bằng cách nhìn vào Node I D của các Operator

Nguyên văn như sau:
Even though Table Spool operator is shown in the execution plan multiple times, it is essential the same spool/cache. SQL Server builds it the first time and using its data later.

http://aboutsqlserver.com/2014/01/07/unwinding-table-spools/

1 link khác cũng nói về điều này
https://www.simple-talk.com/sql/learn-sql-server/showplan-operator-of-the-week---lazy-spool/

nguyên văn:
the Spool operator is displayed three times in the execution plan, but that don’t mean that three temporary tables were created. All the Spools are actually using the same temporary table, which can be verified if you look at the operator’s hints displayed in the graphical execution plan:

Cũng từ link trên, ta lưu ý định nghĩa sau:
Spool temporary tables are usually referenced as worktables in I/O statistics for the queries.

Tức là khi ta dùng lệnh set statistics io on, ta thấy worktables, đó chính là Spool table trong Execution plan.

Link sau đây phân tích 1 ví dụ đầy đủ
https://www.simple-talk.com/sql/learn-sql-server/showplan-operator-of-the-week---lazy-spool/

0 comments:

Post a Comment

 
Toggle Footer