Tracing Individual Users in Connection-pooled Environments with Oracle 10g Terry Sutton Database Specialists, Inc. www.dbspecialists.com.

Slides:



Advertisements
Similar presentations
Database Administration Sessions. Identify the running Sessions The sessions can be identified using following objects. V$SESSION GV$SESSION Following.
Advertisements

Focusing Your Oracle Database Tuning Efforts For PeopleSoft Applications Bobby Durrett U. S. Foodservice, Inc.
Copyright © SoftTree Technologies, Inc. DB Tuning Expert.
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.
1 Wait Event Enhancements in Oracle 10g Terry Sutton and Roger Schrag Database Specialists, Inc.
Finding the Performance Bottlenecks in Your Application Ian Jones and Roger Schrag Database Specialists, Inc. IOUG-A Live! 1999 Paper.
Prligence Empowering Intelligence All About Fine Grained Access Control by Arup Nanda.
Royal London Group A group of specialist businesses where the bottom line is always financial sense Oracle Statistics – with a little bit extra on top.
Copyright © 200\8 Quest Software High Performance PL/SQL Guy Harrison Chief Architect, Database Solutions.
Oracle Architecture. Instances and Databases (1/2)
® IBM Software Group © 2010 IBM Corporation What’s New in Profiling & Code Coverage RAD V8 April 21, 2011 Kathy Chan
Query Manager. QM is a collection of tools you can use to obtain information from the AS/400 database Used to –select, arrange, and analyze information.
What is SDM? SDM : Server and Database Monitoring  SDM is the web-based real-time server and database monitoring and reporting tool  Service Items Server.
Harvard University Oracle Database Administration Session 2 System Level.
Managing an Oracle Instance
Advanced Databases Basic Database Administration Guide to Oracle 10g 1.
1 How to improve SQL Performance with new Health Check Tool? Carlos Sierra Consulting Technical Advisor © 2012 Oracle Corporation – Proprietary and Confidential.
1 Tuning PL/SQL procedures using DBMS_PROFILER 20-August 2009 Tim Gorman Evergreen Database Technologies, Inc. Northern California Oracle.
VMware vCenter Server Module 4.
ORACLE ONLINE TRAINING Contact our Support Team : SOFTNSOL India: Skype id : softnsoltrainings id:
Module 15: Monitoring. Overview Formulate requirements and identify resources to monitor in a database environment Types of monitoring that can be carried.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
5 Copyright © 2008, Oracle. All rights reserved. Configuring the Oracle Network Environment.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
2 Copyright © 2006, Oracle. All rights reserved. Performance Tuning: Overview.
Oracle Application Express 3.0 Joel R. Kallman Software Development Manager.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
#.1 Oracle Wait Interface in Oracle 10g. #.2 Today’s Session  Twelve wait event interface enhancements in Oracle 10g that we really like.  Documentation.
Taught by Mohamed Kassim
5 Copyright © 2004, Oracle. All rights reserved. Using Recovery Manager.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
M1G Introduction to Database Development 6. Building Applications.
Deadlocks For $1000: Let’s Play Jeopardy! Iggy Fernandez Database Specialists, Inc. TCOUG Fall Meeting 2008.
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.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Java Portals and Portlets Submitted By: Rashi Chopra CIS 764 Fall 2007 Rashi Chopra.
© IBM Corporation 2005 Informix User Forum 2005 John F. Miller III Explaining SQLEXPLAIN ®
1 Chapter Overview Planning to Install SQL Server 2000 Deciding SQL Server 2000 Setup Configuration Options Running the SQL Server 2000 Setup Program Using.
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.
3 Copyright © 2006, Oracle. All rights reserved. Using Recovery Manager.
ASEMON JEAN-PAUL MARTIN May 2015.
Tools for Analyzing Problems in Oracle Applications Jeff Slavitz (415)
Hyperion Artifact Life Cycle Management Agenda  Overview  Demo  Tips & Tricks  Takeaways  Queries.
Optimization and Administartion of a Database Management Systems Krystian Zieja.
21 Copyright © 2008, Oracle. All rights reserved. Enabling Usage Tracking.
Introduction to Utilities for New DBAs Session #332 4/19/2008 Erik Hobbs Introduction to Utilities for New DBAs.
2 Copyright © 2004, Oracle. All rights reserved. Running a Forms Developer Application.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
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.
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
9 Copyright © 2004, Oracle. All rights reserved. Getting Started with Oracle Migration Workbench.
Oracle Database Architectural Components
Welcome to IBC233 Cindy Laurin And Russ Pangborn.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
3 Copyright © Oracle Corporation, All rights reserved. 管理数据库事例.
SQL Trace and TKPROF.
SQL Server Monitoring Overview
Introduction of Week 3 Assignment Discussion
RAC Performance Lab.
Backup Monitoring – EMC NetWorker
Backup Monitoring – EMC NetWorker
Wait Event Enhancements in Oracle 10g
Performance Tuning ETL Process
Presentation transcript:

Tracing Individual Users in Connection-pooled Environments with Oracle 10g Terry Sutton Database Specialists, Inc.

Session Objectives  Discuss the concepts behind logical session tracing in Oracle 10g.  See how minor application changes can make logical session tracing of production systems very easy.  Follow a real-life example of how an end-user’s actions in a web-based application can be traced and reported with TKPROF as easily as if the end-user were running a client/server application.

Extended SQL Trace  Provides detailed info about what a database session is doing, including: –SQL statements being executed –Logical & Physical Reads session is performing for each query –Waits- what the session is waiting on and for how long  Works well in Client-Server configuration

Background Trace your own session: –EXECUTE SYS.DBMS_SUPPORT.START_TRACE –ALTER SESSION SET events '10046 trace name context forever, level 12'; Trace another session: –EXECUTE SYS.DBMS_SUPPORT.START_TRACE_IN_SESSION (sid, serial#) –oradebug setorapid [Oracle PID from v$process] oradebug session_event trace name context forever, level 8 –EXECUTE SYS.DBMS_SYSTEM.SET_EV (sid, serial#, 10046, 8, '')

 Trace file created: –dbrxprd_ora_10786.trc  Then use TKPROF (or another profiler) to create a report: –tkprof dbrxprd_ora_10786.trc test_report.txt waits=yes

BUT— The World Now  Connection pooled environments  Shared (Multi-Threaded) Server  Application Server multiplexing many end-user sessions into (relatively) few DB connections  One end-user session can bounce around among multiple DB session connections

A Shotgun Approach To get a look at SQL generated by “system”, use shotgun approach: SPOOL traceall.sql SELECT 'EXECUTE SYS.dbms_system.set_ev (' || TO_CHAR (sid) || ', ' || TO_CHAR (serial#) || ', 10046, 8, '''')' FROM v$session WHERE username = 'WEB_USER'; SPOOL

Oracle 10g Enhancements The DBMS_MONITOR Package –Trace your own session: dbms_monitor.session_trace_enable(waits=>true, binds=>true) –Trace another session: dbms_monitor.session_trace_enable(, waits=>true, binds=>true) Waits=>true, binds=>false is default

Oracle 10g Enhancements The DBMS_MONITOR Package (cont.) DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE

Oracle 10g Enhancements The trcsess Utility To combine multiple trace files. trcsess [output= ] [session= ] [clientid= ] [service= ] [action= ] [module= ]

Real Life Example Database Rx web portal

After the login, correlate the cookie in the user’s browser to an active session begin select w.user_id, w.login_date, w.active_instance_id into p_current_user_rec.user_id, v_login_date, p_current_user_rec.active_instance_id from web_active_sessions w where w.session_key = ltrim(rtrim(p_session_id)); … some other code checking authorization & such … Set the client identifier in the Oracle database session to -- match the session key for easy tracing and instrumentation. -- set_ora_session_id (LTRIM (RTRIM (p_session_id))); end;

set_ora_session_id procedure -- Set the session identifier attributed to the current database session. -- PROCEDURE set_ora_session_id (p_session_id IN VARCHAR2) IS BEGIN dbms_session.set_identifier (p_session_id); END set_ora_session_id;

At the end of each page, the following code is executed -- Clear the client identifier in the Oracle database session so that it -- no longer matches the session key for easy tracing and instrumentation. -- psputil.clear_ora_session_id; The clear_ora_session_id procedure is: -- Clear the session identifier attributed to the current database session. -- PROCEDURE clear_ora_session_id IS BEGIN dbms_session.clear_identifier; END clear_ora_session_id;

After login, user goes to Instance List Page

Turn on Tracing SQL> select user_id from customer_users where username = 'tsutton' USER_ID SQL> select * from web_active_sessions where user_id=100003; SESSION_KEY USER_ID ACTIVE_INST LOGIN_DATE DEC-06 14:41:54 We see that the session_key that has been assigned to this user is So we enable tracing for this user: SQL> exec dbms_monitor.client_id_trace_enable(' ') PL/SQL procedure successfully completed.

Check the user_dump_dest directory $ cd /u01/app/oracle/admin/dbrxprd/udump /u01/app/oracle/admin/dbrxprd/udump $ date Thu Dec 21 14:47:41 PST 2006 /u01/app/oracle/admin/dbrxprd/udump $ ls -lt total rw-r oracle dba 6631 Dec 17 00:14 dbrxprd_ora_10786.trc -rw-r oracle dba Dec 16 05:09 dbrxprd_ora_7959.trc -rw-r oracle dba Dec 16 01:13 dbrxprd_ora_7706.trc -rw-r oracle dba 6630 Dec 10 00:14 dbrxprd_ora_14396.trc

 We’ll look at: –Instance Status Report –Tablespace Size Report –Database Growth Report –Execution Plan Changes Report Now the End-user Goes Through Some Reports

Instance Status

Tablespace Size

Database Growth

Execution Plan Changes

Turn Off Tracing Now the user logs out, and we turn off tracing: SQL> exec dbms_monitor.client_id_trace_disable(' ') PL/SQL procedure successfully completed. DBA_ENABLED_TRACES will show any traces currently enabled.

Check the user_dump_dest directory /u01/app/oracle/admin/dbrxprd/udump $ date Thu Dec 21 15:17:10 PST 2006 /u01/app/oracle/admin/dbrxprd/udump $ ls -lt total rw-r oracle dba Dec 21 14:50 dbrxprd_ora_1887.trc -rw-r oracle dba Dec 21 14:49 dbrxprd_ora_1149.trc -rw-r oracle dba Dec 21 14:49 dbrxprd_ora_1826.trc -rw-r oracle dba Dec 21 14:48 dbrxprd_ora_1110.trc -rw-r oracle dba 6631 Dec 17 00:14 dbrxprd_ora_10786.trc -rw-r oracle dba Dec 16 05:09 dbrxprd_ora_7959.trc -rw-r oracle dba Dec 16 01:13 dbrxprd_ora_7706.trc -rw-r oracle dba 6630 Dec 10 00:14 dbrxprd_ora_14396.trc

Use trcsess to consolidate the 4 trace files into one /u01/app/oracle/admin/dbrxprd/udump $ trcsess output=test1.trc \ clientid=' ' *.trc /u01/app/oracle/admin/dbrxprd/udump $ date Thu Dec 21 15:22:44 PST 2006 /u01/app/oracle/admin/dbrxprd/udump $ ls -lt total rw-r--r-- 1 oracle dba Dec 21 15:22 test1.trc -rw-r oracle dba Dec 21 14:50 dbrxprd_ora_1887.trc -rw-r oracle dba Dec 21 14:49 dbrxprd_ora_1149.trc -rw-r oracle dba Dec 21 14:49 dbrxprd_ora_1826.trc -rw-r oracle dba Dec 21 14:48 dbrxprd_ora_1110.trc -rw-r oracle dba 6631 Dec 17 00:14 dbrxprd_ora_10786.trc -rw-r oracle dba Dec 16 05:09 dbrxprd_ora_7959.trc -rw-r oracle dba Dec 16 01:13 dbrxprd_ora_7706.trc -rw-r oracle dba 6630 Dec 10 00:14 dbrxprd_ora_14396.trc

Then use TKPROF to get a report /u01/app/oracle/admin/dbrxprd/udump $ tkprof test1.trc test1.out TKPROF: Release Production on Thu Dec 21 15:28: Copyright (c) 1982, 2004, Oracle. All rights reserved. /u01/app/oracle/admin/dbrxprd/udump $ ls -lt total rw-r--r-- 1 oracle dba Dec 21 15:28 test1.out -rw-r--r-- 1 oracle dba Dec 21 15:22 test1.trc -rw-r oracle dba Dec 21 14:50 dbrxprd_ora_1887.trc -rw-r oracle dba Dec 21 14:49 dbrxprd_ora_1149.trc -rw-r oracle dba Dec 21 14:49 dbrxprd_ora_1826.trc -rw-r oracle dba Dec 21 14:48 dbrxprd_ora_1110.trc

Here are some pieces of the TKPROF report TKPROF: Release Production on Thu Dec 21 15:28: Copyright (c) 1982, 2004, Oracle. All rights reserved. Trace file: test1.trc Sort options: default

The Instance Status Report SELECT A.INSTANCE_ID, HTF.ESCAPE_SC(A.INSTANCE_NICKNAME) INSTANCE_NICKNAME, HTF.ESCAPE_SC(B.CURRENT_INSTANCE_NAME) CURRENT_INSTANCE_NAME, B.INSTANCE_KEY, A.CURRENT_CUST_USER_PRIV_LEVEL, A.USER_WISHES_TO_SEE, B.MOST_SEVERE_ALERT_OR_EVENT FROM CUSTOMER_USER_INSTANCE_PRIVS A, CUSTOMER_INSTANCES B WHERE A.USER_ID = :B1 AND B.INSTANCE_ID = A.INSTANCE_ID ORDER BY A.DISPLAY_ORDER, LOWER (NVL (A.INSTANCE_NICKNAME, B.CURRENT_INSTANCE_NAME)), A.INSTANCE_ID call count cpu elapsed disk query current rows Parse Execute Fetch total Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 40 (recursive depth: 1)

The Tablespace Size Report SELECT B.TABLESPACE_NAME, C.DATA_FILE_COUNT, C.TEMP_FILE_COUNT, C.AUTOEXTENSIBLE, A.CURRENT_SIZE_IN_BYTES, A.CURRENT_SIZE_IN_BYTES - A.CURRENT_TOTAL_BYTES_FREE BYTES_USED, 100 * (A.CURRENT_TOTAL_BYTES_FREE / A.CURRENT_SIZE_IN_BYTES) PERCENT_FREE, A.CURRENT_BIGGEST_BYTES_FREE, A.BIGGEST_NEXT_DESIRED FROM SAMPLE_TABLESPACES A, COMMON_TABLESPACES B, ( SELECT D.COMMON_TABLESPACE_ID, DECODE (MAX (E.AUTOEXTENSIBLE), 'YES', 'Yes', 'NO', 'No', NULL, 'No', MAX (E.AUTOEXTENSIBLE)) AUTOEXTENSIBLE, SUM (DECODE (E.TEMP_FILE, 'YES', 0, 1)) DATA_FILE_COUNT, SUM (DECODE (E.TEMP_FILE, 'YES', 1, 0)) TEMP_FILE_COUNT FROM SAMPLE_DATA_FILES D, COMMON_DATA_FILES E WHERE D.SAMPLE_ID = :B1 AND E.COMMON_DATA_FILE_ID = D.COMMON_DATA_FILE_ID GROUP BY D.COMMON_TABLESPACE_ID ) C WHERE A.SAMPLE_ID = :B1 AND B.COMMON_TABLESPACE_ID = A.COMMON_TABLESPACE_ID AND C.COMMON_TABLESPACE_ID = B.COMMON_TABLESPACE_ID ORDER BY B.TABLESPACE_NAME

The Tablespace Size Report (continued) call count cpu elapsed disk query current rows Parse Execute Fetch total Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 40 (recursive depth: 1) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited Waited db file sequential read

The Database Growth Report SELECT A.SAMPLE_DATE_DB_LOCAL_TIME, C.CURRENT_SIZE_IN_BYTES, C.CURRENT_TOTAL_BYTES_FREE, C.CURRENT_SIZE_IN_BYTES - C.CURRENT_TOTAL_BYTES_FREE, C.CURRENT_SIZE_IN_BYTES / :B5, (C.CURRENT_SIZE_IN_BYTES - C.CURRENT_TOTAL_BYTES_FREE) / :B5 FROM ( SELECT A1.INSTANCE_ID, 'full_stat' SAMPLE_TYPE, MIN (A1.SAMPLE_DATE_DB_LOCAL_TIME) SAMPLE_DATE_DB_LOCAL_TIME FROM SAMPLES A1 WHERE A1.INSTANCE_ID = :B3 AND A1.SAMPLE_SEQUENCE BETWEEN :B2 AND :B1 AND A1.SAMPLE_TYPE = 'full_stat' GROUP BY A1.INSTANCE_ID, TRUNC (A1.SAMPLE_DATE_DB_LOCAL_TIME) ) A, SAMPLES B, SAMPLE_TABLESPACES C WHERE B.INSTANCE_ID = A.INSTANCE_ID AND B.SAMPLE_TYPE = A.SAMPLE_TYPE AND B.SAMPLE_DATE_DB_LOCAL_TIME = A.SAMPLE_DATE_DB_LOCAL_TIME AND C.SAMPLE_ID = B.SAMPLE_ID AND C.COMMON_TABLESPACE_ID = :B4 ORDER BY A.SAMPLE_DATE_DB_LOCAL_TIME DESC

The Database Growth Report (continued) call count cpu elapsed disk query current rows Parse Execute Fetch total Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 40 (recursive depth: 1) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited Waited db file sequential read

The Execution Plan Changes Report SELECT A.HASH_VALUE, A.SQL_ID, A.PARSING_USER_ID, A.COMMON_SQL_TEXT_ID, COUNT(UNIQUE(A.PLAN_HASH_VALUE)) PLAN_CNT FROM SAMPLE_SQL_TEXTS A, SAMPLES B WHERE B.SAMPLE_SEQUENCE BETWEEN :B3 AND :B2 AND B.INSTANCE_ID = :B1 AND B.SAMPLE_ID = A.SAMPLE_ID AND A.PLAN_HASH_VALUE > 0 GROUP BY A.HASH_VALUE, A.SQL_ID, A.PARSING_USER_ID, A.COMMON_SQL_TEXT_ID HAVING COUNT(UNIQUE(A.PLAN_HASH_VALUE)) > 1 ORDER BY A.SQL_ID, A.HASH_VALUE

The Execution Plan Changes Report (continued) call count cpu elapsed disk query current rows Parse Execute Fetch total Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 40 (recursive depth: 1) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited Waited db file sequential read

TKPROF Summary Section OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows Parse Execute Fetch total Misses in library cache during parse: 0

TKPROF Summary Section (continued) OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows Parse Execute Fetch total Misses in library cache during parse: 125 Misses in library cache during execute: 108 Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited Waited db file sequential read db file scattered read user SQL statements in session. 598 internal SQL statements in session. 779 SQL statements in session.

What about MTS? With Shared Server (formerly Multi Threaded Server:  Tracing by client_id does NOT work.  But tracing by Session ID does.  Trace files are in background_dump_dest  Session ID is SID.SERIAL# from v$session: trcsess output=output.trc session= *.trc

Conclusion Oracle 10g has several enhancements to help with end- user session tracing: –DBMS_MONITOR Package (easier to use) –Ability to trace individual client session, or by service/module/action –trcsess utility to consolidate relevant portions of multiple trace files We’ve seen: –How a client session can be marked with a client_id so it can later be identified –How to enable tracing for a client session using this client_id. –How to consolidate the multiple trace files generated by the trace

The White Paper A companion white paper to this presentation is available for free download from our company’s website at:

About Database Specialists  Database Specialists, Inc. provides Oracle database consulting in Solaris, Linux, HP-UX, AIX, and Windows environments.  Our DBA Pro offering and Database Rx™ tools provide remote database support and 24/7 coverage at an attractive price point.  Our Oracle DBAs each have a minimum of 10 years of Oracle experience.  Database Specialists is US-based. Database Specialists helps you increase uptime, improve performance, minimize risk, and reduce costs

Tracing Individual Users in Connection-pooled Environments with Oracle 10g Terry Sutton Database Specialists, Inc /