215187.1 SQLT XPLAIN 11.4.5.4 Report: sqlt_s53239_readme.html

Instructions to perform the following:


Export SQLT repository

Steps:

  1. Unzip sqlt_s53239_driver.zip in order to get sqlt_s53239_export_parfile.txt.
  2. Copy sqlt_s53239_export_parfile.txt to SOURCE server (TEXT).
  3. Execute export on server:
  4. exp sqltxplain parfile=sqlt_s53239_export_parfile.txt


Import SQLT repository

Steps:

  1. Unzip sqlt_s53239_tc.zip in order to get sqlt_s53239_expdp.dmp.
  2. Copy sqlt_s53239_exp.dmp to the server (BINARY).
  3. Execute import on server:
  4. imp sqltxplain FILE=sqlt_s53239_exp.dmp TABLES=sqlt% IGNORE=Y

You can execute sqlt_s53239_import.sh instead.


Using SQLT COMPARE

You need to have a set of SQLT files (sqlt_sNNNNN_method.zip) from two executions of the SQLT tool. They can be from any method (XTRACT, XECUTE or XPLAIN) and they can be from the same or different systems. They do not have to be from same release or platform. For example, a SQLT from 10g on Linux and a SQLT from 11g on Unix can be compared.

To use the COMPARE method you need 3 systems: SOURCE1, SOURCE2 and COMPARE. The 3 could all be different, or all the same. For example, SOURCE1 could be PROD, SOURCE2 DEV and COMPARE DEV. In other words, you could do the COMPARE in one of the sources. Or the COMPARE could be done on a 3rd and remote system.

Basically you need to restore the SQLT repository from both SOURCES into the COMPARE system. In most cases it means "restoring" the SQLT repository from at least one SOURCE into the COMPARE. Once you have both SQLT repositories into the COMPARE system, then you can execute this method.

Steps:

  1. Unzip sqlt_s53239_tc.zip from this SOURCE in order to get sqlt_s53239_expdp.dmp.
  2. Copy sqlt_s53239_exp.dmp to the server (BINARY).
  3. Execute import on server:
  4. imp sqltxplain FILE=sqlt_s53239_exp.dmp TABLES=sqlt% IGNORE=Y

  5. Perform the equivalent steps for the 2nd SOURCE if needed. You may want to follow its readme file.
  6. Execute the COMPARE method connecting into SQL*Plus as SYS. You will be asked to enter which 2 statements you want to compare.
  7. START sqlt/run/sqltcompare.sql


Restore CBO schema statistics

CBO schema object statistics can be restored from the local SQLT repository, or from an imported repository. Restoring CBO statistics associates them to existing and compatible schema objects. These objects can be owned by the original schema owner or by a different one. For example, table T is owned by user U in SOURCE and by user TC53239 in TARGET.

When using restore script below, the second parameter allows to remap the schema object statistics to a different user. Be aware that target user and schema objects must exist before executing this script. To restore CBO schema object statistics into the original schema owner(s) pass "null" (or just hit the "Enter" key) when the second parameter is requested.

Steps:

  1. Execute restore script connecting as SYSDBA:
  2. START sqlt/utl/sqltimp.sql s53239_v1123_host01 TC53239


Restore CBO system statistics

Steps:

  1. Execute restore script connecting as SYSDBA:
  2. START sqlt_s53239_system_stats.sql


Implement SQLT Test Case (TC)

SOURCE and TARGET systems should be similar. Proceed with Preparation followed by Express or Custom mode.

Preparation

  1. Unzip sqlt_s53239_tc.zip in server and navigate to TC directory.
  2. unzip sqlt_s53239_tc.zip -d TC53239

    cd TC53239

Express (XPRESS) mode

  1. Review and execute xpress.sh from OS or xpress.sql from sqlplus.
  2. Option 1: ./xpress.sh

    Option 2: sqlplus / as sysdba @xpress.sql

Custom mode

  1. Create test case user and schema objects connecting as SYSDBA:
  2. sqlplus / as sysdba

    START sqlt_s53239_metadata.sql

  3. Purge pre-existing s53239 from local SQLT repository connected as SYSDBA:
  4. START sqlt_s53239_purge.sql

  5. Import SQLT repository for s53239 (provide SQLTXPLAIN password):
  6. HOS imp sqltxplain FILE=sqlt_s53239_exp.dmp LOG=sqlt_s53239_imp.log TABLES=sqlt% IGNORE=Y

  7. Restore CBO schema statistics for test case user connected as SYSDBA:
  8. START sqlt_s53239_restore.sql

  9. Restore CBO system statistics connected as SYSDBA:
  10. START sqlt_s53239_system_stats.sql

  11. Set the CBO environment connecting as test case user TC53239 (include optional test case user suffix):
  12. CONN TC53239/TC53239

    START sqlt_s53239_set_cbo_env.sql

  13. Execute test case:
  14. START tc.sql


Create TC with no SQLT dependencies

After creating a local test case using SQLT files, you can create a stand-alone TC with no dependencies on SQLT.

Steps:

  1. Export TC schema object statistics to staging table within TC schema:
  2. DELETE TC53239.CBO_STAT_TAB_4TC;
    EXEC SYS.DBMS_STATS.EXPORT_SCHEMA_STATS(ownname => 'TC53239', stattab => 'CBO_STAT_TAB_4TC');

  3. Export TC schema object statistics from staging table:
  4. HOS exp TC53239/TC53239 FILE=cbo_stat_tab_4tc.dmp LOG=cbo_stat_tab_4tc.log TABLES=cbo_stat_tab_4tc STATISTICS=NONE

  5. Review setup.sql script and adjust if needed.
  6. Review readme.txt file and adjust if needed.
  7. Create and zip a new directory with the following files:
  8. CBO schema object statistics dump: cbo_stat_tab_4tc.dmp
    Plan script:                       plan.sql
    Query script:                      q.sql
    Instructions:                      readme.txt
    Setup script:                      setup.sql
    Metadata script:                   sqlt_s53239_metadata.sql
    OPatch (if needed):                sqlt_s53239_opatch.zip
    Set CBO env script (if needed):    sqlt_s53239_set_cbo_env.sql
    System statistics setup:           sqlt_s53239_system_stats.sql
    Test case script:                  tc.sql
    
  9. Test your new stand-alone TC following your own readme.txt in another system.

Note: You may want to use tc_pkg.sql to execute commands above.


Gather CBO statistics without Histograms (using SYS.DBMS_STATS)

Use commands below to generate a fresh set of CBO statistics for the schema objects accessed by your SQL. Histograms will be dropped.

BEGIN -- generated by SQLT
  SYS.DBMS_STATS.UNLOCK_TABLE_STATS (
    ownname       => '"SH"',
    tabname       => '"PRODUCTS"'
  );
  SYS.DBMS_STATS.GATHER_TABLE_STATS (
    ownname          => '"SH"',
    tabname          => '"PRODUCTS"',
    estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
    method_opt       => 'FOR ALL COLUMNS SIZE 1',
    cascade          => TRUE,
    no_invalidate    => FALSE
  );
  SYS.DBMS_STATS.UNLOCK_TABLE_STATS (
    ownname       => '"SH"',
    tabname       => '"SALES"'
  );
  SYS.DBMS_STATS.GATHER_TABLE_STATS (
    ownname          => '"SH"',
    tabname          => '"SALES"',
    estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
    method_opt       => 'FOR ALL COLUMNS SIZE 1',
    granularity      => 'GLOBAL AND PARTITION',
    cascade          => TRUE,
    no_invalidate    => FALSE
  );
END;
/

Gather CBO statistics with Histograms (using SYS.DBMS_STATS)

Use commands below to generate a fresh set of CBO statistics for the schema objects accessed by your SQL. Histograms will be generated for some columns.

BEGIN -- generated by SQLT
  SYS.DBMS_STATS.UNLOCK_TABLE_STATS (
    ownname       => '"SH"',
    tabname       => '"PRODUCTS"'
  );
  SYS.DBMS_STATS.GATHER_TABLE_STATS (
    ownname          => '"SH"',
    tabname          => '"PRODUCTS"',
    estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
    method_opt       => 'FOR ALL COLUMNS SIZE AUTO',
    cascade          => TRUE,
    no_invalidate    => FALSE
  );
  SYS.DBMS_STATS.UNLOCK_TABLE_STATS (
    ownname       => '"SH"',
    tabname       => '"SALES"'
  );
  SYS.DBMS_STATS.GATHER_TABLE_STATS (
    ownname          => '"SH"',
    tabname          => '"SALES"',
    estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
    method_opt       => 'FOR ALL COLUMNS SIZE AUTO',
    granularity      => 'GLOBAL AND PARTITION',
    cascade          => TRUE,
    no_invalidate    => FALSE
  );
END;
/

List generated files

Files generated under current SQL*Plus directory.
Not all files may be available.

sqlt_s53239_main.html
sqlt_s53239_metadata.sql
sqlt_s53239_metadata1.sql
sqlt_s53239_metadata2.sql
sqlt_s53239_system_stats.sql
sqlt_s53239_schema_stats.sql
sqlt_s53239_set_cbo_env.sql
sqlt_s53239_lite.html
sqlt_s53239_readme.html
sqlt_s53239_readme.txt
sqlt_s53239_tcb_driver.sql
sqlt_s53239_tcb.zip
sqlt_s53239_remote_driver.sql
sqlt_s53239_tkprof_px_driver.sql
sqlt_s53239_export_parfile.txt
sqlt_s53239_export_parfile2.txt
sqlt_s53239_export_driver.sql
sqlt_s53239_import.sh
sqlt_s53239_export.zip
sqlt_s53239_tc.zip
sqlt_s53239_log.zip
sqlt_s53239_opatch.zip
sqlt_s53239_remote.zip
sqlt_s53239_sql_detail_active.html
sqlt_s53239_10053_explain.trc
sqlt_s53239_xplain.log
sqltxplain.log
input/sample/sql1.sql
sqltxhost.log
plan.sql
10053.sql
flush.sql
purge.sql
restore.sql
del_hgrm.sql
tc.sql
tc_pkg.sql
xpress.sql
xpress.sh
setup.sql
q.sql
sel.sql
sel_aux.sql
install.sql
install.sh
tcx_pkg.sql

Files generated under SQLT$UDUMP directory.
To locate SQLT$UDUMP: SELECT directory_path FROM sys.dba_directories WHERE directory_name = 'SQLT$UDUMP';
Not all files may be available.

V1123_ora_4030_s53239_10053.trc

Files generated under SQLT$BDUMP directory.
To locate SQLT$BDUMP: SELECT directory_path FROM sys.dba_directories WHERE directory_name = 'SQLT$BDUMP';
Not all files may be available.

*_s53239_*.trc

Files generated under SQLT$STAGE directory.
To locate SQLT$STAGE: SELECT directory_path FROM sys.dba_directories WHERE directory_name = 'SQLT$STAGE';
Not all files may be available.

sqlt_s53239_tcb_*
README.txt

215187.1 sqlt_s53239_readme.html 2013-02-04/10:13:18