- Learn T-SQL Querying
- Pedro Lopes Pam Lahoud
- 235字
- 2021-06-24 14:38:16
The Trivial Plan stage
As mentioned in the Query optimization essentials section of Chapter 2, Understanding Query Processing, SQL Server does cost-based optimization. But this has an expensive startup cost and so SQL Server will try to avoid this cost for simple queries that may only have one possible query execution plan.
The Trivial Plan stage generates plans for which there are no alternatives, and which require a cost-based decision. The following examples can be executed in the AdventureWorks sample database.
The following is a SELECT … INTO or INSERT INTO statement over a single table with no conditions:
SELECT NationalIDNumber, JobTitle, MaritalStatus
INTO HumanResources.Employee2
FROM HumanResources.Employee;
The preceding query produces the following execution plan:

The following is an INSERT INTO statement over a single table with a simple condition covered by an index:
INSERT INTO HumanResources.Employee2
SELECT NationalIDNumber, JobTitle, MaritalStatus
FROM HumanResources.Employee
WHERE BusinessEntityID < 10;
The preceding query produces the following execution plan:

The following is an INSERT statement with a VALUES clause:
INSERT INTO HumanResources.Employee2
VALUES (87656896, 'CIO', 'M');
The preceding query produces the following execution plan:

The information on the optimization level is stored in the execution plan under the Optimization Level property, with a value of TRIVIAL, as shown in the following screenshot:

The Trivial Plan stage typically finds very inexpensive query plans that are not affected by cardinality estimations.
- GNU-Linux Rapid Embedded Programming
- 三菱FX3U/5U PLC從入門到精通
- LabVIEW虛擬儀器從入門到測(cè)控應(yīng)用130例
- TestStand工業(yè)自動(dòng)化測(cè)試管理(典藏版)
- 自動(dòng)檢測(cè)與轉(zhuǎn)換技術(shù)
- 工業(yè)機(jī)器人工程應(yīng)用虛擬仿真教程:MotoSim EG-VRC
- 智能工業(yè)報(bào)警系統(tǒng)
- 城市道路交通主動(dòng)控制技術(shù)
- 21天學(xué)通Java
- 計(jì)算機(jī)系統(tǒng)結(jié)構(gòu)
- 信息物理系統(tǒng)(CPS)測(cè)試與評(píng)價(jià)技術(shù)
- 網(wǎng)中之我:何明升網(wǎng)絡(luò)社會(huì)論稿
- 實(shí)用網(wǎng)絡(luò)流量分析技術(shù)
- ASP.NET 2.0 Web開發(fā)入門指南
- PowerMill 2020五軸數(shù)控加工編程應(yīng)用實(shí)例