Home Database Mysql Tutorial SQLSERVER中的假脱机

SQLSERVER中的假脱机

Jun 07, 2016 pm 05:38 PM
sqlserver Offline

SQLSERVER中的假脱机 我发现网上对于假脱机的解释都非常零散,究竟假脱机是什么? 这几天在家里研究了一下,收集了很多网上的资料 假脱机是中文的翻译,而英文的名字叫做 spool 在徐老师写的《SQLSERVER企业级平台管理实践》里提到了一下假脱机 在SQLSERVER

SQLSERVER中的假脱机

我发现网上对于假脱机的解释都非常零散,究竟假脱机是什么?

这几天在家里研究了一下,收集了很多网上的资料

假脱机是中文的翻译,而英文的名字叫做 spool

 

在徐老师写的《SQLSERVER企业级平台管理实践》里提到了一下假脱机

在SQLSERVER I/O问题的那一节

在性能监视器里,有一个计数器“worktables/sec” :

每秒创建的工作表数。例如,工作表可用于存储查询假脱机(query spool),LOB变量,XML变量,表变量,游标的临时结果

在《剖析SQLServer执行计划》里也提到了假脱机

(13) 有时查询优化器需要在tempdb数据库中建立临时工作表。如果是这样的话

就意味着图形执行计划中有标识成Index Spool, Row Count Spool或者Table Spool的图标。

任何时候,使用到工作表一般都会防碍到性能,因为需要额外的I/O开销来维护这个工作表。

 

之前本人也写过一篇文章:对于索引假脱机的一点理解

写这篇文章的时候当时还是对假脱机一知半解

假脱机在MSDN中的执行计划中的逻辑运算符和物理运算符中提到了几个假脱机相关的运算符(详见本文最后面)

Eager Spool

Lazy Spool

Index Spool (有时候也叫 Nonclustered Index Spool)

Row Count Spool

Spool

Table Spool

Window Spool 

Spool, Table Spool, Index Spool, Window Spool 和 Row Count Spool是物理运算符

Eager Spool 和 Lazy Spool是逻辑运算符

 

这些运算符描述了假脱机是如何工作的,在这里你需要非常清楚逻辑运算符和物理运算符的区别

MSDN中的解释:

逻辑运算符:逻辑运算符描述了用于处理语句的关系代数操作。 换言之,逻辑运算符从概念上描述了需要执行哪些操作。

物理运算符:物理运算符实施由逻辑运算符描述的操作。 每个物理运算符都是一个执行某项操作的对象或例程。

例如,某些物理运算符可访问表、索引或视图中的列或行。 其他物理运算符执行其他操作,如计算、聚合、数据完整性检查或联接。

物理运算符具有与其关联的开销。

注意:窗口假脱机是没有Eager Spool和Lazy Spool之分的,因为他既是逻辑运算符也是物理运算符!!

 

简单来讲SQLSERVER做某项操作由物理运算符来做,而具体怎样做就由逻辑运算符来决定

打个比方:小明在佛山,想去广州,小明可以选择开汽车去广州,踩自行车去广州,骑摩托车去广州(相当于做某项操作)

小明可以根据当时的路况:

(1)踩自行车:如果道路比较拥堵,踩自行车不用怕,,最多的车也能过,他可以选择使劲的踩(Eager Spool)或者慢慢踩(Lazy Spool)

(2)开汽车:如果道路比较畅通,他可以选择开快一点(Eager Spool)或者开慢一点(Lazy Spool)

(3)骑摩托车:如果道路比较拥堵,他可以选择抄小路,然后开快一点(Eager Spool)或者开慢一点(Lazy Spool)

 

不知道这个比喻大家明白没有,不过本人也找不到更好的比喻~

 

在图形执行计划中,你会发现Table Spool 有时候会带有  Eager Spool ,有时候有会带有 Lazy Spool

因为Table Spool是物理运算符,Eager Spool和Eager Spool 是逻辑运算符

Table Spool(表假脱机)

SQL脚本如下:

表假脱机 Eager Spool

Sales (EmpId INT, Yr INT, Sales MONEY) 5 INSERT Sales VALUES(1, 2005, 12000) 6 INSERT Sales VALUES(1, 2006, 18000) 7 INSERT Sales VALUES(1, 2007, 25000) 8 INSERT Sales VALUES(2, 2005, 15000) 9 INSERT Sales VALUES(2, 2006, 6000) 10 INSERT Sales VALUES(3, 2006, 20000) 11 INSERT Sales VALUES(3, 2007, 24000) .EmpId, Yr, SUM(Sales) AS Sales 17 FROM Sales EmpId, Yr WITH CUBE

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem that the object named already exists in the sqlserver database How to solve the problem that the object named already exists in the sqlserver database Apr 05, 2024 pm 09:42 PM

For objects with the same name that already exist in the SQL Server database, the following steps need to be taken: Confirm the object type (table, view, stored procedure). IF NOT EXISTS can be used to skip creation if the object is empty. If the object has data, use a different name or modify the structure. Use DROP to delete existing objects (use caution, backup recommended). Check for schema changes to make sure there are no references to deleted or renamed objects.

How to import mdf file into sqlserver How to import mdf file into sqlserver Apr 08, 2024 am 11:41 AM

The import steps are as follows: Copy the MDF file to SQL Server's data directory (usually C:\Program Files\Microsoft SQL Server\MSSQL\DATA). In SQL Server Management Studio (SSMS), open the database and select Attach. Click the Add button and select the MDF file. Confirm the database name and click the OK button.

What to do if the sqlserver service cannot be started What to do if the sqlserver service cannot be started Apr 05, 2024 pm 10:00 PM

When the SQL Server service fails to start, here are some steps to resolve: Check the error log to determine the root cause. Make sure the service account has permission to start the service. Check whether dependency services are running. Disable antivirus software. Repair SQL Server installation. If the repair does not work, reinstall SQL Server.

How to check sqlserver port number How to check sqlserver port number Apr 05, 2024 pm 09:57 PM

To view the SQL Server port number: Open SSMS and connect to the server. Find the server name in Object Explorer, right-click it and select Properties. In the Connection tab, view the TCP Port field.

How to recover accidentally deleted database in sqlserver How to recover accidentally deleted database in sqlserver Apr 05, 2024 pm 10:39 PM

If you accidentally delete a SQL Server database, you can take the following steps to recover: stop database activity; back up log files; check database logs; recovery options: restore from backup; restore from transaction log; use DBCC CHECKDB; use third-party tools. Please back up your database regularly and enable transaction logging to prevent data loss.

Where is the sqlserver database? Where is the sqlserver database? Apr 05, 2024 pm 08:21 PM

SQL Server database files are usually stored in the following default location: Windows: C:\Program Files\Microsoft SQL Server\MSSQL\DATALinux: /var/opt/mssql/data The database file location can be customized by modifying the database file path setting.

What should I do if there is no offline option in Windows 10 Home Edition Disk Management? What should I do if there is no offline option in Windows 10 Home Edition Disk Management? Feb 20, 2024 am 08:39 AM

Recently, many friends often encounter that the disk management tool does not display the two options of "offline" and "online", thinking that whether it is an external hard disk device connected to the computer or the built-in C or D drive, they cannot The solution to this operation is actually very simple. Win10 Home Edition Disk Management does not have an offline option. Solution 1. First, we click the Start button on the computer’s taskbar. 2. Then we enter the keyword of the service in the search box and select the option we need. 3. After entering the corresponding option interface, we use the mouse to double-click the OfflineFiles option. 4. After entering the OfflineFiles interface, we click the start button in the service status here. 5. Finally we

How to solve Java connection SqlServer error How to solve Java connection SqlServer error May 01, 2023 am 09:22 AM

The problem was found that this time I was using the SqlServer database, which I had not used before, but the problem was not serious. After I connected the SqlServer according to the steps in the requirements document, I started the SpringBoot project and found an error, as follows: At first I thought it was a SqlServer connection. There was a problem, so I went to check the database and found that everything was normal. I first asked my colleagues if they had such a problem, and found that they did not, so I started my best part, facing Baidu. programming. The specific error message I started to solve was this, so I started Baidu error reporting: ERRORc.a.d.p.DruidDataSource$CreateCo

See all articles