Practice 33 - Using SQL Tuning Health-Check Script (SQLHC) P a g e |1
Practice 33
Using SQL Tuning Health-Check Script (SQLHC)
Practice Target
In this practice, you will use the SQL Tuning Health-Check Script.
About SQL Tuning Health-Check Script (SQLHC)
The SQL Tuning Health-Check Script is a script developed by the Oracle Server Technologies Center of
Expertise. The tool, also known as SQLHC, is used to diagnose performance issues on a single specific
query. It checks the environment in which a single SQL Statement runs, the cost-based optimizer
(CBO) statistics, schema object metadata, configuration parameters and other elements that may
influence the performance of the one SQL that is being analyzed.
Use this tool to quickly gather all the information that you need to diagnose specific query
performance issues.
The generated report helps you to diagnose the root cause, but it does not recommend fixing the
issue.
This free tool can be downloaded from Oracle support Doc ID 1366133.1.
Oracle Database 12c the Ultimate Guide to SQL Tuning, a course by Ahmed Baraka
Practice 33 - Using SQL Tuning Health-Check Script (SQLHC) P a g e |2
Using SQL Tuning Health-Check Script (SQLHC)
In the following steps, you will use the SQL Tuning Health-Check Script (SQLHC).
1. Download the sqlhc.zip file from the Document ID 1366133.1
2. Copy the file to the staging directory.
3. Open Putty, login to srv1 as oracle then extract the file.
cd /media/sf_extdisk
unzip sqlhc.zip
4. Invoke SQL*Plus, and connect to ORADB as soe.
sqlplus soe/soe
5. Run the following query
SELECT /* my query */ CUST_FIRST_NAME FNAME, CUST_LAST_NAME LNAME, NLS_LANGUAGE
LANG, NLS_TERRITORY TERRITORY, CREDIT_LIMIT
FROM CUSTOMERS
WHERE CUST_FIRST_NAME LIKE 'gr%' AND CUST_LAST_NAME LIKE 'sq%';
6. Retrieve the statement SQL_ID and take a note of it.
COL SQL_COMMAND FORMAT A50
SELECT substr(SQL_TEXT,1,50) SQL_COMMAND, SQL_ID FROM V$SQL WHERE SQL_TEXT LIKE
'SELECT /* my query */%';
7. Run the following script as sysdba. Wait for the script to finish.
o When it prompts you to enter value for 1, enter ‘T’
o When it prompts you to enter value for 2, enter the value of the SQL ID
conn / as sysdba
@/media/sf_extdisk/sqlhc/sqlhc.sql
8. Check out the contents of the generated zip file. It should contain reports on the SQL statement
on concern.
9. Cleanup
host rm -r /media/sf_extdisk/sqlhc
10. Delete the produced reports.
Oracle Database 12c the Ultimate Guide to SQL Tuning, a course by Ahmed Baraka