|
Main Methods
|
Special Methods
|
Advanced Methods and Modules
|
SQLT
Overview SQLT
总览SQLTXPLAIN
, also known as SQLT
, is a tool provided by Oracle Server Technologies Center of Expertise - ST CoE. SQLT
main methods input one SQL statement and output a set of diagnostics files. These files are commonly used to diagnose SQL statements performing poorly or those which generate wrong results. SQLTXPLAIN
也称为SQLT,
Oracle Server技术专家中心-ST CoE提供的工具。SQLT
主要方法输入一个SQL语句并输出一组诊断文件。这些文件通常用于诊断性能不佳或产生错误结果的SQL语句。
Once installed, you can use SQLT
to analyze a SQL statement by passing its text within a script (including bind variables), or by providing its SQL_ID
.The SQL_ID can be found in AWR and ASH reports and the HASH_VALUE in SQL_TRACE output (above the SQL text and identified by the "hv=" token). You can also find these columns in the V$SQL view. Please refer to the following document for example selects: Document 1627387.1 How to Determine the SQL_ID for a SQL Statement 一旦安装,你可以用SQLT
一个脚本(包括绑定变量)内通过其文本分析SQL语句,或通过提供其SQL_ID
. SQL_ID可以在AWR和ASH报告和SQL_TRACE输出HASH_VALUE(SQL文本上方并由 "hv="标记标识)。您也可以在V$SQL视图中找到这些列。请参考以下文档进行示例选择:Document 1627387.1 How to Determine the SQL_ID for a SQL Statement
SQLT
main methods connect to the database and collect execution plans, Cost-based Optimizer CBO statistics, schema objects metadata, performance statistics, configuration parameters, and other elements that influence the performance of the one SQL being analyzed. SQLT
主要方法连接到数据库并收集执行计划,基于成本的Optimizer CBO统计信息,schema对象元数据,性能统计信息,配置参数以及其他影响所分析的SQL性能的元素。
SQLT
may use the Oracle Diagnostic and/or the Oracle Tuning Packs if your site has a license for them. These two provide enhanced functionality to the SQLT
tool. During SQLT
installation you can specify if one of these two packages is licensed by your site. If none, SQLT
still provides some basic information that can be used for initial SQL diagnostics. SQLT
如果您的站点具有许可证,则可以使用Oracle Diagnostics和/或Oracle Tuning Pack。这两个为该SQLT
工具提供了增强的功能。在SQLT
安装过程中,您可以指定两个软件包之一是否由您的站点许可。如果没有,则SQLT
仍提供一些可用于初始SQL诊断的基本信息。
During the installation of this SQLT
tool, 2 users and one role are created. These users and role have fixed names. 在安装此SQLT
工具期间,将创建2个用户和一个角色。这些用户和角色具有固定名称。
The SQLT
repository is owned by user SQLTXPLAIN
. SQLT
users need to provide the SQLTXPLAIN
password everytime they use any of the main methods. User SQLTXPLAIN
is granted the following system privileges: 该SQLT
存储库归用户SQLTXPLAIN
所有。SQLT
用户SQLTXPLAIN
每次使用任何主要方法时都需要提供密码。用户SQLTXPLAIN
被授予以下系统特权:
The SQLT
set of PL/SQL packages and Views is owned by user SQLTXADMIN
. This SQLTXADMIN
user is locked and identified by a random password. SQLTXADMIN
is granted the following system privileges: SQLT的
PL / SQL软件包和视图的集合由用户SQLTXADMIN
拥有。该用户SQLTXADMIN
已被锁定并由随机密码标识。SQLTXADMIN
被授予以下系统特权:
All SQLT
users must be granted the SQLT_USER_ROLE
before they can use any of the main methods. This SQLT_USER_ROLE
role is granted the following system privileges: SQLT
必须先授予所有用户SQLT_USER_ROLE
使用任何主要方法的权限。SQLT_USER_ROLE
授予该角色以下系统特权:
it is NOT recommended to use SYS or other DBA accounts to run the main methods as collections may fail. 不建议使用SYS或其他DBA帐户运行主要方法,因为收集可能会失败。
The best user to grant the SQLT_USER_ROLE
and run the main methods is the owner of the application. 授予SQLT_USER_ROLE
和运行主要方法的最佳用户是应用程序的所有者。
If it becomes imperative to use SYS or another DBA account then, in 12c it is necessary to do additional grants manually due to a change in the security model for PL/SQL. 如果必须使用SYS或另一个DBA帐户,则在12c中,由于PL/SQL的安全模型发生了更改,因此必须手动进行其他授予。
To address this change SQLTXADMIN
needs to be granded INHERIT PRIVILEGES
on SYS or the DBA account. 要解决此更改SQLTXADMIN
,必须INHERIT PRIVILEGES
在SYS或DBA帐户上进行。GRANT INHERIT PRIVILEGES ON USER SYS TO SQLTXADMIN
You can find more details in Oracle® Database PL/SQL Language Reference 12c Release 1 (12.1) - Invoker's Rights and Definer's Rights (AUTHID Property) and in Oracle® Database Security Guide 12c Release 1 (12.1) - Managing Security for Definer's Rights and Invoker's Rights
Again, it is NOT recommended to use SYS or DBA accounts to run the main methods.
SQLT
安装 SQLT
SQLT
installs under its own schemas SQLTXPLAIN
and SQLTXADMIN
. It does not install any objects into the application schema(s). You can install this version of SQLT
in Oracle databases 10.2, 11.1, 11.2 and higher, on UNIX, Linux or Windows platforms. SQLT
根据其自己的schemas安装SQLTXPLAIN
和SQLTXADMIN
。它不会在应用程序schemas中安装任何对象。您可以在UNIX,Linux或Windows平台上的Oracle数据库10.2、11.1、11.2和更高版本中安装此版本SQLT
。
Installation steps: 安装步骤
1. Uninstall a prior version (optional). 卸载先前版本(可选)。
This optional step removes all obsolete SQLTXPLAIN
/SQLTXADMIN
schema objects and prepares the environment for a fresh install. Skip this step if you want to preserve the existing content of the SQLT
repository (recommended). 此可选步骤将删除所有过时的SQLTXPLAIN
/ SQLTXADMIN
schema对象,并为全新安装准备环境。如果要保留SQLT
存储库的现有内容(建议),请跳过此步骤。
# cd sqlt/install
# sqlplus / as sysdba
SQL> START sqdrop.sql
2. Execute installation script sqlt/install/sqcreate.sql
connected as SYS
. 以SYS连接数据库执行安装脚本
# cd sqlt/install
# sqlplus / as sysdba
SQL> START sqcreate.sql
During the installation you will be asked to enter values for these parameters: 在安装过程中,将要求您输入以下参数的值:
1. Optional Connect Identifier (mandatory when installing in a Pluggable Database) 可选的连接标识符(在PDB数据库中安装时必选)
In some restricted-access systems you may need to specify a connect identifier like @PROD
. If a connect identifier is not needed, enter nothing and just hit the "Enter" key. Entering nothing is the most common setup. 在某些限制访问的系统中,您可能需要指定一个连接标识符,例如 @PROD
。如果不需要连接标识符,则不输入任何内容,只需按"Enter"键。不输入任何内容是最常见的设置。
The Connect Identifier is a mandatory parameter when installing SQLT in a Pluggable Database. 在PDB数据库中安装SQLT时,连接标识符是必填参数。
2. SQLTXPLAIN
password. 设置密码
Case sensitive in most systems. 在大多数系统中,区分大小写。
3. SQLTXPLAIN
Default Tablespace. 设置默认表空间
Select from a list of available permanent tablespaces which one should be used by SQLTXPLAIN
for the SQLT
repository. It must have more than 50MB of free space. 使用可用的永久表空间作为SQLT
存储库。它必须具有50MB以上的可用空间。
4. SQLTXPLAIN
Temporary Tablespace. 设置临时表空间
Select from a list of available temporary tablespaces which one should be used by SQLTXPLAIN
for volatile operations and objects. 从可用的临时表空间列表中进行选择,这些表空间应用于SQLTXPLAIN
的volatile operations and objects。
5. Optional Application User. 设置用户
This is the user that issued the SQL statement to be analyzed. For example, if this were an EBS system specify APPS
, on Siebel you would specify SIEBEL
and on People Soft SYSADM
. You won't be asked to enter the password for this user. You can add additional SQLT
users after the tool is installed, by granting them role SQLT_USER_ROLE
. 这是发出要分析的SQL语句的用户。例如,如果这是EBS系统APPS
,则在Siebel上指定,SIEBEL
并在People Soft上指定SYSADM
。您将不会被要求输入该用户的密码。您可以SQLT
在安装工具后通过授予其他用户角色来添加其他用户SQLT_USER_ROLE
。
6. Licensed Oracle Pack. (T, D or N) 设置 许可
You can specify T
for Oracle Tuning, D
for Oracle Diagnostic or N
for none. If T
or D
is selected, SQLT
may include licensed content within the diagnostics files it produces. Default is T
. If N
is selected, SQLT
installs with limited functionality. 您可以指定 T
for Oracle Tuning, D
for Oracle Diagnostic or N
for none。如果选择T
或D
,则SQLT
可能在其生成的诊断文件中包括许可的内容。默认值为T
。如果N
选择,则SQLT
安装功能受限。
If a silent installation is desired, there are three options to pass all 6 installation parameters: 如果需要静默安装,则可以通过三个选项来传递所有6个安装参数:
1. In a file. 在第一个文件中
Executing first a script with pre-defined values, similar to sample script sqlt/install/sqdefparams.sql
. Then use sqlt/install/sqcsilent.sql
instead of sqlt/install/sqcreate.sql
. 首先执行具有预定义值的脚本,类似于示例脚本 sqlt/install/sqdefparams.sql
。然后使用sqlt/install/sqcsilent.sql
代替sqlt/install/sqcreate.sql
# cd sqlt/install
# sqlplus / as sysdba
SQL> START sqdefparams.sql
SQL> START sqcsilent.sql
2. In-line.
Executing sqlt/install/sqcsilent2.sql
instead of sqlt/install/sqcreate.sql
. The former inputs the same 6 installation parameters but in-line. 执行sqlt/install/sqcsilent2.sql
而不是sqlt/install/sqcreate.sql
。输入相同的6个安装参数,但都是串联的。
# cd sqlt/install
# sqlplus / as sysdba
SQL> START sqcsilent2.sql '' sqltxplain USERS TEMP '' T
3. Internal installation at Oracle.
Executing sqlt/install/sqcinternal.sql
instead of sqlt/install/sqcreate.sql
. The former executes sqlt/install/sqdefparams.sql
followed by sqlt/install/sqcsilent.sql
.
# cd sqlt/install
# sqlplus / as sysdba
SQL> START sqcinternal.sql
f you need further help with install issues, you can get help in the following community thread: SQLTXPLAIN: SQLT Installation Issues
If you have an installation error you can refer to Stelios Charalambides - [email protected] (primary contact)
SQLT 卸载
Uninstalling SQLT
removes the SQLT
repository and all SQLTXPLAIN
/SQLTXADMIN
schema objects. SQLTXPLAIN
and SQLTXADMIN
users also gets dropped. To uninstall SQLT
simply execute sqlt/install/sqdrop.sql
connected as SYS
. 卸载SQLT
将删除SQLT
存储库和所有SQLTXPLAIN
/ SQLTXADMIN
schema对象。SQLTXPLAIN
并且SQLTXADMIN
用户也被drop。要卸载SQLT
只需用SYS连接数据库执行sqlt/install/sqdrop.sql
# cd sqlt/install
# sqlplus / as sysdba
SQL> START sqdrop.sql
SQLT 升级
If you have a prior version of SQLT
already installed in your system, you can upgrade SQLT
to its latest version while partially preserving most objects of your existing SQLT
repository. The new migrated SQLT
repository can then be used to restore CBO statistics or to perform a COMPARE between old and new executions of SQLT
. 如果您SQLT
已经在系统中安装了先前版本,则可以升级SQLT
到最新版本,同时保留现有SQLT
存储库的大多数对象。然后,新迁移的SQLT
存储库可用于还原CBO统计信息或在的新旧执行之间进行比较SQLT
。
To upgrade SQLT
, simply do an installation without performing the optional uninstall step. 要升级SQLT
,只需执行安装即可,而无需执行可选的卸载步骤。
If the upgrade fails, then it is possible the prior SQLT
version was too old to be upgraded. In such case please proceed to uninstall SQLT
first, followed by a clean installation. 如果升级失败,则可能是先前SQLT
版本过旧而无法升级。在这种情况下,请先进行卸载 SQLT
,然后再进行全新安装。
Refer to MOS Doc ID:1454160.1. 或参考文章:https://blog.csdn.net/u010692693/article/details/102981665
Before attempting using any of the SQLT
main methods, be sure SQLT
has been installed and that your SQLT
user has been granted the SQLT_USER_ROLE
. 在尝试使用任何SQLT
主要方法之前,请确保SQLT
已安装并且您的SQLT
用户已被授予SQLT_USER_ROLE
。
If SQLT has been installed bypassing SQL*Net (meaning that you did not input any value for the Connect Identifier during the installation), then prior to running any of the SQLT main methods from a remote client, you will need to manually set the connect_identifier parameter. Ie. if you connected using sqlplus scott/tiger@myprod then you will need to execute: EXEC sqltxadmin.sqlt$a.set_sess_param('connect_identifier', '@myprod'); 如果已绕过SQL*Net来安装SQLT(这意味着在安装过程中未为Connect Identifier输入任何值),则在从远程客户端运行任何SQLT main方法之前,您将需要手动设置connect_identifier参数。就是 如果使用sqlplus scott/tiger@myprod连接,则需要执行:EXEC sqltxadmin.sqlt$a.set_sess_param('connect_identifier', '@myprod');
SQLT
provides 7 main methods that generate diagnostics details for one SQL statement: XTRACT, XECUTE, XTRXEC, XTRSBY, XPLAIN, XPREXT and XPREXC. While XTRACT, XECUTE, XTRXEC, XTRSBY, XPREXT and XPREXC handle bind variables and understand about bind peeking, XPLAIN does not. This is because XPLAIN is based on the EXPLAIN PLAN FOR
command which is blind to bind peeking. For this reason avoid using XPLAIN if possible. SQLT
提供7种主要方法来为一个SQL语句生成诊断详细信息。除了XPLAIN,其他方法都能处理绑定变量并了解绑定窥视,这是因为XPLAIN基于EXPLAIN PLAN FOR
。因此,请尽可能避免使用XPLAIN。
Besides the bind peeking limitation on XPLAIN all 7 main methods provide enough diagnostics details to make an initial assessment of a SQL performing poorly or generating wrong results. If the SQL still resides in memory or in the Automatic Workload Repository (AWR
) use then XTRACT or XTRXEC, else use XECUTE. For Data Guard or standby read-only databases use XTRSBY. Use XPLAIN only if the other methods are not feasible. XPREXT and XPREXC are similar to XTRACT and XECUTE but they disable some SQLT
features in order to improve SQLT
performance. 除了XPLAIN上的绑定窥视限制外,所有7种主要方法都提供了足够的诊断详细信息,可以对性能不佳或产生错误结果的SQL进行初步评估。如果SQL仍驻留在内存中或自动工作负载存储库(AWR
)中,则使用XTRACT或XTRXEC,否则使用XECUTE。对于Data Guard或备用只读数据库,请使用XTRSBY。仅在其他方法不可行时才使用XPLAIN。XPREXT和XPREXC类似于XTRACT和XECUTE但他们禁用一些SQLT
,以提高功能SQLT
性能。
Use this method if you know the SQL_ID
or the HASH_VALUE
of the SQL to be analyzed, else use XECUTE. The SQL_ID
can be found on an AWR
report, and the HASH_VALUE
on any SQL Trace (above the SQL text and identified by the "hv=" token). 如果您知道要分析的SQL的 SQL_ID
或HASH_VALUE时
请使用此方法,否则请使用XECUTE。SQL_ID
可在AWR
报告中找到,HASH_VALUE
在任何SQL Trace中找到。
If the SQL is still in memory, or it has been captured by AWR
, then XPREXT finds it and provides a set of diagnostics files, else XPREXT errors out. 如果SQL仍在内存中,或者已被捕获AWR
,则XPREXT将找到它并提供一组诊断文件,否则XPREXT错误会消失。
Important performance statistics, like actual number of rows per execution plan operation, will be available if the SQL was parsed while parameter STATISTICS_LEVEL
was set to ALL
when the SQL was hard-parsed. You can also produce same valuable performance statistics by including the following CBO hint in your SQL: /*+ GATHER_PLAN_STATISTICS */
. On 11g you may want your SQL to contain the following CBO Hints for enhanced diagnostics: /*+ GATHER_PLAN_STATISTICS MONITOR */
. Please remember that adding those hints will change the SQL ID and it will prevent SQLT from being able to extract valuable historical information. If it's acceptable to run the SQL then method XPREXC should be used instead. 如果将参数STATISTICS_LEVEL
设置为ALL
,SQL解析为硬解析时,则重要的性能统计信息(如每个执行计划操作的实际行数)将可用。您还可以通过在SQL中包含以下CBO提示来产生同样有价值的性能统计信息:/*+ GATHER_PLAN_STATISTICS */
。在11g上,您可能希望您的SQL包含以下CBO提示以增强诊断功能:/*+ GATHER_PLAN_STATISTICS MONITOR */
。请记住,添加这些提示将更改SQL ID,并且将阻止SQLT提取有价值的历史信息。如果可以运行SQL,则应改用XPREXC方法。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XPREXT. 使用此方法时,它要求输入SQLTXPLAIN
密码,以便导出SQLT
与此XPREXT执行相对应的存储库。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use this XPREXT method, be sure SQLT
has been installed first, then connect into SQL*Plus as the application user that executed the SQL to be analyzed and execute the sqlt/run/sqltxtract.sql
script passing the SQL_ID
or HASH_VALUE
. 要使用此XPREXT方法,请确保SQLT
已先安装,然后以执行要分析的SQL的应用程序用户身份连接到SQL * Plus,并执行SQL_ID或
HASH_VALUE
的脚本sqlt/run/sqltxtract.sql
# cd sqlt/run
# sqlplus apps
SQL> START sqltxtract.sql [SQL_ID]|[HASH_VALUE] [sqltxplain_password]
SQL> START sqltxtract.sql 0w6uydn50g8cx sqltxplain_password
SQL> START sqltxtract.sql 2524255098 sqltxplain_password
This method provides more detail than XTRACT. As the name XECUTE implies, it executes the SQL being analyzed, then it produces a set of diagnostics files. Its major drawback is that if the SQL being analyzed takes long to execute, this method will also take long. 该方法比XTRACT提供更多细节。顾名思义,XECUTE分析正在执行的SQL,然后生成一组诊断文件。它的主要缺点是,如果要分析的SQL执行需要很长时间,则此方法也将花费很长时间。
As a rule of thumb, use this method only if the SQL takes less than 1hr to execute, else use XTRACT. 根据经验,仅当SQL执行时间少于1小时时才使用此方法,否则请使用XTRACT。
Before you can use this XECUTE method, you have to create a text file that contains your SQL text. If the SQL includes bind variables, your file must contain the bind variable declaration and assignment. Use sqlt/input/sample/script1.sql
as an example. Your SQL should contain the token /* ^^unique_id */
which should be spelled out exactly as it shows here. In other words: please do not change it. 在使用此XECUTE方法之前,您必须创建一个包含SQL文本的text文件。如果SQL包含绑定变量,则您的文件必须包含绑定变量声明和赋值。使用sqlt/input/sample/script1.sql
作为一个例子。您的SQL应该包含令牌/* ^^unique_id */
,该令牌的含义应与此处显示的完全相同。换句话说:请不要更改它。
If your SQL requires binds with data types not allowed by SQL*Plus, or if it uses collections, you may be restricted to embed your SQL into an anonymous PL/SQL block. In such case use sqlt/input/sample/plsql1.sql
as an input example to this method. 如果您的SQL要求使用SQL* Plus不允许的数据类型进行绑定,或者如果它使用集合,则可能会限制将SQL嵌入到匿名PL/SQL块中。在这种情况下,请使用sqlt/input/sample/plsql1.sql
作为方法的输入示例。
For statements that modify data, i.e. INSERT/UPDATE/DELETE, a savepoint is created prior to statement execution and the transaction is rolled back to the savepoint at the conclusion of the session. For further information regarding SAVEPOINT please consult the Oracle Concepts reference manual. 对于修改数据的语句,即INSERT/UPDATE/DELETE,在执行语句之前创建一个保存点,并且在会话结束时将事务回滚到该保存点。有关SAVEPOINT的更多信息,请查阅Oracle Concepts参考手册。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XECUTE. 使用此方法时,它将要求输入SQLTXPLAIN
密码,以导出与SQLT
XECUTE的此执行相对应的存储库。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use the XECUTE method, be sure SQLT
has been installed first, then connect into SQL*Plus as the application user that executed the SQL to be analyzed and execute the sqlt/run/sqltxecute.sql
script passing the name of the text file that contains your SQL text and its bind variables. You may want to place this file into the sqlt/input
directory and run XECUTE while standing on the sqlt main directory, as shown below. 要使用XECUTE方法,请确保SQLT
已先安装,然后以执行要分析的SQL的应用程序用户身份连接到SQL* Plus,并执行脚本sqlt/run/sqltxecute.sql
,该脚本传递包含SQL文本及其绑定变量的文本文件的名称。您可能希望将此文件放到目录中,并在sqlt/input
主目录上运行XECUTE,如下所示。
# cd sqlt
# sqlplus apps
SQL> START [path]sqltxecute.sql [path]scriptname [sqltxplain_password]
SQL> START run/sqltxecute.sql input/sample/script1.sql sqltxplain_password
This method combines the features of XTRACT and XECUTE. Actually, XTRXEC executes both methods serially. The XTRACT phase generates a script that contains the extracted SQL together with the binds declaration and assignment for an expensive plan found for the requested SQL statement. XTRXEC then executes the XECUTE phase using the script created by the first. 该方法结合了XTRACT和XECUTE的功能。实际上,XTRXEC串行执行两种方法。XTRACT阶段生成一个脚本,其中包含提取的SQL以及绑定声明和为请求的SQL语句找到的昂贵计划的分配。 然后XTRXEC使用第一个创建的脚本执行XECUTE阶段。
The selection of the values of the bind variables used by XTRACT to create the script is based on the peeked values at the moment the most expensive plans in memory were generated. Expensive plans are selected according to their average elapsed time. XTRACT用于创建脚本的绑定变量的值的选择基于生成内存中最昂贵的计划时的peeked值。根据平均花费的时间来选择昂贵的计划。
If XTRXEC errors out having executed only the 1st phase (XTRACT), you may need to review the script used during the 2nd phase (XECUTE) and adjust the bind variables accordingly. This is specially true when uncommon data types are used. 如果XTRXEC在仅执行第一阶段(XTRACT)时出错,则可能需要查看在第二阶段(XECUTE) 中使用的脚本,并相应地调整绑定变量。当使用不常见的数据类型时,尤其如此。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XTRXEC. 使用此方法时,它将要求输入SQLTXPLAIN
密码,以便导出SQLT
与此XTRXEC执行相对应的存储库。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use this XTRXEC method, be sure SQLT
has been installed first, then connect into SQL*Plus as the application user that executed the SQL to be analyzed and execute the sqlt/run/sqltxtrxec.sql
script passing the SQL_ID
or HASH_VALUE
. 要使用此XTRXEC方法,请确保SQLT
已先安装,然后以执行要分析的SQL的应用程序用户身份连接到SQL * Plus,并执行SQL_ID
or HASH_VALUE
的脚本sqlt/run/sqltxtrxec.sql
# cd sqlt/run
# sqlplus apps
SQL> START sqltxtrxec.sql [SQL_ID]|[HASH_VALUE] [sqltxplain_password]
SQL> START sqltxtrxec.sql 0w6uydn50g8cx sqltxplain_password
SQL> START sqltxtrxec.sql 2524255098 sqltxplain_password
Use this method if you need to analyze a SQL executed on a Data Guard or stand-by read-only database. You need to know the SQL_ID
or the HASH_VALUE
of the SQL to be analyzed. 如果您需要分析在Data Guard或备用只读数据库上执行的SQL,请使用此方法。你需要知道的SQL_ID
或HASH_VALUE
的SQL进行分析。
Create on Primary database a link to read-only database connecting as any user that has access to the data dictionary. A DBA account would be fine: 在主数据库上创建指向只读数据库的链接,该链接以有权访问数据字典的任何用户身份连接。DBA帐户可以:
CREATE PUBLIC DATABASE LINK V1123 CONNECT TO mydba IDENTIFIED by mydba_password
USING '(DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)
(HOST=coesrv14.us.oracle.com)(PORT=1521))(CONNECT_DATA=(SID = V1123)))';
If the remote account cannot be a DBA account you will have to add additional grants as per document "Required Grants for the DB Link to Standby for SQLT XTRSBY Method (Doc ID 2450388.1)" (Internal document) 如果远程帐户不能是DBA帐户,则必须按照文档"Required Grants for the DB Link to Standby for SQLT XTRSBY Method (Doc ID 2450388.1)"(内部文件)中添加其他授予
If the SQL is still in memory in the read-only database, then XTRSBY finds it and provides a set of diagnostics files, else XTRSBY errors out. 如果SQL在只读数据库的内存中,则XTRSBY会找到它并提供一组诊断文件,否则XTRSBY会出错。
Important performance statistics, like actual number of rows per execution plan operation, will be available if the SQL was parsed while parameter STATISTICS_LEVEL
was set to ALL
when the SQL was hard-parsed in the read-only database. You can also produce same valuable performance statistics by including the following CBO hint in your SQL: /*+ GATHER_PLAN_STATISTICS */
. On 11g you may want your SQL to contain the following CBO Hints for enhanced diagnostics: /*+ GATHER_PLAN_STATISTICS MONITOR */
如果将参数STATISTICS_LEVEL
设置为ALL
,SQL解析为在只读数据库中对SQL进行硬解析时,则重要的性能统计信息(如每个执行计划操作的实际行数)将可用。您还可以通过在SQL中包含以下CBO提示来产生同样有价值的性能统计信息:/*+ GATHER_PLAN_STATISTICS */
。在11g上,您可能希望您的SQL包含以下CBO提示以增强诊断功能:/*+ GATHER_PLAN_STATISTICS MONITOR */
。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XTRSBY. 使用此方法时,它将要求输入SQLTXPLAIN
密码,以便导出SQLT
与此XTRSBY执行相对应的存储库。
XTRSBY takes 3 parameters: the SQL id, the DB_LINK id, and the SQLTXPLAIN
password. XTRSBY具有3个参数:SQL ID,DB_LINK ID和SQLTXPLAIN
密码。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use this XTRSBY method, be sure SQLT
has been installed on the Primary first, and replicated into the read-only database. Then connect into SQL*Plus in Primary and execute the sqlt/run/sqltxtrsby.sql
script passing the SQL_ID
or HASH_VALUE
followed by the DB_LINK
. 要使用此XTRSBY方法,请确保SQLT
已先安装在主数据库上,然后将其复制到只读数据库中。然后连接到Primary中的SQL * Plus,并通过SQL_ID
HASH_VALUE
DB_LINK
执行脚本sqlt/run/sqltxtrsby.sql
# cd sqlt/run
# sqlplus apps
SQL> START sqltxtrsby.sql [SQL_ID]|[HASH_VALUE] [sqltxplain_password] [DB_LINK]
SQL> START sqltxtrsby.sql 0w6uydn50g8cx sqltxplain_password V1123
SQL> START sqltxtrsby.sql 2524255098 sqltxplain_password v1123
In addition to XTRSBY you may want to execute sqlt/utl/sqlhc.sql
or sqlt/utl/sqlhcxec.sql
directly from the read-only database. These two read-only scripts do not install anything on the database nor they execute DML commands. They provide additional information that is not available in XTRSBY. 除了XTRSBY,您可能还想直接从只读数据库执行sqlt/utl/sqlhc.sql
or sqlt/utl/sqlhcxec.sql
。这两个只读脚本不会在数据库上安装任何内容,也不会执行DML命令。它们提供XTRSBY中没有的其他信息。
This method is based on the EXPLAIN PLAN FOR
command, therefore it is blind to bind variables referenced by your SQL statement. Use this method only if XTRACT or XECUTE are not possible. 此方法基于EXPLAIN PLAN FOR
命令,因此无法绑定SQL语句引用的变量。仅当不能使用XTRACT或XECUTE时才使用此方法。
Before using the XPLAIN method, you have to create a text file that contains your SQL text. If the SQL includes bind variables, you have two options: leave the SQL text "as is", or carefully replace the binds with literals of the same datatype. Use sqlt/input/sample/sql1.sql
as an example. 在使用XPLAIN方法之前,您必须创建一个包含SQL文本的文本文件。如果SQL包含绑定变量,则有两个选择:保留SQL文本为“原样”,或小心地将绑定替换为相同数据类型的文字。使用sqlt/input/sample/sql1.sql
作为一个例子。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XPLAIN. 使用此方法时,它会要求输入SQLTXPLAIN
密码,以导出SQLT
与此XPLAIN执行相对应的存储库。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use this XPLAIN method, be sure SQLT
has been installed first, then connect into SQL*Plus as the application user that executed the SQL to be analyzed and execute the sqlt/run/sqltxplain.sql
script passing the name of the text file that contains your SQL text. You may want to place this file into the sqlt/input directory and run XPLAIN while standing on the sqlt main directory, as shown below. 要使用此XPLAIN方法,请确保SQLT
已先安装,然后以执行要分析的SQL的应用程序用户身份连接到SQL * Plus,并执行传递包含SQL文本的文本文件名称的脚本sqlt/run/sqltxplain.sql
。您可能希望将此文件放置在sqlt / input目录中,并站在sqlt主目录上时运行XPLAIN,如下所示。
# cd sqlt
# sqlplus apps
SQL> START [path]sqltxplain.sql [path]filename [sqltxplain_password]
SQL> START run/sqltxplain.sql input/sample/sql1.sql sqltxplain_password
Use this method if you have used XTRACT and you need a faster execution of SQLT
while disabling some SQLT
features. Script sqlt/run/sqltcommon11.sql
shows which features are disabled. 如果您使用过XTRACT,并且SQLT
在禁用某些SQLT
功能时需要更快的执行速度,请使用此方法。脚本sqlt/run/sqltcommon11.sql
显示禁用了哪些功能。
Use this method if you know the SQL_ID
or the HASH_VALUE
of the SQL to be analyzed, else use XPREXC. The SQL_ID
can be found on an AWR
report, and the HASH_VALUE
on any SQL Trace (above the SQL text and identified by the "hv=" token). 如果您知道要分析SQL的 SQL_ID
或HASH_VALUE
,否则请使用XPREXC。可在AWR
报告找到SQL_ID
,并且在任何SQL Trace找到HASH_VALUE
。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XPREXT. 使用此方法时,它要求输入SQLTXPLAIN
密码,以便导出SQLT
与此XPREXT执行相对应的存储库。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use this XPREXT method, be sure SQLT
has been installed first, then connect into SQL*Plus as the application user that executed the SQL to be analyzed and execute the sqlt/run/sqltxprext.sql
script passing the SQL_ID
or HASH_VALUE
. 要使用此XPREXT方法,请确保SQLT
已先安装,然后以执行要分析的SQL的应用程序用户身份连接到SQL * Plus,并执行SQL_ID
HASH_VALUE
脚本sqlt/run/sqltxprext.sql
。
# cd sqlt/run
# sqlplus apps
SQL> START sqltxprext.sql [SQL_ID]|[HASH_VALUE] [sqltxplain_password]
SQL> START sqltxprext.sql 0w6uydn50g8cx sqltxplain_password
SQL> START sqltxprext.sql 2524255098 sqltxplain_password
Use this method if you have used XECUTE and you need a faster execution of SQLT
while disabling some SQLT
features. Script sqlt/run/sqltcommon11.sql
shows which features are disabled. 如果您使用过XECUTE,并且SQLT
在禁用某些SQLT
功能时需要更快的执行速度,请使用此方法。脚本sqlt/run/sqltcommon11.sql
显示禁用了哪些功能。
As a rule of thumb, use this method only if the SQL takes less than 1hr to execute, else use XPREXT. 根据经验,仅当SQL执行时间少于1小时时才使用此方法,否则请使用XPREXT。
Before you can use this XPREXC method, you have to create a text file that contains your SQL text. If the SQL includes bind variables, your file must contain the bind variable declaration and assignment. Use sqlt/input/sample/script1.sql
as an example. Your SQL should contain the token /* ^^unique_id */
which should be spelled out exactly as it shows here. In other words: please do not change it. 在使用此XPREXC方法之前,您必须创建一个包含SQL文本的文本文件。如果SQL包含绑定变量,则您的文件必须包含绑定变量声明和赋值。使用sqlt/input/sample/script1.sql
作为一个例子。您的SQL应该包含令牌/* ^^unique_id */
,该令牌的含义应与此处显示的完全相同。换句话说:请不要更改它。
If your SQL requires binds with data types not allowed by SQL*Plus, or if it uses collections, you may be restricted to embed your SQL into an anonymous PL/SQL block. In such case use sqlt/input/sample/plsql1.sql
as an input example to this method. 如果您的SQL要求使用SQL * Plus不允许的数据类型进行绑定,或者如果它使用集合,则可能会限制将SQL嵌入到匿名PL / SQL块中。在这种情况下,请用sqlt/input/sample/plsql1.sql
作此方法的输入示例。
For statements that modify data, i.e. INSERT/UPDATE/DELETE, a savepoint is created prior to statement execution and the transaction is rolled back to the savepoint at the conclusion of the session. For further information regarding SAVEPOINT please consult the Oracle Concepts reference manual. 对于修改数据的语句,即INSERT / UPDATE / DELETE,在执行语句之前创建一个保存点,并且在会话结束时将事务回滚到该保存点。有关SAVEPOINT的更多信息,请查阅Oracle Concepts参考手册。
When this method is used, it asks for the SQLTXPLAIN
password, which is needed to export the SQLT
repository corresponding to this execution of XPREXC. 使用此方法时,它将要求输入SQLTXPLAIN
密码,以导出SQLT
与此XPREXC的执行相对应的存储库。
This method requires the application user executing SQLT
to be granted the SQLT_USER_ROLE
role. 此方法要求执行的应用程序用户SQLT
被授予SQLT_USER_ROLE
角色。
To use the XPREXC method, be sure SQLT
has been installed first, then connect into SQL*Plus as the application user that executed the SQL to be analyzed and execute the sqlt/run/sqltxprexc.sql
script passing the name of the text file that contains your SQL text and its bind variables. You may want to place this file into the sqlt/input
directory and run XPREXC while standing on the sqlt main directory, as shown below. 要使用XPREXC方法,请确保SQLT
已先安装,然后以执行要分析的SQL的应用程序用户身份连接到SQL * Plus,并执行脚本sqlt/run/sqltxprexc.sql
,并传递包含SQL文本及其绑定变量的文本文件的名称。您可能希望将此文件放到目录sqlt/input
中,然后站在sqlt主目录上运行XPREXC,如下所示。
# cd sqlt
# sqlplus apps
SQL> START [path]sqltxprexc.sql [path]scriptname [sqltxplain_password]
SQL> START run/sqltxprexc.sql input/sample/script1.sql sqltxplain_password
Besides the main methods SQLT
provides some special methods. 除主要方法 外,SQLT
还提供了一些特殊的方法。
The most popular special method is COMPARE. This method takes as input two prior executions of SQLT
(any of the main methods) and produces a report with a gap analysis. 最受欢迎的特殊方法是COMPARE。此方法将SQLT
(任何主要方法的)两个先前执行作为输入,并生成带有gap分析的报告。
The other special methods are: TRCANLZR, TRCAXTR, TRCASPLIT and XTRSET. The first three act on a SQL Trace and the latter on a set of SQL statements. 其他特殊方法。前三个作用于SQL跟踪,后三个作用于一组SQL语句。
Use this COMPARE method when you have two similar systems (SOURCES) and the same SQL statement performs fine in one of them but not in the other. This method helps to pin-point the differences between the two SOURCES in terms of plans, metadata, CBO statistics, initialization parameters and bug fix-control. SQLT
has to be installed first in both, and any of the main methods must have been used on the same SQL in both systems. 当您有两个相似的系统(SOURCES)并且相同的SQL语句在其中一个系统中执行得很好,而在另一个系统中却没有执行时,请使用此COMPARE方法。此方法有助于从计划,元数据,CBO统计信息,初始化参数和错误修复控制方面查明两个SOURCES之间的差异。SQLT
必须首先在两个系统中都安装,并且两个系统中的同一SQL上都必须使用任何主要方法。
The compare can take place on any of the two SOURCES or on a 3rd COMPARE system. The latter should contain the SQLT
repositories of the two SOURCES. To import a SQLT
repository use the syntax provided in the sqlt_*_readme.html file generated by any of the main methods. 比较可以在两个SOURCES中的任何一个或在第3个COMPARE系统上进行。后者应包含SQLT
两个SOURCES 的存储库。要导入SQLT
存储库,请使用任何主要方法生成的sqlt _ * _ readme.html文件中提供的语法。
Once the COMPARE system contains the repositories from both SOURCES, execute sqlt/run/sqltcompare.sql
connecting as SYS
or the application user. A list of STATEMENT_ID
is presented, from which you choose which two SQLT
stored executions you want to compare. Once you indicate the two STATEMENT_ID
you are asked next for particular PLAN_HASH_VALUE
from both SOURCES. 一旦COMPARE系统包含来自两个SOURCES的存储库,请以SYS或应用程序用户的身份连接执行sqlt/run/sqltcompare.sql
。出现一个STATEMENT_ID
列表,您可以从中选择要比较的两个STATEMENT_ID
存储的执行。指出两者后,接下来将要求两个来源提供PLAN_HASH_VALUE
特定信息。
# cd sqlt
# sqlplus sqltxplain
SQL> START [path]sqltcompare.sql [STATEMENT_ID 1] [STATEMENT_ID 2]
SQL> START run/sqltcompare.sql 92263 72597
SQL> START run/sqltcompare.sql
This method takes as input a SQL Trace filename and proceeds to analyze this file. The actual trace must be located in the TRCA$INPUT1
directory, which defaults to the USER_DUMP_DEST
directory during installation. 此方法将SQL Trace文件名作为输入,然后继续分析该文件。实际Trace必须位于TRCA$INPUT1
目录中,该USER_DUMP_DEST
目录在安装期间为默认目录。
The TRCANLZR method also has the capability of analyzing simultaneously several related traces, treating them as a set. This functionality is needed when analyzing parallel execution PX traces. In such case, create a control.txt
file with a list of traces (one filename per line and without path specification) and place this control.txt
into the TRCA$INPUT1
or TRCA$INPUT2
directories. These two directories default to USER_DUMP_DEST
and BACKGROUND_DUMP_DEST
respectively during installation. TRCANLZR will then read the control.txt
file from one of the two input directories, and it will find the set of traces in either one of those two directories. TRCANLZR 方法还具有同时分析多个相关Trace并将它们合并的能力。分析并行执行PX跟踪时,需要此功能。在这种情况下,请创建一个control.txt
具有Trace列表的文件(每行一个文件名,并且不指定路径),然后将其control.txt
放入TRCA$INPUT1或
TRCA$INPUT2
目录中。这两个目录在安装过程中分别默认为USER_DUMP_DEST
和BACKGROUND_DUMP_DEST
。然后,TRCANLZR将从两个输入目录之一中读取文件control.txt
,并在这两个目录中的一个目录中找到跟踪集。
TRCANLZR is like TKPROF
but with extended functionality. When it analyzes a trace or a set of traces, it also includes schema object characteristics like CBO statistics and some other valuable performance metrics. TRCANLZR与TKPROF
类似,但具有扩展的功能。当它分析一个Trace或一组Trace时,它还包括schema对象特征,例如CBO统计信息和一些其他有价值的性能指标。
To use this TRCANLZR method, be sure SQLT
has been installed first. Then, start SQL*Plus connecting as the application user that generated the trace and execute the sqlt/run/sqltrcanlzr.sql
script passing the name of the trace to be analyzed, or the name of the control.txt
file populated with filenames. Do not include any path specification. 要使用此TRCANLZR方法,请确保SQLT
已首先安装。然后,以生成跟踪的应用程序用户身份启动SQL * Plus连接,并执行脚本sqlt/run/sqltrcanlzr.sql
以传递要分析的跟踪的名称或填充了文件名的文件的名称control.txt
。不包括任何路径规范。
# cd sqlt
# sqlplus [application_user]
SQL> START [path]sqltrcanlzr.sql [SQL Trace filename|control.txt]
SQL> START run/sqltrcanlzr.sql V1122_ora_24292.trc
SQL> START run/sqltrcanlzr.sql control.txt
This method does the same than TRCANLZR but when the trace analysis completes, it continues with a XTRACT for the Top SQL found in the trace. Basically it consolidates all the generated reports by TRCANLZR and XTRACT on the Top SQL. 此方法的功能与TRCANLZR相同,但是在跟踪分析完成后,它将继续对跟踪中找到的Top SQL 使用XTRACT。基本上,它会合并Top SQL上TRCANLZR和XTRACT生成的所有报告。
To use this TRCAXTR method, be sure SQLT
has been installed first. Then, navigate to the sqlt/run
directory and start SQL*Plus connecting as the application user that generated the trace. From there, execute the sqlt/run/sqltrcaxtr.sql
script passing the name of the trace to be analyzed, or the name of the control.txt
file populated with filenames. Do not include any path specification. 要使用此TRCAXTR方法,请确保SQLT
已首先安装。然后,导航到该sqlt/run
目录并以生成跟踪的应用程序用户身份开始SQL * Plus连接。从那里执行脚本sqlt/run/sqltrcaxtr.sql
,传递要分析的跟踪的名称或填充文件名的文件的名称control.txt
。不包括任何路径规范。
# cd sqlt/run
# sqlplus [application_user]
SQL> START sqltrcaxtr.sql [SQL Trace filename|control.txt]
SQL> START sqltrcaxtr.sql V1122_ora_24292.trc
SQL> START sqltrcaxtr.sql control.txt
This method takes as input a SQL Trace filename which was created by EVENT 10046 and some other EVENT(s) (usually 10053). Then it proceeds to split this input trace file into two output files. One with the trace lines corresponding to EVENT 10046 and the other with its complement. In other words, the second file contains those trace lines that are not part of the EVENT 10046 grammar. So if the input trace was created using simultaneously EVENT 10046 and EVENT 10053, the resulting output files would be the 10046 trace and the 10053 trace. The actual input trace must be located in the TRCA$INPUT1
directory, which defaults to the USER_DUMP_DEST
directory during installation. 此方法将由事件10046和其他事件(通常为10053)创建的SQL跟踪文件名作为输入。然后,它将这个输入跟踪文件分成两个输出文件。一个带有对应于EVENT 10046的走线,另一个带有其补码。换句话说,第二个文件包含不属于EVENT 10046语法一部分的那些跟踪行。因此,如果输入跟踪是同时使用EVENT 10046和EVENT 10053创建的,则输出文件将是10046跟踪和10053跟踪。实际的输入跟踪必须位于TRCA$INPUT1
目录中,该USER_DUMP_DEST
目录在安装期间默认为目录。
To use this TRCASPLIT method, be sure SQLT
has been installed first. Then, start SQL*Plus connecting as any SQLT
user and execute the sqlt/run/sqltrcasplit.sql
script passing the name of the trace to be splitted. Do not include any path specification. 要使用此TRCASPLIT方法,请确保SQLT
已先安装。然后,以任何SQLT
用户身份启动SQL * Plus连接,并执行脚本sqlt/run/sqltrcasplit.sql
以传递要拆分的跟踪名称。不包括任何路径规范。
# cd sqlt
# sqlplus [sqlt_user]
SQL> START [path]sqltrcasplit.sql [SQL Trace filename]
SQL> START run/sqltrcasplit.sql V1122_ora_24292.trc
The XTRSET extracts from memory or AWR
a list of SQL statements identified by their SQL_ID
or HASH_VALUE
then it executes the XTRACT on each of the SQL statements. At the end it consolidates all the SQLT
files into a single compressed file. This XTRSET is used when benchmarking the same set of SQL statements over a series of tests. 从内存中提取XTRSET或AWR
由他们确定的SQL语句列表SQL_ID
或HASH_VALUE
然后执行XTRACT在每个SQL语句。最后,它将所有SQLT
文件合并为一个压缩文件。通过一系列测试对同一组SQL语句进行基准测试时,将使用此XTRSET。
When this method is used, it asks once for the SQLTXPLAIN
password, which is needed to export the SQLT
repository for each execution of XTRACT on the list of SQL statements. 使用此方法时,它会询问一次SQLTXPLAIN
密码,这对于导出SQL语句列表上的XTRACT的SQLT
每次执行都需要导出存储库。
To use this XTRSET method, SQLT
has to be installed first. Navigate to the sqlt/run
directory and start SQL*Plus connecting as the application user that issued all or most of the SQL statements. From there, execute the sqlt/run/sqltxtrset.sql
script. When asked, pass the comma-separated list of SQL statements identified by their SQL_ID
or HASH_VALUE
, and the password for SQLTXPLAIN
. 要使用此XTRSET方法,SQLT
必须首先安装。导航到该sqlt/run
目录,然后以发出所有或大部分SQL语句的应用程序用户身份启动SQL * Plus连接。从那里执行脚本sqlt/run/sqltxtrset.sql
。询问时,传递以逗号分隔的SQL语句列表,这些语句由SQL_ID
or HASH_VALUE
标识,并提供SQLTXPLAIN
密码。
# cd sqlt/run
# sqlplus [application_user]
SQL> START sqltxtrset.sql
List of SQL_IDs or HASH_VALUEs: 2yas208zgt5cv, 6rczmqdtg99mu, 8w8tjgac6tv12
SQLT
provides some additional functionality beyond the main methods and the special methods. Use these advanced methods and modules only if requested by Oracle Support: PROFILE, XGRAM, XPLORE and XHUME. The latter is for exclusive use of Oracle Support and only in an internal testing environment. SQLT
除了主要方法和特殊方法以外,还提供了一些其他功能。仅在Oracle支持人员要求时才使用这些高级方法和模块:PROFILE,XGRAM,XPLORE和XHUME。后者专用于Oracle Support,并且仅在内部测试环境中使用。
This PROFILE method allows a quick fix on 10g when a SQL performing poorly happens to have a known better-performing plan. This better plan can be in memory in the same or different system, or in AWR
in the same or different system. In other words, if a better plan is available, this method allows "pinning" this plan using a custom SQL Profile. Before you use this method you have to use any of the main methods on the SQL for which you want to extract and pin its plan. On 11g or higher you want to use SQL Plan Management (SPM) instead of this method. 当执行不佳的SQL碰巧具有已知的性能更好的计划时,在10g中,此PROFILE方法可以快速修复。更好的计划可以在相同或不同系统中的内存中,也可以在相同或不同系统中的AWR
中。换句话说,如果有更好的计划,此方法允许使用自定义SQL配置文件“固定”该计划。使用此方法之前,必须在SQL上使用要提取和固定其计划的任何主要方法。在11g或更高版本上,您要使用SQL计划管理(SPM)代替此方法。
Be aware that PROFILE uses a DBMS_SQLTUNE
API, which is part of the SQL Tuning Advisor, therefore licensed through the Oracle Tuning pack. Use this PROFILE method only if your site has a license for the Oracle Tuning pack. 请注意,PROFILE使用的DBMS_SQLTUNE
API是SQL Tuning Advisor的一部分,因此是通过Oracle Tuning Pack许可的。仅当您的站点具有Oracle Tuning Pack的许可证时,才使用此PROFILE方法。
To use this PROFILE method, be sure SQLT
has been installed and used in the SOURCE system, then connect into SQL*Plus as SYS
or SQLTXPLAIN
and execute the sqlt/utl/sqltprofile.sql
script. It will ask for the STATEMENT_ID
out of a list of prior SQLT
executions. After a STATEMENT_ID
is selected, it will ask for a PLAN_HASH_VALUE
out of a list of available plans. These plans were captured and stored by SQLT
when XTRACT or XECUTE were used on the SQL of concern. 要使用此PROFILE方法,请确保SQLT
已在SOURCE系统中安装并使用它,然后以SYS
或SQLTXPLAIN
身份连接到SQL * Plus 并执行脚本sqlt/utl/sqltprofile.sql
。它将要求从先前执行的列表中删除STATEMENT_ID
。选择STATEMENT_ID
后,它将要求从可用计划列表中选择一个PLAN_HASH_VALUE
。这些计划是在有关SQL上使用XTRACT或XECUTE时捕获并存储的。
SQLT
does not have to be installed in the TARGET system where the custom SQL Profile is implemented. SQLT
不必在实现自定义SQL配置文件的TARGET系统中安装。
There are basically 4 steps in this PROFILE method. 此PROFILE方法基本上有4个步骤。
sqlt/utl/sqltprofile.sql
in SOURCE to generate a script with the custom SQL Profile. 在SOURCE中执行sqlt/utl/sqltprofile.sql
以使用自定义SQL配置文件生成脚本。/* ^^unique_id */
if XECUTE was used. 查看生成的脚本并根据需要调整SQL文本。例如,删除由/* ^^unique_id */
if XECUTE引起的注释。# cd sqlt/utl
# sqlplus sqltxplain
SQL> START sqltprofile.sql [statement id] [plan hash value];
SQL> START sqltprofile.sql 32263 923669362;
SQL> START sqltprofile.sql 32263;
SQL> START sqltprofile.sql;
The custom SQL Profile created by this method is based on the plan outline data and not in scaling factors, therefore it is more steady. If you later want to drop this custom SQL Profile, you can find the drop command within the script that PROFILE generated. 通过此方法创建的自定义SQL Profile是基于计划轮廓数据而不是缩放因子,因此它更稳定。如果以后要删除此自定义SQL配置文件,则可以在PROFILE生成的脚本中找到drop命令。
If you don't have SQLT
installed in the SOURCE system, or you cannot execute XTRACT or XECUTE for the SQL of concern, you can achieve the same functionality offered by the PROFILE method by using sqlt/utl/coe_xfr_sql_profile.sql
instead. This script also uses DBMS_SQLTUNE
; therefore a license for the Oracle Tuning pack is required. 如果您尚未SQLT
安装在SOURCE系统中,或者无法针对所关注的SQL 执行XTRACT或XECUTE,则可以通过使用PROFILE方法sqlt/utl/coe_xfr_sql_profile.sql
来实现相同的功能。这个脚本也使用DBMS_SQLTUNE
; 因此,需要Oracle Tuning Pack的许可证。
If your system is 11g and you are considering using this PROFILE method, review the dynamic readme generated by any of the main methods and look for "Create SQL Plan Baseline from SQL Set". You may want to consider using SQL Plan Management SPM through a SQL Set as documented in the dynamic readme. 如果您的系统是11g,并且正在考虑使用此PROFILE方法,请查看由任何主要方法生成的动态自述文件,并查找“根据SQL Set创建SQL计划基准”。您可能要考虑使用动态自述文件中记录的通过SQL集使用SQL计划管理SPM。
The XGRAM module provides functionality to modify CBO Histograms either to enhance CBO Statistics for some columns or as part of a Test Case. With this module you can insert, update or delete Histograms or individual Buckets. XGRAM模块提供了修改CBO直方图的功能,以增强某些列的CBO统计信息或作为测试用例的一部分。使用此模块,您可以插入,更新或删除直方图或单个存储桶。
Alphabetical list of scripts that implement the XGRAM module: 实现XGRAM模块的脚本的字母顺序列表:
sqlt/utl/xgram/sqlt_delete_column_hgrm.sql
sqlt/utl/xgram/sqlt_delete_hgrm_bucket.sql
sqlt/utl/xgram/sqlt_delete_schema_hgrm.sql
sqlt/utl/xgram/sqlt_delete_table_hgrm.sql
sqlt/utl/xgram/sqlt_display_column_stats.sql
sqlt/utl/xgram/sqlt_insert_hgrm_bucket.sql
sqlt/utl/xgram/sqlt_set_bucket_size.sql
sqlt/utl/xgram/sqlt_set_column_hgrm.sql
sqlt/utl/xgram/sqlt_set_min_max_values.sql
The XGRAM module is installed automatically when SQLT
is installed. If you ever need to install and use this XGRAM module outside SQLT
you would only need to install one package and use the list of scripts above (removing SQLTXADMIN
dependencies). XGRAM模块在安装时SQLT
会自动安装。如果您需要在外部安装和使用此XGRAM模块SQLT
,则只需安装一个软件包并使用上面的脚本列表(除去SQLTXADMIN
依赖性)
The XPLORE module helps when after a database upgrade a SQL starts to perform poorly or it may produce apparent wrong results. If switching optimizer_features_enable
(OFE) to the database release prior to the upgrade the SQL performs fine again, or it produces different results, you can use this XPLORE module to try to identify which particular Optimizer feature or fix introduced the undesired behavior. Identifying the particular culprit can help to troubleshoot further or do more research on this particular feature and/or fix. XPLORE模块可在数据库升级后何时开始执行SQL错误或可能产生明显错误结果的情况下提供帮助。如果optimizer_features_enable
在升级之前将(OFE)切换到数据库版本,则SQL再次可以正常运行,或者产生不同的结果,则可以使用此XPLORE模块来尝试确定哪个特定的优化器功能或修复引入了不良行为。找出特定的罪魁祸首可以帮助进一步排除故障,或者对该特定功能和/或修复方法进行更多研究。
This module toggles initialization and fix control parameters to discover plans. 该模块切换初始化和修复控制参数以发现计划。
Use XPLORE only when ALL these conditions are met: 仅当满足以下所有条件时,才使用XPLORE:
SYS
access.Do not use XPLORE when ANY of these conditions is true: 当满足以下任一条件时,请勿使用XPLORE:
To install and use this XPLORE module, read corresponding sqlt/utl/xplore/readme.txt
.
This module is for the exclusive use of Oracle Support. It must be used only in an Oracle internal system. It updates the data dictionary and this operation is not supported by Oracle. 该模块专用于Oracle Support。它只能在Oracle内部系统中使用。它会更新数据字典,而Oracle不支持此操作。
XHUME can be used to discover plans that are only possible with older version of schema object statistics related to one SQL. After a Test Case (TC
) is created using SQLT
, this XHUME module restores systematically prior versions of the statistics and generates plans by executing the SQL being studied. It captures the plan that each version of the statistics can generate. Then produces a report, which can be used to understand the plan instability, or to find an elusive plan that can be used to create a SQL Profile or SQL Plan Baseline. XHUME可用于发现仅与旧版本的与一个SQL相关的模式对象统计信息才可能实现的计划。TC
使用创建测试用例()之后SQLT
,此XHUME模块将系统地还原统计信息的先前版本,并通过执行所研究的SQL生成计划。它捕获了每个版本的统计信息可以生成的计划。然后生成一个报告,该报告可用于了解计划的不稳定性,或查找可用于创建SQL概要文件或SQL计划基准的难以捉摸的计划。
This module should never be used in a Production system because it modifies the data dictionary. Use only on an Oracle internal Test enviornment. 此模块绝不能在生产系统中使用,因为它会修改数据字典。仅在Oracle内部测试环境上使用。
As an alternative to modify the creation date of the Test Case (TC
) schema objects, you can change the date on the server prior to the TC
implementation, and reset to current date after the TC
is created. This temporary prior date must be at least one month old, so all history of schema object statistics would have a save time newer than the TC
object creation time. 作为修改测试用例(TC
)模式对象的创建日期的替代方法,您可以在TC
实现之前在服务器上更改日期,并在TC
创建之后将其重置为当前日期。该临时的先前日期必须至少为一个月,因此所有架构对象统计信息的历史记录的保存时间都将比TC
对象创建时间新。
Use XHUME only when ALL these conditions are met: 仅当满足以下所有条件时,才使用XHUME:
SQLT
TC
where a known plan is generated (a "good" or a "bad" one).SYS
access.Do not use XHUME when ANY of these conditions is true: 当满足以下任一条件时,请勿使用XHUME
TC
on a Production environment.TC
created with SQLT
.TC
.To install and use this XHUME module, read corresponding sqlt/utl/xhume/readme.txt
.