1 Tuning with Oracle’s SQL Trace David Kurtz Go-Faster Consultancy Ltd.

Slides:



Advertisements
Similar presentations
Analyzing Application Performance in RAC
Advertisements

PeopleSoft Ping David Kurtz
Why is that LOV in the screen not returning me desired value?
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Office of the Accountant General (A&E) Andhra Pradesh Hyderabad
9 Copyright © 2006, Oracle. All rights reserved. Automatic Performance Management.
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
Jonathan Lewis EOUG Jun 2000 Execution Plans Agenda What are execution plans Where do you find execution plans Key mechanisms of execution Understanding.
SQL Objects and PL/SQL. Who am I ?  Gary Myers  Oracle developer since 1994  Database Consultant with SMS M&T  Blogger since 2004 Now at blog.sydoracle.com.
What Happens when a SQL statement is issued?
An introduction to SQL*Trace, TKPROF and Execution Plans
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
Finding the Performance Bottlenecks in Your Application Ian Jones and Roger Schrag Database Specialists, Inc. IOUG-A Live! 1999 Paper.
1 Chapter 16 Latch and Mutex Contention. 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2007 all rights.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Harvard University Oracle Database Administration Session 5 Data Storage.
Introduction to Structured Query Language (SQL)
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
1 Tuning PL/SQL procedures using DBMS_PROFILER 20-August 2009 Tim Gorman Evergreen Database Technologies, Inc. Northern California Oracle.
ORACLE ONLINE TRAINING Contact our Support Team : SOFTNSOL India: Skype id : softnsoltrainings id:
5 Copyright © 2008, Oracle. All rights reserved. Configuring the Oracle Network Environment.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Unicode Oddity. from a Unicode PeopleSoft Database SELECT emplid, name, LENGTH(name), BLENGTH(name) FROMps_personal_data WHEREemplid = '007’ ; EMPLID.
Oracle9i Performance Tuning Chapter 1 Performance Tuning Overview.
The Model Clause explained Tony Hasler, UKOUG Birmingham 2012 Tony Hasler, Anvil Computer Services Ltd.
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
SEMANTEC 1 Oracle Performance Tuning - Part I Krasen Paskalev Oracle 8i Certified DBA.
Mark Inman U.S. Navy (Naval Sea Logistics Center) Session #213 Analytic SQL for Beginners.
Oracle tuning: a tutorial Saikat Chakraborty. Introduction In this session we will try to learn how to write optimized SQL statements in Oracle 8i We.
1 Chapter 17 Shared Memory Contention. 2 Overview Specifically talking about SGA – Buffer Cache – Redo Log Buffer Contention in these areas of SGA – Can.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
© IBM Corporation 2005 Informix User Forum 2005 John F. Miller III Explaining SQLEXPLAIN ®
Troubleshooting 11i issues Adam Janbolat
1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.
Tools for Analyzing Problems in Oracle Applications Jeff Slavitz (415)
DB Tuning : Chapter 10. Optimizer Center for E-Business Technology Seoul National University Seoul, Korea 이상근 Intelligent Database Systems Lab School of.
Ad Hoc User or Application Cost-based Data Dictionary Statistics Rule-based Execution Plan Asks the question: All people and their grades in a list giving.
Optimization and Administartion of a Database Management Systems Krystian Zieja.
3 Copyright © 2007, Oracle. All rights reserved. Using the RMAN Recovery Catalog.
OEM 10g Performance and Tuning. #.2 Copyright 2006 Kyle Hailey Performance SQL Diagnostics SQLTuning Performance Session DB HOME.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Same Plan Different Performance Mauro Pagano. Consultant/Developer/Analyst Oracle  Enkitec  Accenture DBPerf and SQL Tuning Training Tools (SQLT, SQLd360,
I NTRODUCTION OF W EEK 2  Assignment Discussion  Due this week:  1-1 (Exam Proctor): everyone including in TLC  1-2 (SQL Review): review SQL  Review.
SAP Tuning 실무 SK㈜ ERP TFT.
Oracle Database Architectural Components
1 PVSS Oracle scalability Target = changes per second (tested with 160k) changes per client 5 nodes RAC NAS 3040, each with one.
SQL Trace and TKPROF.
EXPLAIN and AUTOTRACE.
1Z0-071 Exam : Oracle Database 12c SQL
SQL Server Monitoring Overview
Chapter 8 Working with Databases and MySQL
Oracle Memory Internals
CS347 Spring 2017 – Quiz 5 Preparation - Solutions UTEID _________
Performance Tuning ETL Process
Presentation transcript:

1 Tuning with Oracle’s SQL Trace David Kurtz Go-Faster Consultancy Ltd.

2 Message from the SIG management Keep filling in the critique forms Keep suggesting topics –This is session was a requested topic Offer to talk on topic about which you know

3 Who am I? DBA –Independent consultant –Performance tuning

4 Tuning with Oracle’s SQL Trace Overview of Tuning Explain Plan Enabling SQL Trace TKPROF Interpreting Execution Plans

5 Rules of Engagement Interrupt me: –if you think I have got something wrong –if you have a question –if you can’t hear me

6 What is Tuning? It is a much abused term What does a person mean when they say ‘Tuning’

7 Oracle Designing and Tuning for Performance Manual New name in Oracle 8i Used to be the ‘Tuning’ manual A good place to start Always there Free

8 Oracle Designing and Tuning for Performance Manual Chapters 4.The Optimiser 5.Using Explain Plan 6.Using SQL Trace and TKPROF

9 When should I start to Tune? NOW is already too late from ‘Oracle Designing and Tuning for Performance’

10 Tuning occurs at Different Levels business design data design application design logical structure of the database database operations access paths memory allocation I/O and physical structure resource contention platform

11 Tuning is a search for lost time Identify problem SQL Find out why it is a problem –SQL execution plan

12 Explain plan Explain plan for –PLAN_TABLE set autotrace on

13 Rule -v- Cost Based Optimiser select /*+RULE*/ * from dual; Execution Plan SELECT STATEMENT Optimizer=HINT: RULE 1 0 TABLE ACCESS (FULL) OF 'DUAL' select /*+ALL_ROWS*/ * from dual; Execution Plan SELECT STATEMENT Optimizer=HINT: ALL_ROWS (Cost=1 Card=1 Bytes=2) 1 0 TABLE ACCESS (FULL) OF 'DUAL' (Cost=1 Card=1 Bytes=2)

14 SQL Trace Whole database –SQL_TRACE=TRUE Current Session –ALTER SESSION SET SQL_TRACE=TRUE; –sys.dbms_session.set_sql_trace(true) A different session –sys.dbms_system.set_sql_trace_in_session (,,TRUE);

15 USER_DUMP_DEST Trace file written to directory –USER_DUMP_DEST Default –$ORACLE_HOME/rdbms/log/ System level –ALTER SYSTEM SET USER_DUMP_DEST=newdir

16 MAX_DUMP_FILE_SIZE Maximum size of trace file –Kbytes / OS blocks –Shadow process will stop writing when maximum reached –grep "DUMP FILE SIZE IS LIMITED” Beware –Truncated trace file –Full File System

17 Timed Statistics Enable to get statement and other timings Initialisation file –TIMED_STATISTICS=TRUE Ad-hoc –ALTER SYSTEM SET TIMED_STATISTICS=TRUE; Small performance overhead

18 Trace File (Unix) Difficult to read, but useful information Dump file /PS/oracle/app/oracle/product/8.0.5/rdbms/log/psperf_ora_20437.trc Oracle8 Enterprise Edition Release Production PL/SQL Release Production ORACLE_HOME = /PS/oracle/app/oracle/product/8.0.5 System name:SunOS Node name:hqmain01 Release:5.6 Version:Generic_ Machine:sun4u Instance name: PSPERF Redo thread mounted by this instance: 1 Oracle process number: 30 Unix process pid: 20437, image: oraclePSPERF *** SESSION ID:( )

19 Trace File (NT) Dump file c:\user\ppt\tuning with Oracle Trace\demo\ORA00298.TRC Tue May 16 20:02: ORACLE V Production vsnsta=0 vsnsql=e vsnxtr=3 Windows NT Version 4.0 Service Pack 6, CPU type 586 Oracle8i Enterprise Edition Release Production With the Partitioning option JServer Release Production Windows NT Version 4.0 Service Pack 6, CPU type 586 Instance name: f75do81 Redo thread mounted by this instance: 1 Oracle process number: 9 Windows thread id: 298, image: ORACLE.EXE

20 Trace file Lists every statement PARSING IN CURSOR #1 len=33 dep=0 uid=21 oct=42 lid=21 tim= hv= ad='809c49a4' ALTER SESSION SET SQL_TRACE=TRUE END OF STMT EXEC #1:c=0,e=2,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=

21 Trace file Contains the execution plan END OF STMT PARSE #1:c=44,e=45,p=42,cr=1821,cu=4,mis=1,r=0,dep=0,og=4,tim= *** EXEC #1:c=15661,e=16023,p=164769,cr= ,cu=0,mis=0,r=0,dep=0,og=4,tim= EXEC #2:c=0,e=3,p=4,cr=1,cu=3,mis=0,r=1,dep=0,og=4,tim= STAT #1 id=1 cnt=0 pid=0 pos=0 obj=0 op='SORT UNIQUE ' STAT #1 id=2 cnt=0 pid=1 pos=1 obj=0 op='FILTER ' STAT #1 id=3 cnt=0 pid=2 pos=1 obj=0 op='NESTED LOOPS ' STAT #1 id=4 cnt=8 pid=3 pos=1 obj=0 op='NESTED LOOPS ' STAT #1 id=5 cnt= pid=4 pos=1 obj=0 op='NESTED LOOPS ' STAT #1 id=6 cnt=360 pid=5 pos=1 obj=0 op='NESTED LOOPS ' STAT #1 id=7 cnt=10 pid=6 pos=1 obj=0 op='NESTED LOOPS ' STAT #1 id=8 cnt=10 pid=7 pos=1 obj=10009 op='TABLE ACCESS BY INDEX ROWID PS_PP_PAYMENT_TMP ’...

22 TKPROF Processes the trace file –removes recursive SQL –generate execution plans –aggregate duplicates –sort by criteria –top n statements

23 Plan Table $ORACLE_HOME/rdbms/admin/ utlxplan.sql –builds plan table either make it local to a user, or create a public synonym and issue grants $ORACLE_HOME/rdbms/admin/ utltkprf.sql

24 TKPROF Command Usage: tkprof tracefile outputfile [explain= ] [table= ] [print= ] [insert= ] [sys= ] [sort= ] table=schema.tablename Use 'schema.tablename' with 'explain=' option. explain=user/password Connect to ORACLE and issue EXPLAIN PLAIN. print=integer List only the first 'integer' SQL statements. aggregate=yes|no insert=filename List SQL statements and data inside INSERT statements. sys=no TKPROF does not list SQL statements run as user SYS. record=filename Record non-recursive statements found in the trace file. sort=option Set of zero or more of the following sort options:... execnt number of execute was called execpu cpu time spent executing exeela elapsed time executing exedsk number of disk reads during execute exeqry number of buffers for consistent read during execute execu number of buffers for current read during execute exerow number of rows processed during execute exemis number of library cache misses during execute...

25 SQL statement INSERT INTO PS_PP_CUST_TMP2 ( PROCESS_INSTANCE, DEPOSIT_BU, DEPOSIT_ID, PAYMENT_SEQ_NUM, CUST_ID, PAYMENT_AMT, PAYMENT_DT, PP_METHOD, SETID, SUBCUST_QUAL1, SUBCUST_QUAL2, PP_HOLD, PP_MET_SW, PAYMENT_CURRENCY ) SELECT DISTINCT P.PROCESS_INSTANCE, P.DEPOSIT_BU, P.DEPOSIT_ID, P.PAYMENT_SEQ_NUM, C.CUST_ID, P.PAYMENT_AMT, P.PAYMENT_DT, O.PP_METHOD, O.SETID, C.SUBCUST_QUAL1, C.SUBCUST_QUAL2, O.PP_HOLD, 'N', P.PAYMENT_CURRENCY FROM PS_CUST_OPTION O, PS_ITEM I, PS_CUSTOMER C, PS_SET_CNTRL_REC S, PS_PAYMENT_ID_ITEM X, PS_PP_PAYMENT_TMP P WHERE P.PROCESS_INSTANCE = 212 AND S.RECNAME = 'CUSTOMER' AND S.SETID = C.SETID AND S.SETCNTRLVALUE = I.BUSINESS_UNIT AND I.CUST_ID = C.CUST_ID AND I.ITEM_STATUS = 'O' AND O.SETID = C.REMIT_FROM_SETID AND O.CUST_ID = C.REMIT_FROM_CUST_ID AND O.EFFDT = ( SELECT MAX(Z.EFFDT) FROM PS_CUST_OPTION Z WHERE Z.SETID = O.SETID AND Z.CUST_ID = O.CUST_ID AND Z.EFF_STATUS = 'A' AND Z.EFFDT <= P.PAYMENT_DT ) AND O.PP_METHOD <> ' ' AND P.DEPOSIT_BU = X.DEPOSIT_BU AND P.DEPOSIT_ID = X.DEPOSIT_ID AND P.PAYMENT_SEQ_NUM = X.PAYMENT_SEQ_NUM AND X.REF_QUALIFIER_CODE = 'I' AND X.REF_VALUE = I.ITEM

26 Statistics … count = number of times OCI procedure was executed cpu = cpu time in seconds executing elapsed = elapsed time in seconds executing disk = number of physical reads of buffers from disk query = number of buffers gotten for consistent read current = number of buffers gotten in current mode (usually for update) rows = number of rows processed by the fetch or execute call … call count cpu elapsed disk query current rows Parse Execute Fetch total

27 Execution plan (Oracle 8.1 only) Rows Execution Plan INSERT STATEMENT GOAL: CHOOSE 0 SORT (UNIQUE) 0 FILTER 0 NESTED LOOPS 8 NESTED LOOPS NESTED LOOPS 360 NESTED LOOPS 10 NESTED LOOPS 10 TABLE ACCESS BY INDEX ROWID PS_PP_PAYMENT_TMP 11 INDEX (RANGE SCAN) (object id 9329) 20 INDEX (RANGE SCAN) OF (object id 8105) 360 TABLE ACCESS (BY INDEX ROWID) OF 'PS_SET_CNTRL_REC' 370 INDEX (RANGE SCAN) OF (object id 12020) TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUSTOMER' INDEX (RANGE SCAN) OF (object id 4751) INDEX (RANGE SCAN) OF 'PS#ITEM' (NON-UNIQUE) 8 TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUST_OPTION' 16 INDEX (RANGE SCAN) OF (object id 4854) 0 SORT (AGGREGATE) 0 TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUST_OPTION' 0 INDEX (RANGE SCAN) OF (object id 4854)

28 Execution plan (if you connect TKPROF to the database) Rows Execution Plan INSERT STATEMENT GOAL: CHOOSE 0 SORT (UNIQUE) 0 FILTER 0 NESTED LOOPS 8 NESTED LOOPS NESTED LOOPS 360 NESTED LOOPS 10 NESTED LOOPS 10 TABLE ACCESS (BY INDEX ROWID) OF 'PS_PP_PAYMENT_TMP' 11 INDEX (RANGE SCAN) OF 'PSAPP_PAYMENT_TMP' (NON-UNIQUE) 20 INDEX (RANGE SCAN) OF 'PSAPAYMENT_ID_ITEM' (NON-UNIQUE) 360 TABLE ACCESS (BY INDEX ROWID) OF 'PS_SET_CNTRL_REC' 370 INDEX (RANGE SCAN) OF 'PSBSET_CNTRL_REC' (NON-UNIQUE) TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUSTOMER' INDEX (RANGE SCAN) OF 'PS#CUSTOMER' (NON-UNIQUE) INDEX (RANGE SCAN) OF 'PS#ITEM' (NON-UNIQUE) 8 TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUST_OPTION' 16 INDEX (RANGE SCAN) OF 'PS_CUST_OPTION' (UNIQUE) 0 SORT (AGGREGATE) 0 TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUST_OPTION' 0 INDEX (RANGE SCAN) OF 'PS_CUST_OPTION' (UNIQUE)

29 1. Make the statement readable SELECT DISTINCT P.PROCESS_INSTANCE, P.DEPOSIT_BU, P.DEPOSIT_ID, P.PAYMENT_SEQ_NUM, C.CUST_ID, P.PAYMENT_AMT, P.PAYMENT_DT, O.PP_METHOD, O.SETID, C.SUBCUST_QUAL1, C.SUBCUST_QUAL2, O.PP_HOLD, 'N', P.PAYMENT_CURRENCY FROMPS_CUST_OPTION O, PS_ITEM I, PS_CUSTOMER C, PS_SET_CNTRL_REC S, PS_PAYMENT_ID_ITEM X, PS_PP_PAYMENT_TMP P WHEREP.PROCESS_INSTANCE = 212 AND S.RECNAME = 'CUSTOMER' AND S.SETID = C.SETID AND S.SETCNTRLVALUE = I.BUSINESS_UNIT AND I.CUST_ID = C.CUST_ID AND I.ITEM_STATUS = 'O' AND O.SETID = C.REMIT_FROM_SETID AND O.CUST_ID = C.REMIT_FROM_CUST_ID AND O.EFFDT = (SELECT MAX(Z.EFFDT) FROM PS_CUST_OPTION Z WHERE Z.SETID = O.SETID AND Z.CUST_ID = O.CUST_ID AND Z.EFF_STATUS = 'A' AND Z.EFFDT <= P.PAYMENT_DT) AND O.PP_METHOD <> ' ' AND P.DEPOSIT_BU = X.DEPOSIT_BU AND P.DEPOSIT_ID = X.DEPOSIT_ID AND P.PAYMENT_SEQ_NUM = X.PAYMENT_SEQ_NUM AND X.REF_QUALIFIER_CODE = 'I' AND X.REF_VALUE = I.ITEM

30 2. Start to draw the query

31 3. Put the joins in

32 4. Get the order from the plan 0 FILTER 0 NESTED LOOPS 8 NESTED LOOPS NESTED LOOPS 360 NESTED LOOPS 10 NESTED LOOPS 10 (1)TABLE ACCESS (BY INDEX ROWID) OF 'PS_PP_PAYMENT_TMP' 11 INDEX (RANGE SCAN) OF 'PSAPP_PAYMENT_TMP' (NON-UNIQUE) 20 (2)INDEX (RANGE SCAN) OF 'PSAPAYMENT_ID_ITEM' (NON-UNIQUE) 360 (3)TABLE ACCESS (BY INDEX ROWID) OF 'PS_SET_CNTRL_REC' 370 INDEX (RANGE SCAN) OF 'PSBSET_CNTRL_REC' (NON-UNIQUE) (4)TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUSTOMER' INDEX (RANGE SCAN) OF 'PS#CUSTOMER' (NON-UNIQUE) (5)INDEX (RANGE SCAN) OF 'PS#ITEM' (NON-UNIQUE) 8 (6)TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUST_OPTION' 16 INDEX (RANGE SCAN) OF 'PS_CUST_OPTION' (UNIQUE) 0 SORT (AGGREGATE) 0 TABLE ACCESS (BY INDEX ROWID) OF 'PS_CUST_OPTION' INDEX (RANGE SCAN) OF 'PS_CUST_OPTION' (UNIQUE)

33 5. Put the order in the diagram

34 6. This time, the answer is an index CREATE INDEX PSBITEM ON PS_ITEM (ITEM, CUST_ID, BUSINESS_UNIT, ITEM_STATUS) TABLESPACE PSINDEX STORAGE (INITIAL 10K NEXT 98K MAXEXTENTS 110 PCTINCREASE 0) /

35 New execution order

36 Statistics Before call count cpu elapsed disk query current rows Parse Execute Fetch total After call count cpu elapsed disk query current rows Parse Execute Fetch total

37 Theory & Practice Tuning Explain Plan SQL Trace TKPROF Graphical Technique How and what to trace a real system? Do you have access to the source code? Can you alter the code?

38 How to SQL_Trace PeopleSoft? Client Query/Crystal & Database Agent SQR Cobol AE nVision

39 Client Multithreaded 2-tier, 3-tier –Client trace - SQLcleanup.exe SQL Script Work in SQL*Plus –Small application server no PSQCKSRV or PSQRYSRV enable trace on PSAPPSRV

40 PS/Query, Crystal, Database Agent Trace Application Server –PSQRYSRV Cut and paste SQL PS/Query –work in SQL*Plus

41 nVision Trace PSQRYSRV Client trace & SQLcleanup.exe Cut and paste the statement directly

42 Mass Change

43 Application Engine

44 SQR session.sqc begin-sql ALTER SESSION SET SQL_TRACE=TRUE end-SQL

45 Cobol Difficult to add extra statements Batch Initiated via Process Scheduler –Data driven agent –Table of requests –Each request has a status

46 Cobol Trigger on process request table create or replace trigger sysadm.set_trace before update of runstatus on sysadm.psprcsrqst for each row when (new.runstatus = 7 and old.runstatus != 7 and new.prcstype = 'COBOL SQL' and new.prcsname = 'GLPJEDIT' and new.oprid = 'VP1' and new.servernamerqst = 'PSUNX' and new.rqstdttm <= TO_DATE(‘ ’,’DDMMYYYY’)) begin sys.dbms_session.set_sql_trace(true); exception when others then null; end; /

47 Trigger with log create or replace trigger sysadm.set_trace before update of runstatus on sysadm.psprcsrqst for each row when (new.runstatus = 7 and old.runstatus != 7 and not new.prcstype IN('Crystal','PSJob','Database Agent')) begin insert into dmk_trace_log (prcsinstance, oracle_shadow, timestamp) select :new.prcsinstance, p.spid, sysdate from v$session s, v$process p where s.sid = (select sid from v$mystat where rownum = 1) and s.paddr = p.addr; sys.dbms_session.set_sql_trace(true); exception when others then null; end; /

48 Autonomous Trigger New in Oracle 8.1 create or replace trigger sysadm.set_trace before update of runstatus on sysadm.psprcsrqst for each row when (new.runstatus = 7 and old.runstatus != 7 and not new.prcstype IN('Crystal','PSJob','Database Agent')) declare pragma autonomous_transaction; begin insert into dmk_trace_log (prcsinstance, oracle_shadow, timestamp) select :new.prcsinstance, p.spid, sysdate from v$session s, v$process p where s.sid = (select sid from v$mystat where rownum = 1) and s.paddr = p.addr; sys.dbms_session.set_sql_trace(true); commit; --only allowed & mandatory in autonomous trigger exception when others then null; end; /

49 Tuning with Oracle’s SQL Trace Tuning SQL Trace TKPROF Explain Plan Graphical Technique Techniques for enabling SQL Trace

50 Any Questions?

51 Tuning with Oracle’s SQL Trace David Kurtz Go-Faster Consultancy Ltd.