Anzeige

数据库性能诊断的七种武器

Vice General Manager at Yunhe Enmo um Yunhe Enmo
3. Apr 2010
Anzeige

Más contenido relacionado

Anzeige

Último(20)

Anzeige

数据库性能诊断的七种武器

  1. 数据库性能诊断的七种武器 ITPUB : Ora-600 liyinan
  2. <Insert Picture Here> 性能优化面临的挑战
  3. 性能优化面临的挑战 1 、架构和业务的设计与变更 2 、熟悉各种数据库参数、系统参数 3 、应用逻辑与 SQL 代码实现 4 、选择合适的存储方式 存储盘阵、存储模式、存储参数、存储表空间、存储对象等 5 、复杂的网络配置 还有更多。。。 DBA 的事情好多哦… 为满足业务的运行要求,高性能要求是目前 IT 系统普遍面临的最棘手问题,尤其是客户面对着目前越来越庞大系统和数据,系统整合、数据大集中似乎成了趋势,而对我们来说,则充满了压力和挑战。
  4. <Insert Picture Here> 调优工具的变迁
  5. <Insert Picture Here> 诊断工具中的七种武器
  6. Statspack 内容
  7. Statspack 内容
  8. Statspack 内容
  9. Statspack 内容
  10. ASH 报告
  11. ASH 报告
  12. ASH 报告
  13. 活动会话信息中的 TOP
  14. 通过 TOP SQL 进一步发现问题
  15. AWR 报告
  16. AWR 报告
  17. ADDM 分析报告
  18. ADDM 分析报告细节
  19. AWR Compare Period Report
  20. AWR Compare Period Report: Configuration
  21. AWR Compare Period Report: Load Profile
  22. AWR Compare Period Report: Top Timed Events
  23. AWR Compare Period Report: Report Details
  24. AWR Compare Period Report: Top SQL by Elapsed Time
  25. 性能调优工具关联图示 Snapshots In-memory statistics AWR SGA 60 mn ADDM results MMON DBA Snapshots Statspack Fore- -ground Automatic ASH ADDM Alerts
  26. SQL Tuning Advisor Overview Add Missing Indexes Modify SQL Constructs Create a SQL Profile Automatic Tuning Optimizer SQL Structure Analysis Access Path Analysis SQL Profiling Statistics Analysis Gather Missing or Stale Statistics DBA SQL Tuning Recommendations SQL Tuning Advisor
  27. SQL Tuning Usage Scenarios SQL Tuning Advisor ADDM High-load SQL Cursor Cache AWR SQL Tuning Set (STS) User-defined Filter / Rank SQL Sources Manual Selection Automatic Selection AWR
  28. SQL Tuning in Oracle Database 10g End-to-End Workflow Workload AWR one hour A good end-to-end solution, but manual intervention is required SQL Tuning Candidates SQL Tuning Advisor ADDM Generate Recommendations DBA Invoke Advisor Implement DBA Evaluate Recommendations DBA
  29. Automatic SQL Tuning in Oracle 11g It’s Automatic! Workload Choose Candidate SQL one week SQL Tuning Candidates Test SQL Profiles Implement SQL Profiles Generate Recommendations AWR DBA View Reports / Control Process
  30. SQL Access Advisor Overview Partitions ( 11g only ) MV and MV Logs Bit-map indexes Automatic Tuning Optimizer Access Path Analysis B*-tree indexes DBA Recommendations SQL Access Advisor 除了像在 Oracle 数据库 10g 中一样可以分析索引、物化视图等, Oracle 数据库 11g 中的 SQL Access Advisor 还可以分析表和查询以提供可能的分区策略 — 这在设计最佳模式时可以提供很大帮助

Hinweis der Redaktion

  1. Enqueue 有 3 个参数: 1. P1 表示 Lock type 、 mode 比如, P1RAW 的值为 54580006 ,其中, 54 表示的是 T , 58 表示的为 X , 6 表示的专用锁; 也可以用 SELECT chr(to_char(bitand(p1,-16777216))/16777215)|| chr(to_char(bitand(p1, 16711680))/65535) &amp;quot;Lock&amp;quot;, to_char( bitand(p1, 65535) ) &amp;quot;Mode&amp;quot; FROM v$session_wait WHERE event = &apos;enqueue&apos; ; 来查询当前发生 enqueue 等待事件的 Lock mode ,该值对应着 V$lock 中的 lock type 2. P2 、 P3 代表 Enqueue name 的 ID1 和 ID2 ,分别对应着 V$Lock 中的 ID1 和 ID2 大多数情况下, Enqueue 的等待时间为 3 秒 在 v$Lock 中, request = 0 表示的是 Holder , &gt;0 表示的是 waiter 确定 Enqueue 的性能: 1. 可以查询 v$sysstat 来查看 enqueue 等待 select * from v$sysstata where class = 4 2. 对于 9i ,可以查询: SELECT eq_type &amp;quot;Lock&amp;quot;, total_req# &amp;quot;Gets&amp;quot;, total_wait# &amp;quot;Waits&amp;quot;, cum_wait_time FROM V$enqueue_stat WHERE Total_wait# &gt; 0 ; 3. 对于 8i ,可以查询: SELECT ksqsttyp &amp;quot;Lock&amp;quot;, ksqstget &amp;quot;Gets&amp;quot;, ksqstwat &amp;quot;Waits&amp;quot; FROM X$KSQST where KSQSTWAT &gt; 0; 根据这两个 sql ,确定整个系统中的 enqueue 的等待情况 几个普遍存在的 Lock mode : TX :事务锁 Note 62354.1 ; 在以下情况下发生: 1) Another session is locking the requested row. 2) When two sessions tries to insert the same unique key into a table (none of them has done a COMMIT), then the last session is waiting for the first one to COMMIT or ROLLBACK. 3) There are no free ITL (Interested Transaction List) in the block header (increase INI_TRANS och PCT_FREE for the segment). TM : DML enqueue , 一般当外键没有建立索引的时候产生, Note 38373.1 , Note 33453.1 ST : space management enqueue ,当系统存在小碎片,或者存在大量的 sort 的时候产生 Note 33567.1 JQ : Job queue UL : user lock ,当用户 DBMS_LOCK.REQUEST 时产生 SQ : sequence enqueue, 检查 sequence 的 cache size 是否过小 SS : sort segment enqueue, 检查 temp 表空间太小,是否有查询需要使用大量的 temporary 空间 HW enqueue 指和段的高水位标记相关等待;手动分配适当区可以避免这一等待 TX 是最常见的 enqueue 等待。 TX enqueue 等待通常是以下三个问题之一产生的结果: 第一个问题是唯一索引中的重复索引,你需要执行提交( commit ) / 回滚( rollback )操作来释放 enqueue 。 第二个问题是对同一位图索引段的多次更新。因为单个位图段可能包含多个行地址( rowid ),所以当多个用户试图更新同一段时,可能一个用户会锁定其他用户请求的记录,这时等待出现。直到获得锁定的用户提交或回滚, enqueue 释放。 第三个问题,也是最可能发生的问题是多个用户同时更新同一个块。如果没有足够的 ITL 槽,就会发生块级锁定。通过增大 initrans 和 / 或 maxtrans 以允许使用多个 ITL 槽(对于频繁并发进行 DML 操作的数据表,在建表之初就应该考虑为相应参数设置合理的数值,避免系统运行以后在线的更改,在 8i 之前, freelists 等参数不能在线更改,设计时的考虑就尤为重要),或者增大表上的 pctfree 值,就可以很容易的避免这种情况。 TM enqueue 队列锁在进行 DML 操作前获得,以阻止对正在操作的数据表进行任何 DDL 操作 ( 在 DML 操作一个数据表时,其结构不能被更改 select * from V$ENQUEUE_STAT; enqueue 类型 : BL, Buffer Cache Management CF, Controlfile Transaction CI, Cross-instance Call Invocation CU, Bind Enqueue DF, Datafile DL, Direct Loader Index Creation DM, Database Mount DR, Distributed Recovery DX, Distributed TX FS, File Set IN, Instance Number IR, Instance Recovery IS, Instance State IV, Library Cache Invalidation JQ, Job Queue KK, Redo Log “Kick” L[A-P], Library Cache Lock MR, Media Recovery N[A-Z], Library Cache Pin PF, Password File PI, Parallel Slaves PR, Process Startup PS, Parallel Slave Synchronization Q[A-Z], Row Cache RT, Redo Thread SC, System Commit Number SM, SMON SQ, Sequence Number Enqueue SR, Synchronized Replication SS, Sort Segment ST, Space Management Transaction SV, Sequence Number Value TA, Transaction Recovery TM, DML Enqueue TS, Temporary Segment (also TableSpace) TT, Temporary Table TX, Transaction UL, User-defined Locks UN, User Name US, Undo Segment, Serialization WL, Being Written Redo Log XA, Instance Attribute Lock XI, Instance Registration Lock
  2. Statspack Installation of the Statspack Package Installing the Statspack utility creates the perfstat user, who owns all PL/SQL code and database objects created (including the Statspack tables, the constraints, and the Statspack package). During the installation you will be prompted for the perfstat user’s default and temporary tablespaces. The Statspack package has been available with Oracle Database from Oracle8.1.6. When initially installed roughly 80 MBs of the perfstat user’s default tablespace is used. This may grow later with the tables storing snapshot information. Collecting Statistics To take a snapshot of performance data, log on to SQL*Plus as the perfstat user, and then execute the statspack.snap procedure. This stores the current performance statistics in the Statspack tables, which can be used as a baseline snapshot for comparison with another snapshot taken at a later time. Automatically Collecting Statistics To compare performance from one day, week, or year to the next, there must be multiple snapshots taken over a period of time. The best method to gather snapshots is to automate the collection at regular time intervals. The spauto.sql script makes use of the dbms_job package to provide an automated method for collecting statistics. The supplied script schedules a snapshot every hour, on the hour. This can be changed to suit the requirements of the system. Producing a Report To examine the change in statistics between two time periods, execute the spreport.sql file while being connected to the perfstat user. The user is shown a list of collection periods and selects a start and end period. The difference between the statistics at each end point is then calculated and put into a file named by the user.
  3. First Page of the Statspack Report The first page summarizes the report. The items found on this page include most of the information that the DBA requires to enhance performance. Each of these areas will be covered in greater depth during the course. • Cache Sizes The current size of the buffer cache, shared pool, and log buffer are shown here in KB. Also included here is the value of the primary block size. • Load Profile One value given here is per second and the other is per transaction. What is shown includes the redo size and the physical reads and physical writes performed during the snapshot period. • Instance Efficiency Percentages The items listed here are ones that are most often used for tuning a database. These statistics are used to indicate that workloads have changed on the database. • Top Five Wait Events The full list of wait events appears later in the report and will be dealt with later in the course. The top contention items are listed under this heading.
  4. The “ head ” image depicts a decision point.
Anzeige