Royal London GroupA group of specialist businesses where the bottom line is always financial sense
Oracle Statistics – with a little bit extra on topLise ParkerTechnical DesignerScottish Life – part of The Royal London Group
1
2
Agenda
IntroductionSome background about my company, me and how we use OracleDatabase StatisticsWhat are they and what can they tell you?
Bridging The GapWhat we’ve done to better understand individual code behaviourThe End!Questions?
Royal London GroupA group of specialist businesses where the bottom line is always financial sense
IntroductionAbout Royal London and Scottish LifeAbout MeAbout the Database and Application
3
4
• UK’s largest mutual (customer-owned) Life and Pensions provider
• Multi-brand business run as separate business units
• 2,880* employees, primarily UK-based with main offices in Edinburgh, Wilmslow and London
• £46.8 billion* of funds under management
• Around 4 million customers*
About Royal London
* As at 31st March 2012
Introduction
5
About Scottish Life
• Founded in 1881, acquired by Royal London in 2001
• Pension specialist
• Internal business users on two UK sites
• Core business applications primarily developed in-house including secure web application for external customers and business partners
Introduction
6
About Me
• Worked with Oracle databases and tools since 1996
• Work within the Technical Architecture & Design team
• Provide specialised technical support for Scottish Life Oracle development teams covering both database and code
Introduction
7
About the Database• Main policy administration application uses Oracle
11gR1 database and PL/SQL for business logic
• Complex application landscape with multiple integrations
• One production database supporting OLTP during day time and batch during night time– c. 1k concurrent users per hour– c. 1m online transactions per day– c. 350 batch reports per night
• Multiple concurrent batch streams with complex dependencies
Large database interaction variation between online and batch scenarios
Introduction
8
About the Applications
WindowsWeb Servers
DMZ InternetInternal Network
Unix Database Servers
Oracle
Windows Database Servers
MS SQL
WindowsApplication Servers
ExternalUsers
(Financial Advisers, Employers, Employees/
Policyholders)
External BusinessPartners
InternalUsers
Firewall Firewall
Introduction
Royal London GroupA group of specialist businesses where the bottom line is always financial sense
Database StatisticsWhy do we need them? What do you get “out the box”?What can they tell us?What else is available?
9
10
Why do we need them?
• Customers expectations of information accessibility have changed as a result of the internet
• There’s an expectation to receive information:– via multiple channels– in real-time– quickly
• The database can be a bottleneck if performance is not understood and managed effectively on an on-going basisKey to ensure that database performance doesn’t constrain our business
proposition designs and customer experiences
Database Statistics
11
What’s available “out the box”
• Real time data to historical data
• AWR
Statistics are available as both real time and historical data
• Cumulative values• Metrics• Sampled data (ASH)
Database Statistics
12
-- Top 10 CPU consumers in the last 5 minsSELECT *FROM (SELECT session_id ,session_serial# ,COUNT(*) FROM v$active_session_history WHERE session_state = 'ON CPU' AND sample_time > SYSDATE - INTERVAL '5' minute GROUP BY session_id ,session_serial# ORDER BY COUNT(*) DESC)WHERE rownum <= 10;
-- Top 10 waiting sessions in the last 5 minsSELECT *FROM (SELECT session_id ,session_serial# ,COUNT(*) FROM v$active_session_history WHERE session_state = 'WAITING' AND sample_time > SYSDATE - INTERVAL '5' minute GROUP BY session_id ,session_serial# ORDER BY COUNT(*) DESC)WHERE rownum <= 10;
-- Who is the SID?SELECT serial# ,username ,osuser ,machine ,program ,resource_consumer_group ,client_infoFROM v$sessionWHERE sid = &sid;
SERIAL# USERNAME OSUSER MACHINE PROGRAM RESOURCE_CONSUMER_GROUP
CLIENT_INFO
55055 LLL01BCH lll01bch mercury UT9051@mercury (TNS V1-V3)
OTHER_GROUPS
-- What did the SID do?SELECT DISTINCT sql_id ,session_serial#FROM v$active_session_historyWHERE sample_time > SYSDATE - INTERVAL '5' minuteAND session_id = &sid;
SQL_ID SESSION_SERIAL#
6w4rhtrt95r7q 55055
2ap8g8jyak8wd 55055
2c32bv0km2q8k 55055
SESSION_ID SESSION_SERIAL# COUNT(*)
1468 1 74
552 55055 55
572 8117 11
SESSION_ID SESSION_SERIAL# COUNT(*)
552 55055 298
2197 43291 298
1432 16820 210
-- Retrieve the SQL from the Library Cache:SELECT sql_text FROM v$sql WHERE sql_id = '&sqlid';
What can they tell us – real-time?
Real time data continuously updated whilst database is open and in use (v$)
Database Statistics
SQL_TEXT
select /*+ first_rows index_desc(PA020 PA020_AM) */ AUDAPLCDE, AUDSTF_NO, AUDUPD_ID, AUDUPDDTE, AUDUPDTME, CLICAT, CLIREF, CRGAMT, CRGIND, EFVDTE, ENDDTE, FNDTRNTYP, FRQ, INRREF, INRTYP, MAINT, ORIDTE, PCSSTG, PNTTRN_NO, POLREF, RE_APLIND, RHTTYP, ROLREF, SPSDTE, STA_PA, STGSWHDTE, STMLOC, STMRSN, STRDTE, TRNCTL_NO, TRNSUBTYP, UNTSTM_NO, WDRAMT, WDRPCT, UNIQUE_ID from PA020 where POLREF = :k_POLREF and ( ( TRNCTL_NO <= :k_TRNCTL_NO ) ) order by POLREF ,TRNCTL_NO desc
13
-- Top 10 waiting sessions for a specific time periodSELECT *FROM (SELECT session_id ,session_serial# ,COUNT(*) FROM dba_hist_active_sess_history WHERE session_state = ‘WAITING' AND sample_time BETWEEN TO_DATE('01-june-2012 14','dd-mon-yyyy hh24') AND TO_DATE('01-june-2012 16','dd-mon-yyyy hh24') GROUP BY session_id ,session_serial# ORDER BY COUNT(*) DESC)WHERE rownum <= 10;
-- Top 10 CPU consumers for a specific time periodSELECT *FROM (SELECT session_id ,session_serial# ,COUNT(*) FROM dba_hist_active_sess_history WHERE session_state = 'ON CPU' AND sample_time BETWEEN TO_DATE('01-june-2012 14','dd-mon-yyyy hh24') AND TO_DATE('01-june-2012 16','dd-mon-yyyy hh24') GROUP BY session_id ,session_serial# ORDER BY COUNT(*) DESC)WHERE rownum <= 10;
-- What did the SID do?SELECT DISTINCT sql_id ,session_serial#FROM dba_hist_active_sess_historyWHERE sample_time BETWEEN TO_DATE('01-june-2012 14', 'dd-mon-yyyy hh24') AND TO_DATE('01-june-2012 16', 'dd-mon-yyyy hh24')AND session_id = &sid;
-- Retrieve the SQL from the Library CacheSELECT sql_text FROM dba_hist_sqltext WHERE sql_id = '&sqlid';
What can they tell us – historical?Database Statistics
Real time data available for set amount of days (DBA_HIST)
SESSION_ID SESSION_SERIAL# COUNT(*)
1898 35788 42
624 29854 16
1178 47367 12
SESSION_ID SESSION_SERIAL# COUNT(*)
1469 1 96
2176 21427 19
2197 18141 16
SQL_TEXT
Begin EN500_P.EN500_STARTUP(:v0, :v1, :v2, :v3, :v4, :v5, :v6, :v7, :v8, :v9, :v10, :v11, :v12, :v13, :v14, :v15, :v16, :v17, :v18, :v19, :v20, :v21, :v22, :v23, :v24, :v25, :v26, :v27, :v28); End;
14
What else is available?
• DBMS_APPLICATION_INFO– Oracle package used to record the names of the
executing modules or transactions in the database. – These settings are very useful when it comes to
tracking performance.– Set MODULE and ACTION sensibly throughout your
code structure.• Profiling at run time:– Wrap the DBMS_APPLICATION_INFO within a PL/SQL
package.– If profiling then record every setting of the MODULE
and ACTION in a table.
Database Statistics
Consider use of DBMS_APPLICATION_INFO in your application designs
Royal London GroupA group of specialist businesses where the bottom line is always financial sense
Bridging The GapOur problemWhat we had and what we wantedThe additional frameworkThe GUI we have built
15
16
• Some examples of questions that we needed to answer:– The marketing department wants to know how long
it takes to produce a statement from the web at the busiest time.
– How can I decide on what to tune that will reduce the overall batch window?
– The batch is starting to take longer and longer to run. What is causing this?
Our problemBridging The Gap
Very difficult to identify relevant data from global database statistics
17
PL/SQLSQL
What we had and what we wanted
PL/SQLSQL
Needed statistics relevant to specific business processes
Process A
Process C
Process B
Process D
Process E
Process F
Process G
SegmentsSQL statements
TransactionsCPU I/O
ASH
AWR
PL/SQLSQL
Bridging The Gap
Process A
Process C
Process B
Process D
Process E
Process F
Process G
Process Name
Oracle Stats
User Stats
Process A v$mystat user-defined
Process B v$mystat user-defined
...
SegmentsSQL
statementsTransactions
CPU I/O
ASH
AWR
18
Application A
ProcessProcess
Process
Application C
ProcessProcess
Process
Application D
ProcessProcess
Process
Application B
ProcessProcess
Process
The additional framework
ProcessProcessProcessDB
Bridging The Gap
Process Statistics Framework
PROCESS_MASTER
PROCESS_STATS
PROCESS_STATS_ENTRIES
PROCESS_CONTROL_PARAMETERS
19
Process Data Analysis ToolBridging The Gap
This slide had a movie showing you our Process Stats GUI tool. Instead I have added a few slides showing you screen dumps of this GUI tool so you still have an idea of how we did it.
25
Summary
• Things to consider:– Invest some time to better understand what Oracle
statistics “out the box” can tell you about your database behaviour
– Is there anything “extra on top” you could add that would provide additional benefit to your particular environment
– How you could design your application code to integrate with the Oracle statistics framework
– How you can make the statistics information available to developers to help them improve their query designs
Be proactive, not reactive!
Royal London GroupA group of specialist businesses where the bottom line is always financial sense
Any questions?Lise [email protected]
?
Top Related