Presentation is loading. Please wait.

Presentation is loading. Please wait.

Олег Коротков AWR, ASH - use cases and 11.2 enhancements.

Similar presentations


Presentation on theme: "Олег Коротков AWR, ASH - use cases and 11.2 enhancements."— Presentation transcript:

1 Олег Коротков AWR, ASH - use cases and 11.2 enhancements

2 Олег Коротков Agenda - Automatic Workload Repository (AWR) - Basic ideas - dba_hist% views enhancements - AWR use cases & limitations - Active Session History (ASH) - Basic ideas enhancements - Typical use cases

3 Олег Коротков Agenda - Automatic Workload Repository (AWR) - Basic ideas - dba_hist% views enhancements - AWR use cases & limitations - Active Session History (ASH) - Basic ideas enhancements - Typical use cases

4 Олег Коротков Automatic Workload Repository Oracle Database performance diagnostics tools evolution: - UTLBSTAT/UTLESTAT - STATSPACK (starting from Oracle 8i) - AWR (starting from Oracle 10g) But the idea is the same…

5 Олег Коротков Automatic Workload Repository Oracle has a lot of operational statistics/metrics gathered since the instance startup.

6 Олег Коротков Automatic Workload Repository SQL> select inst_id, name, value from gv$sysstat where name in ('physical reads','session logical reads','user commits','user rollbacks') order by name, inst_id; INST_ID NAME VALUE physical reads physical reads session logical reads session logical reads E+10 1 user commits user commits user rollbacks user rollbacks All stattistics: select * from v$statname; = 387; = = 628

7 Олег Коротков Automatic Workload Reports SQL> select inst_id, event, total_waits, time_waited, average_wait, sum(time_waited_micro) over (partition by event) twm_total from gv$system_event where wait_class='User I/O' order by twm_total desc, event, inst_id; INST_ID EVENT TOTAL_WAITS TIME_WAITED AVERAGE_WAIT TWM_TOTAL db file sequential read E+12 2 db file sequential read E+12 1 direct path read temp E+11 2 direct path read temp E+11 1 direct path read E+10 2 direct path read E All events: select count(*) from v$event_name; = 889; = = 1142

8 Олег Коротков Automatic Workload Repository SQL> select sql_id, execs, rw, LIOs, PhIOs from ( 2 select sql_id, /*sql_text,*/ sum(executions) execs, 3 sum(rows_processed) rw, sum(buffer_gets) LIOs, sum(disk_reads) PhIOs 4 from gv$sql 5 where module='SQL Developer' and rownum>=1 6 group by sql_id/*, sql_text*/ 7 order by PhIOs desc) 8 where rownum<=5; SQL_ID EXECS RW LIOS PHIOS w1fk8r93360m davt444np8yr b775q3tc69a kz178ugwm ayaq4d3bbt7k

9 Олег Коротков Automatic Workload Repository AWR just makes a copy of system views with scheduled time interval… … and gives a possibility to make a report (diff) based on two snapshots. gv$sysstat gv$system _event … gv$sql Snap at 8 AM; done by MMON gv$sysstat gv$system _event … gv$sql Snap at 9 AM DB activity [8AM, 9AM]

10 Олег Коротков Automatic Workload Repository AWR configuration. - Oracle Diagnostic Pack is required (Oracle EE additional option). - STATISTICS_LEVEL = TYPICAL or ALL - (11g) CONTROL_MANAGEMENT_PACK_ACCESS = DIAGNOSTIC or DIAGNOSTIC+TUNING

11 Олег Коротков Automatic Workload Repository AWR configuration. SQL> select * from dba_hist_wr_control; DBID SNAP_INTERVAL RETENTION TOPNSQL :00: :00:00.0 DEFAULT To change: dbms_workload_repository.modify_snapshot_settings( retention=>129600, -- New retention time (in minutes). 60*24*90= interval=>30, -- New interval setting between each snapshot, in units of minutes topnsql=>50 – Number ; 'DEFAULT', 'MAXIMUM' )

12 Олег Коротков Automatic Workload Repository Create (additional) snapshot: dbms_workload_repository.create_snapshot('ALL') -- flush_level = 'TYPICAL' or 'ALL‘ SQL> select dbms_workload_repository.create_snapshot from dual; CREATE_SNAPSHOT SQL> select dbms_workload_repository.create_snapshot('ALL') from dual; DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT('ALL') SQL> select snap_id, count(*) from dba_hist_sqlstat where snap_id in (7762,7763) group by snap_id; SNAP_ID COUNT(*)

13 Олег Коротков Automatic Workload Repository Generate report across two snapshots: select * from table( dbms_workload_repository.awr_report_text( , -- DBID 1, -- instance number 38392, -- ‘Begin Snapshot’ ID 38393, -- ‘End Snapshot’ ID 0) -- flag = 0 or 8 (display ADDM specific parts) ); -- ADDM sections: Buffer Cache Advisory (for ADDM); SGA Target Advisory (for ADDM); Shared Pool Advisory (for ADDM); Streams Pool Advisory (for ADDM); PGA Target Advisory (for ADDM) There is a similar awr_report_html() function.

14 Олег Коротков Automatic Workload Repository AWR report (fragments) 1/8: WORKLOAD REPOSITORY report for DB Name DB Id Instance Inst Num Startup Time Release RAC XXXXX ###### 1 09-Oct-11 20: YES Host Name Platform CPUs Cores Sockets Memory(GB) ###### Linux x86 64-bit Snap Id Snap Time Sessions Curs/Sess Begin Snap: Feb-12 08:00: End Snap: Feb-12 09:00: Elapsed: (mins) DB Time: (mins) 11.2 new data/format

15 Олег Коротков Automatic Workload Reports AWR reports 2/8: Load Profile Per Second Per Transaction Per Exec Per Call ~~~~~~~~~~~~ DB Time(s): DB CPU(s): Redo size: 167, ,585.9 Logical reads: 70, ,694.0 Block changes: Physical reads: 3, Physical writes: User calls: Parses: Hard parses: W/A MB processed: Logons: Executes: Rollbacks: Transactions: 8.1

16 Олег Коротков Automatic Workload Repository AWR report 3/8: Top 5 Timed Foreground Events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Avg wait % DB Event Waits Time(s) (ms) time Wait Class db file sequential read 618,214 4, User I/O DB CPU 4, direct path read temp 810,891 1, User I/O enq: TX - row lock contention Applicatio log file sync 29, Commit Host CPU (CPUs: 8 Cores: 8 Sockets: 4) ~~~~~~~~ Load Average Begin End %User %System %WIO %Idle Instance CPU ~~~~~~~~~~~~ % of total CPU for Instance: 15.0 % of busy CPU for Instance: 51.3

17 Олег Коротков Automatic Workload Reports AWR reports 4/8: Wait Event Histogram DB/Inst: ######/###### Snaps: % of Waits Total Event Waits 1s db file sequential read Waits 64ms Event to 2s =2s db file sequential read Waits 4s Event to 2m =2m db file sequential read

18 Олег Коротков Automatic Workload Repository AWR report 5/8: SQL ordered by Elapsed Time DB/Inst: ######/##### Snaps: Elapsed Elapsed Time Time (s) Executions per Exec (s) %Total %CPU %IO SQL Id , c8sz91kt214t Module: JDBC Thin Client MERGE INTO … 3, N/A q694rv7gzkzs Module: SQL*Plus SELECT count(*) FROM …

19 Олег Коротков Automatic Workload Repository AWR report 6/8: SQL ordered by Elapsed Time SQL ordered by CPU Time SQL ordered by User I/O Wait Time SQL ordered by Gets SQL ordered by Reads SQL ordered by Physical Reads (UnOptimized) -> UnOptimized Read Reqs = Physical Read Reqts - Optimized Read Reqs SQL ordered by Executions SQL ordered by Parse Calls SQL ordered by Sharable Memory SQL ordered by Version Count SQL ordered by Cluster Wait Time

20 Олег Коротков Automatic Workload Repository AWR report 7/8: IOStat by Function summary DB/Inst: #####/##### Snaps: Reads: Reqs Data Writes: Reqs Data Waits: Avg Function Name Data per sec per sec Data per sec per sec Count Tm(ms) Direct Reads 45.5G M 0.0 0M 0 N/A Buffer Cache Re 2.4G M 0.0 0M 619.1K 7.1 DBWR 0M 0.0 0M 1.7G N/A TOTAL: 48.9G G K 6.3 IOStat by Filetype summary DB/Inst: #####/##### Snaps: Reads: Reqs Data Writes: Reqs Data Small Large Filetype Name Data per sec per sec Data per sec per sec Read Read Temp File 39.6G M 0.0 0M 1.6 N/A Data File 8.4G G TOTAL: 48.9G G IOStat by Function/Filetype summary

21 Олег Коротков Automatic Workload Repository AWR report 8/8: Segments by Physical Reads Segments by Physical Read Requests Segments by UnOptimized Reads Segments by Optimized Reads Segments by Direct Physical Reads Segments by Physical Writes Segments by Physical Write Requests Segments by Direct Physical Writes Segments by Table Scans Segments by DB Blocks Changes + enhanced RAC (interconnect, DRM) statistics

22 Олег Коротков Automatic Workload Repository Other AWR reports/procedures: Dbms_workload_repository package: ASH_report_text (ASH_report_html) ASH_global_report_text AWR_diff_report_text AWR_global_diff_report_text AWR_global_report_text AWR_SQL_report_text Dbms_xplan.display_awr

23 Олег Коротков Automatic Workload Repository AWR baselines. Baseline is a pair of snapshots… Oracle10g: fixed baselines only: DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE( start_snap_id, end_snap_id, baseline_name... ); Oracle 11g: baseline templates for fixed date or for repeated timeframe.

24 Олег Коротков Automatic Workload Repository AWR tables and views. AWR data is stored in SYS schema in SYSAUX tablespace. Looks like there are WRH$% and WRM$% tables. DBA_HIST% views are created above the tables – 78 views; – 111 views

25 Олег Коротков Automatic Workload Repository select from dba_hist_snapshot, dba_hist_sys_time_model Date min_snap_id max_id DB time DB CPU ,461899, ,731787, ,621587, ,141410, , , ,761934, ,662004,01

26 Олег Коротков Automatic Workload Repository select from dba_hist_snapshot, dba_hist_system_event Event_name waits_1 duration_1 waits_2 duration_2 gc buffer busy , ,4 gc cr grant 2-way , ,2 gc current block 2-way , ,3 gc cr multi block request , ,2 gc cr block 2-way , ,3 gc current grant busy , ,3 gc current grant 2-way , ,3

27 Олег Коротков Automatic Workload Repository Example 1. Average and Skew. So four executions took 278 seconds (69,5*4). How long did each take? 69,5 in average.

28 Олег Коротков Automatic Workload Repository select from dba_hist_snapshot, dba_hist_sqlstat SNAP_ID EXECS ELA GETS READS IOWAIT PLAN_HASH_VALUE ,5 in average. But no any execution even close to this time.

29 Олег Коротков Automatic Workload Repository Example 2. TOPNSQL. A query is the same (9g7dr4k9qj1r1). Usage pattern is the same. “Heavy” executions: DD EXECS ELA_PER_EXEC GETS_PER_EXEC “Light” executions: There were no executions in some snaps. ADD_COLORED_SQL/REMOVE_COLORED_SQL to mark sql_id.

30 Олег Коротков Automatic Workload Repository A kind of conclusion about AWR. - It’s very useful tool for analyzing performance in past periods. - Oracle11g AWR is better (more comprehensive and more convenient) than 10g. - Selecting from AWR views gives even more powerful and flexible reports. But… AWR requires addition licensing. It gives you only aggregated information. Some data can be ‘omitted’.

31 Олег Коротков Agenda - Automatic Workload Repository (AWR) - Basic ideas - dba_hist% views enhancements - AWR use cases & limitations - Active Session History (ASH) - Basic ideas enhancements - Typical use cases

32 Олег Коротков Active Session History Active Session History (ASH) is a new tool introduced in Oracle10g. Once a second it makes snapshot of active sessions (on CPU or in non-Idle events). Something close to… select... from gv$session where wait_class<>'Idle'; ASH data is not complete but.. It is not aggregated (like other AWR data).

33 Олег Коротков Active Session History dba_hist_active_sess_history – 52 columns; – 97 columns. Some of the columns: SNAP_ID, DBID, INSTANCE_NUMBER, SAMPLE_ID, SAMPLE_TIME – sample identification; SESSION_ID, SESSION_SERIAL#, USER_ID, PROGRAM, MODULE, MACHINE, PORT – session identification; SQL_ID, SQL_PLAN_HASH_VALUE, SQL_PLAN_LINE_ID, SQL_EXEC_ID – SQL information; EVENT, P1, P2, P3, TIME_WAITED – wait event information; BLOCKING_SESSION, BLOCKING_SESSION_SERIAL#, BLOCKING_INST_ID – locking information; TM_DELTA_CPU_TIME, TM_DELTA_DB_TIME, DELTA_READ_IO_REQUESTS. DELTA_WRITE_IO_REQUESTS, DELTA_READ_IO_BYTES, DELTA_WRITE_IO_BYTES, DELTA_INTERCONNECT_IO_BYTES – session activity info.

34 Олег Коротков Agenda ASH architecture (John Beresniewicz. Practical Active Session History) Circular buffer in SGA (2MB per CPU) Session state objects V$SESSION V$SESSION_WAIT MMON Lite (MMNL) V$ACTIVE_SESSION_HISTORY DBA_HIST_ACTIVE_SESS_HISTORY AWR Direct- path INSERTS Every hour Write 1 out of 10 samples Every second (or flush) Indexed on time Readers go unlatched Writer goes one direction Readers go the opposite way

35 Олег Коротков Active Session History ASH in memory – fixed memory consumption, variable time range. SQL> select inst_id, bytes/(1024*1024) MB from gv$sgastat where name='ASH buffers'; INST_ID MB SQL> select inst_id, (max(sample_time)-min(sample_time)) ASH_window from gv$active_session_history group by inst_id; INST_ID ASH_WINDOW :18: :01: :15: Samples for every second.

36 Олег Коротков Active Session History ASH on disk – fixed time range controlled by AWR retention. SQL> select instance_number, (max(sample_time)-min(sample_time)) ASH_window from dba_hist_active_sess_history group by instance_number; INSTANCE_NUMBER ASH_WINDOW :59: :59: :59: SQL> select 'ASH in memory' what, count(distinct sample_id) samples_per_hour 2 from v$active_session_history 3 where sample_time>=trunc(sysdate) and sample_time=trunc(sysdate) and sample_time

37 Олег Коротков Active Session History Each sample in ASH data represents a second of database activity. Theoretically: - Count of rows for one sample is DB Time. - Count of rows with session_state=‘ON CPU’ is DB CPU. In my experience the accuracy of the calculation hardly ever better than 15-20% on production systems with significant load.

38 Олег Коротков Active Session History Example 1. AWR report: Snap Id Snap Time Sessions Curs/Sess Begin Snap: Dec-11 13:30:23 1, Elapsed: (mins) DB Time: 2, (mins) Event Waits Time (s) (ms) Time Wait Class latch: cache buffers chains 409,488 51, Concurrenc CPU time 6, db file sequential read 164,900 1, User I/O Elapsed CPU Elap per % Total Time (s) Time (s) Executions Exec (s) DB Time SQL Id ,282 4,307 11, g7dr4k9qj1r (ela for the query) / 900 (15 minutes) = = 155 concurrently executed queries.

39 Олег Коротков Active Session History Example 1. ASH content (1/3): SQL> select to_char(trunc(sample_time,'mi'),'hh24:mi') dd, count(*) c, 2 count(distinct h.session_id||':'||h.session_serial#) s 3 from dba_hist_active_sess_history h 4 where h.instance_number=1 and h.snap_id between and and h.sample_time>=to_date(' :30','dd.mm.yyyy hh24:mi') 6 and h.sample_time

40 Олег Коротков Active Session History Example 1. ASH content (2/3): SQL> select sample_time, count(*) c, 2 sum(case when sql_id='9g7dr4k9qj1r1' then 1 else 0 end) s 3 from dba_hist_active_sess_history h 4 where h.instance_number=1 and h.snap_id between and and h.sample_time>=to_date(' :30','dd.mm.yyyy hh24:mi') 6 and h.sample_time

41 Олег Коротков Active Session History Example 1. ASH content (3/3): SAMPLE_TIME C S DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM DEC PM 4 0

42 Олег Коротков Active Session History Example 2. sql_exec_id (Oracle 11g) (1/2). SQL_EXEC_ID is counter of SQL executions on a given instance. (See Tanel Poder blog entry.) SQL> declare j number; begin dbms_job.submit(job=>j, what=>'declare p number; begin for i in 1..3 loop select count(*) into p from positions e_test where mrp=1; end loop; end;', instance=>1); end; / PL/SQL procedure successfully completed. SQL> declare j number; begin dbms_job.submit(job=>j, what=>'declare p number; begin for i in 1..2 loop select count(*) into p from positions e_test where mrp=1; end loop; end;', instance=>2); end; /

43 Олег Коротков Active Session History Example 2. sql_exec_id (Oracle 11g) (2/2). SQL> select sql_id, sql_text from v$sql where sql_id='2dxypmkd8p3qk'; dxypmkd8p3qk SELECT COUNT(*) FROM POSITIONS E_TEST WHERE MRP=1 SQL> select inst_id, sql_exec_id, to_char(sql_exec_id,'XXXXXXXX') sql_exec_id_h, count(*) s from gv$active_session_history where sql_id='2dxypmkd8p3qk' group by inst_id, sql_exec_id order by 1,2; INST_ID SQL_EXEC_ID SQL_EXEC_ S

44 Олег Коротков Active Session History ASH is great tool for: - Investigate load spikes within an AWR snapshot. - Analyze ‘long’ queries executions (especially in 11g). - Investigate locking/blocking issues (if locking time not too short). Limitations: - The information is not complete. ASH on disk is more incomplete. - DB activity spikes makes ‘retention window’ of ASH in memory shorter (sometimes dramatically). - Tends to sample ‘long’ events. - Licensing as part of AWR.

45 Олег Коротков References Oracle® Database Documentation, 11g Release 2 (11.2) Oracle® Database Performance Tuning Guide 5 Automatic Performance Statistics Oracle® Database PL/SQL Packages and Types Reference 161 DBMS_WORKLOAD_REPOSITORY Mike Ault. AWR Report Detailed Analysis. John Beresniewicz. Practical Active Session History Tanel Poder. What the heck is the SQL Execution ID – SQL_EXEC_ID?

46 Олег Коротков Thank you for coming! Questions?


Download ppt "Олег Коротков AWR, ASH - use cases and 11.2 enhancements."

Similar presentations


Ads by Google