![Learn T-SQL Querying](https://wfqqreader-1252317822.image.myqcloud.com/cover/635/36698635/b_36698635.jpg)
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:
![](https://epubservercos.yuewen.com/9A808B/19470379101492206/epubprivate/OEBPS/Images/eeb5470f-497f-4eda-bd1c-121369aa3de3.png?sign=1740081232-Wc5iS1XNeSYQTWFT4jbvmHFhCEoXStBj-0-cc32624b342b2a0501093a348a187ba7)
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:
![](https://epubservercos.yuewen.com/9A808B/19470379101492206/epubprivate/OEBPS/Images/69a26f8e-40d1-41fa-b867-e2e32b234d60.png?sign=1740081232-izZopRvWJj3vSCvQCexWJL5kLLPGfwJg-0-9a8ad35bcbc26279ed877b8c37aef34a)
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:
![](https://epubservercos.yuewen.com/9A808B/19470379101492206/epubprivate/OEBPS/Images/3f91c292-9889-4d2e-bc7b-cb44a01c95ba.png?sign=1740081232-dbeLf35VcvFCo71pdPYrxCAidXFZwsqc-0-a53613a2fd811bb08545c2a0d1639cd4)
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:
![](https://epubservercos.yuewen.com/9A808B/19470379101492206/epubprivate/OEBPS/Images/35fdddef-441a-4656-8813-6a6709d0377b.png?sign=1740081232-QPUIzDYW0ZFs0po540hy38oE8YrnByAu-0-514e781ffcc4bacc1cf9ecf824798947)
The Trivial Plan stage typically finds very inexpensive query plans that are not affected by cardinality estimations.