This blog is a co-operation with my colleague Jan Kritter from the DB6 performance team. We will explain the "explain (plan)" function for DB6 in the SAP environment. Furthermore the basic options in the execution plan view will be explained.
You may want to read the database independent introduction in explain plans first:
Besides the Explain in the ST05 SQL trace (discussed in the above mentioned blog) there are other places where we can find the Explain in DB6.
ST05:
The "Enter SQL Statement" (shown in the above mentioned blog) option in ST05 is database dependent. We have to use native SQL here. For DB6 the parameter markers are question marks. A typical statement that you can explain here looks like this:
Don't forget to include the CLIENT/MANDT field if you "translate" an OPEN SQL Statement to a native SQL statement. The client is added automatically by the database interface (DBI), so you should add CLIENT / MANDT here.
ST04:
In ST04 you can find the Explain in the following places:
Figure 1 - Explain plan in ST04
Note: In each of these places the execution plan is an estimated execution plan. This means the current environment (e.g. parameter settings, statistics, hardware characteristics) is used to build the plan. By the way, the execution plan and access plan are often used as synonyms. Strictly speaking, "explain" is the DB6 function, which is applied to an explainable SQL statement during compilation time
We will continue with the classic Explain here, leaving out the new explain for the time being, in order to describe the basic option in the execution plan view of DB6.
After clicking "explain" you will see a screen like in figure 2.
Figure 2: Display Execution Plan for SQL Statement in DB6
In the following section we describe the options for the execution plan. The list also contains a very brief definition of the different functionalities, further explanations will be supplied in later blogs.
Note: In older SAP releases there might be an additional option called "Tree Info" which displays or hides the columns num_rows, tot_cost, io_cost for each step of the execution plan. In the current releases these columns are always shown.
Some of the options will be explained in more detail in future blogs where we will describe more on how to read and tune DB6 execution plans in detail.
We finish with a description of what is visible in right part of the Execution Plan view in figure 2.
The SQL Statement Section (bullet C in figure 2) shows the native SQL statement. This is what the DBI made out of the OPEN SQL statement. In case the OPEN SQL used a FOR ALL ENTRIES (FAE) or a pool or clustered table the native SQL statement might look very different from the OPEN SQL statement.
In the Access Plan line (bullet D in figure 2) we see the current level of optimization and parallelism that was used for this execution plan.
The execution plan itself is in the lower part of this screen (bullet E in figure 2). We plan to write more detailed blogs about the execution plan itself but here is already a quick overview of what we can see in our example.
Her we see a collection of operators that are organized in a tree-like structure. This structure describes the execution flow of the statement. Starting from top to bottom the first operation that has no child usually marks the first step in the execution plan. In our case in figure 2 this is the line:
This step indicates that we start with an index scan on index USR02~0 with 2 key columns and the associated estimated rows and costs (time and I/O) for this line.
The next step is the table access and the estimated rows and costs (time and I/O) for this line:
After fetching, the rows are returned to the application (ABAP program) in this step:
The root node indicates the type of the statement (SELECT, INSERT, ...) and the total cost (time) for this execution plan
This blog explained the basic option of explain plan in DB6. We will see more specific and detailed examples in future blogs.
Jan Kritter is Technical Support Consultant for SAP AGS (SAP Active Global Support)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |