Cover | Table of Contents
|
Problem
|
% Cases
|
|---|---|
|
1. Incorrect driving table
|
40%
|
|
2. Incorrect index
|
40%
|
|
3. Incorrect driving index
|
10%
|
|
4. Using the ORDER BY index and not the WHERE index
|
10%
|
SELECT COUNT(*) FROM acct a, trans b WHERE b.cost_center = 'MASS' AND a.acct_name = 'MGA' AND a.acct_name = b.acct_name;
|
Problem
|
% Cases
|
|---|---|
|
1. The skewness problem
|
30%
|
|
2. Analyzing with wrong data
|
25%
|
|
3. Mixing the optimizers in joins
|
20%
|
|
4. Choosing an inferior index
|
20%
|
|
5. Joining too many tables
|
< 5%
|
|
6. Incorrect INIT.ORA parameter settings
|
< 5%
|
|
Problems for both Rule and Cost
|
Occurrence %
|
|---|---|
|
1. Statement not written for indexes
|
25%
|
|
2. Indexes are missing or inappropriate
|
16%
|
|
3. Use of single-column index merge
|
15%
|
|
4. Misuse of nested loop, sort merge, or hash join
|
12%
|
|
5. Misuse of IN, EXISTS, NOT IN, NOT EXISTS, or table joins
|
8%
|
|
6. Unnecessary Sorts
|
4%
|
|
7. Too many indexes on a table
|
4%
|
|
8. Use of OR instead of UNION
|
3%
|
|
9. Tables and indexes with many deletes
|
3%
|
|
10. Other
|
10%
|
column "Response" format 999,999,999.99;
column nl newline;
ttitle 'SQL With Disk Reads > 10 Seconds'
SELECT sql_text nl, 'Executions='||
executions nl,
'Expected Response Time in Seconds= ',
disk_reads / decode(executions, 0, 1,
executions) / 300
"Response"
FROM v$sql
WHERE disk_reads / decode(executions,0,1, executions)
/ 300 > 10
AND executions > 0
ORDER BY hash_value, child_number;
column "Response" format 999,999,999.99
ttitle 'SQL Buffer Scan > 10 Seconds'
SELECT sql_text nl, 'Executions='||
executions nl,
'Expected Response Time in Seconds= ',
buffer_gets /
decode(executions, 0, 1, executions)
/ 4000 "Response"
FROM v$sql
WHERE buffer_gets /
decode(executions, 0,1, executions)
/ 4000 > 10
AND executions > 0
ORDER BY hash_value, child_number;
SELECT /*+ RULE */ . . . .
FROM emp, dept
WHERE . . .
SELECT /*+ hint text */ . . . . DELETE /*+ hint text */ . . . . UPDATE /*+ hint text */ . . . .
SELECT /*+ RULE */ . . . .
FROM emp
WHERE emp_status = 'PART-TIME'
AND EXISTS
( SELECT /*+ FIRST_ROWS */ 'x'
FROM emp_history
WHERE emp_no = E.emp_no
AND emp_status
!= 'PART-TIME' )
SELECT /*+ RULE */ . . . .
FROM emp
WHERE emp_status = 'PART-TIME'
UNION
SELECT /*+ ALL_ROWS */ . . . .
FROM emp_history
WHERE emp_status != 'PART-TIME'
EXECUTE SYS.DBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>
'HROA', ESTIMATE_PERCENT=>10, DEGREE=>4, CASCADE=>TRUE);
ALTER TABLE WINNERS MONITORING;
EXECUTE SYS.DBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>
'HROA', ESTIMATE_PERCENT=>10, DEGREE=>4, CASCADE=>TRUE,
OPTIONS=>'GATHER STALE');
CREATE OR REPLACE OUTLINE aug0901
FOR CATEGORY harness_racing
ON select *
from winners
where owner > 'G%';
ALTER SESSION
SET CREATE_STORED_OUTLINES
=GENERAL_LEDGER;
ALTER SESSION SET CREATE_STORED_OUTLINES=TRUE;
ALTER SESSION SET CREATE_STORED_OUTLINES=FALSE;
Return to Oracle SQL Tuning Pocket Reference