Documente Academic
Documente Profesional
Documente Cultură
SQL Trace
A
Buffer trace
A
Enqueue trace
A
RFC trace
A record of received
To obtain an overview of
To
access the SQL Performance Trace, use transaction ST05 or from the R/3 initial screen, choose
System Utilities SQL Trace.
Before activating an SQL Performance Trace for a report or a transaction, you should execute the
report one time to prevent the buffer load process for the R/3 table buffer, the R/3 program buffer,
and so on, from being included in the subsequent trace.
The trace can be activated in the production system without any risk of creating errors or
inconsistencies.
The trace can be activated by any user and for any object. When activating the trace, ensure that you
are not using multiple user sessions or running other processes such as background jobs or update
processes under the same user ID on this application server. These activities would make the SQL
Performance Trace difficult to interpret.
For each application server, there is only one active trace file. Therefore, on a given application
server, only one user can activate a trace. The default size of the trace file is 800 KB. SAP
recommends increasing the size of the trace file to 16 MB by setting the parameter
rstr/max_diskspace to 16 384 000.
(C) SAP AG BC490 2-13
SAP AG 1999
Database
files
SQL
Trace
File
The
R/3 database interface receives an SQL statement from the ABAP program and converts it to an
SQL statement that can be processed by the database.
For each database operation, the SQL trace measures the time taken from the sending of the request
to the database server to the receipt of the results for the request on the application server via the R/3
database interface (including the time spent in the network between the application server and the
database server).
The data written to the trace file includes the database response time, a time stamp, the number of
transferred data records, the database return code, the text of the SQL statement, and additional
administrative information for each database operation.
(C) SAP AG BC490 2-14
SAP AG 2001
same regardless of the database system. Data operations that require more than
100 milliseconds are marked red. Each section of the list has a header identifying the user,
transaction, R/3 work process number, and R/3 client ID. The expanded trace list has the following
columns:
hh:mm:ss:ms Time stamp indicating the begin of sending the database request
(hour:minute:second:millisecond)
Duration Duration of the database operation in microseconds (varies according to
system load)
Program Name of the program calling the SQL statement
Object Name of the table or view, as taken from the SQL statement
Oper Database operation to be executed
Curs Name of the database cursor
ArrSz Size of packets containing the data records sent from the database server to the
application server
Rec Number of data records sent by the database operation
RC Return code of the database system
Statement The text of the SQL statement
(C) SAP AG BC490 2-15
SAP AG 2001
Database interface
:A1= '0000000100'
During the
processing of an SQL statement performing a read access, the following operations occur:
PREPARE: This operation parses the SQL statement and converts it to a statement that can be
processed by the database. In particular, the access strategy is determined. Placeholders are used
for variables in the SQL statement.
OPEN/REOPEN: This operation replaces the placeholders in the SQL statement with concrete
values, and opens the database cursor.
FETCH: This operation transfers the database records from the database server to the application
server. The number of records transferred per FETCH is given by dividing the length of the data
record to be read in bytes by the value of dbs/io_buf_size, which, by default, is set to 33 792 bytes.
An SQL statement performing a write access is processed in the same way, except that
EXEC/REEXEC is used instead of OPEN/REOPEN and FETCH.
Database
cursors per R/3 work process are buffered in the SAP cursor cache. This enables the
PREPARE operation to be omitted for repeated executions of similar SQL statements. Displacement
occurs in the SAP cursor cache.
(C) SAP AG BC490 2-16
SAP AG 2001
1
2
5
43
access Explain SQL from the trace list, choose Trace Explain SQL. Alternatively, use the
Explain SQL button. Explain SQL is performed for the SQL statement on which your cursor is
currently positioned in the trace list. Explain SQL is only possible for the database operations
PREPARE, OPEN, and REOPEN.
In the top part of the Explain SQL display, you see the SQL statement with its variables. The lower
part of the display shows the access strategy of the SQL statement. The possible access strategies
will be explained later.
Double-click the table frame (see 1 in the Figure) to display a dialog box containing statistical
information on the table and information on all indexes of the table. Double-click an index (see 2) to
display statistical information on it.
Use the Analyze button (see 3) to refresh the statistical information on a table and its indexes. To
enable the cost-based optimizer to function effectively, the statistical information it uses must be
updated after each change to a table or its indexes. Use the Index Statistics button (see 4) to display
an overview of the statistical information across all indexes.
Use the Explain with hint button (see 5) to display the execution path of an SQL statement in
conjunction with hints. Hints are used to force the database to choose a particular execution path.
The available hints are explained later.
To
To
access the ABAP code that triggered the issue of the SQL statement, from the trace list screen,
use the ABAP Display button or choose Trace ABAP Display from the menu. The ABAP coding
is displayed for the SQL statement on which your cursor is currently positioned in the trace list.
Explain SQL is only possible for the database operations PREPARE, OPEN, and REOPEN.
The SQL statement in the ABAP code, which is normally formulated in OPEN SQL, may differ
considerably from the SQL statement processed by the database. The following list indicates how the
R/3 database interface converts certain SQL terms:
A WHERE clause is used for each SQL statement that accesses a client-dependent table (except
for SELECT CLIENT SPECIFIED)
SELECT FOR ALL ENTRIES => Several SELECT statements with corresponding OR clauses
(details later)
MODIFY => INSERT or UPDATE
Accessing pooled and cluster tables
EXPORT/IMPORT TO/FROM DATABASE => INSERT/SELECT on INDX-like tables
OPEN CURSOR/FETCH NEXT => No equivalent in the SQL trace or/ equivalent SELECT
(details later)
(C) SAP AG BC490 2-18
SAP AG 2001
365
365
365
365
365
365
365
DIA
DIA
DIA
DIA
DIA
DIA
DIA
12:52:59.091
12:52:59.088
12:52:59.097
12:52:59.099
12:52:59.084
12:52:59.103
12:52:59.100
SEU_
SEU_
SEU_
SEU_
SEU_
SEU_
SEU_
VVBEP
KKNA1
VVBAP
MMARC
MMARC
VVBEP
KKNA1
SEL
SEL
SEL
SEL
SEL
SEL
SEL
4
2
1
1
1
1
1
1.554
631
3.553
1.493
1.716
1.428
610
Loop
construct
the trace list, choose Goto Summary to display a summarized form of the list. The list shows
the SQL operations, the number of affected data records, and the processing time required.
The summarized list is particularly useful for identifying loop constructs. The list can be compressed
even further to show the most frequently accessed tables by using the Summarize button.
In
the trace list, choose Goto Statement Summary to find out how many structure-identical SQL
statements there are, and which tables or views they access (a structure-identical strategy is an
identical access strategy with different variables). The displayed list is sorted by the time taken with
time indicated in microseconds.
The list also indicates the percentage of value-identical accesses (identical SELECTs) and the total
number of returned data records. You should avoid all value-identical accesses.
In
VVBAK
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
VVBAP
WHERE clause
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
"MANDT" = '100'
Continue Cancel...
System Help S
Identical Selects
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
"VBELN"
BETWEEN '000000000
= '0000000001'
= '0000000002'
= '0000000003'
= '0000000004'
= '0000000005'
= '0000000006'
= '0000000007'
= '0000000008'
= '0000000009'
= '0000000010'
= '0000000001' OR