SQL调优和诊断神器SQLTXPLAIN (SQLT)简介(二 XPLORE Module)

Posted SQLplusDB

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL调优和诊断神器SQLTXPLAIN (SQLT)简介(二 XPLORE Module)相关的知识,希望对你有一定的参考价值。

XPLORE Module

对于SQL的很多Optimzer问题如执行计划异常、SQL慢、结果不正(Wrong Result)等,
如果在测试环境可以重现的话,可以通过SQLT的xplore功能,
调整各种参数和Optimzer的Fix Control来找到回避方法和找到Root Cause。

其他参考:
【SQL工具】SQL调优和诊断神器SQLTXPLAIN (SQLT)简介

注意点

在使用xplore功能时需要注意以下几点:

Use XPLORE only when ALL these conditions are met:
    SQL performs poorly or returns wrong results while using a "bad" plan.
    The bad plan can be reproduced on a test system (no data is preferred).
    A "good" plan can be reproduced on the test system by switching OFE.
    You need to narrow reason to specific parameter or bug fix control.
    You have full access to the test system, including SYS access.
Do not use XPLORE when ANY of these conditions is true:
    The SQL statement may cause corruption or update data.
    There is high volume of data in tables referenced by SQL.
    The execution of the SQL may take longer than a few seconds.

执行例

以下是xplore的执行方法例:

SQL*Plus: Release 12.2.0.1.0 Production on Sun May 21 03:16:55 2017
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> START install.sql
Test Case User: testxplore
Password: testxplore
...
Installation completed.
You are now connected as testxplore.
1. Set CBO env if needed
2. Execute @create_xplore_script.sql
SQL> @create_xplore_script.sql
Parameter 1:
XPLORE Method: XECUTE (default) or XPLAIN
"XECUTE" requires /* ^^unique_id */ token in SQL
"XPLAIN" uses "EXPLAIN PLAN FOR" command
Remember EXPLAIN PLAN FOR does not perform bind peeking
Enter "XPLORE Method" [XECUTE]: XECUTE
Parameter 2:
Include CBO Parameters: Y (default) or N
Enter "CBO Parameters" [Y]:
Parameter 3:
Include Exadata Parameters: Y (default) or N
Enter "EXADATA Parameters" [Y]: N
Parameter 4:
Include Fix Control: Y (default) or N
Enter "Fix Control" [Y]: Y
Parameter 5:
Generate SQL Monitor Reports: N (default) or Y
Only applicable when XPLORE Method is XECUTE
Enter "SQL Monitor" [N]: Y
...
Review and execute @xplore_script_1.sql

※在执行前你需要建立一个包括/* ^^unique_id */的对象SQL文件如test.sql,
然后执行plore_script_1.sql
例:
test.sql
SELECT /* ^^unique_id */ …

执行:
SQL>@xplore_script_1.sql
testxplore
Parameter 1:
Name of SCRIPT file that contains SQL to be xplored (required)
Note: SCRIPT must contain comment /* ^^unique_id */
Enter value for 1: test.sql
Parameter 2:
Password for testxplore (required)
Enter value for 2: testxplore

版权声明:本文为博主原创文章,转载必须注明出处,本人保留一切相关权力!http://blog.csdn.net/lukeunique

欢迎关注微信订阅号:Oracle数据库技术 (TeacherWhat)

参考:

sqlt/utl/xplore/readme.txt

以上是关于SQL调优和诊断神器SQLTXPLAIN (SQLT)简介(二 XPLORE Module)的主要内容,如果未能解决你的问题,请参考以下文章

SQL调优和诊断神器SQLTXPLAIN (SQLT)简介(二 XPLORE Module)

SQL调优和性能监控利器SQL Monitor

oracle sqlt(sqltxplain) 诊断工具

oracle sqlt(sqltxplain) 诊断工具

SQL Server超时诊断和调优

重磅发布|新一代云原生数据仓库AnalyticDB「SQL智能诊断」功能详解