Trivial plan optimization
The optimization process may be expensive to initialize and run for simple queries that don’t require any cost estimation. To avoid this expensive operation for simple queries, SQL Server uses trivial plan optimization. In short, if there’s only one way, or one obvious best way, to execute the query, depending on the query definition and available metadata, a lot of work can be avoided. For example, the following AdventureWorks2019
query will produce a trivial plan:
SELECT * FROM Sales.SalesOrderDetail
WHERE SalesOrderID = 43659
The execution plan will show whether a trivial plan optimization was performed; the Optimization Level entry in the Properties window of a graphical plan will show TRIVIAL
. In the same way, an XML plan will show the StatementOptmLevel
attribute as TRIVIAL
, as you can see in the next XML fragment:
<StmtSimple StatementCompId=”1” StatementEstRows=”12” StatementId=”1”...