A long text plan provides more information than a short text plan, including the cached plan for a statement, and it is in a format that is easy to print and view without scrolling.
You must be the owner of the object(s) upon which the function is executed, or have the appropriate SELECT, UPDATE, DELETE, or INSERT privileges on the object(s).
Connect to a database.
Execute the PLAN function.
In this example, the long text plan is based on the following statement:
SELECT PLAN ('SELECT GivenName, Surname, OrderDate, Region, Country FROM GROUPO.Customers JOIN GROUPO.SalesOrders ON ( SalesOrders.CustomerID = Customers.ID ) WHERE CustomerID < 100 AND ( Region LIKE ''Eastern'' OR Country LIKE ''Canada'' ) ORDER BY OrderDate');
The long text plan reads as follows:
( Plan [ Total Cost Estimate: 6.46e-005, Costed Best Plans: 1, Costed Plans: 10, Optimization Time: 0.0011462, Estimated Cache Pages: 348 ] ( WorkTable ( Sort ( NestedLoopsJoin ( IndexScan Customers CustomersKey[ Customers.ID < 100 : 0.0001% Index | Bounded ] ) ( IndexScan SalesOrders FK_CustomerID_ID[ Customers.ID = SalesOrders.CustomerID : 0.79365% Statistics ] [ ( SalesOrders.CustomerID < 100 : 0.0001% Index | Bounded ) AND ( ( ((Customers.Country LIKE 'Canada' : 100% Computed) AND (Customers.Country = 'Canada' : 5% Guess)) OR ((SalesOrders.Region LIKE 'Eastern' : 100% Computed) AND (SalesOrders.Region = 'Eastern' : 5% Guess)) ) : 100% Guess ) ] ) ) ) ) )
The word Plan indicates the start of a query block. The Total Cost Estimate is the optimizer estimated time, in milliseconds, for the execution of the plan. The Costed Best Plans, Costed Plans, and Optimization Time are statistics of the optimization process while the Estimated Cache Pages is the estimated current cache size available for processing the statement.
The plan indicates that the results are sorted, and that a Nested Loops Join is used. On the same line as the join operator, there is the join condition and its selectivity estimate (which is evaluated for all the rows produced by the join operator). The IndexScan lines indicate that the Customers and SalesOrders tables are accessed via indexes CustomersKey and FK_CustomerID_ID respectively.
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|