oracle tuning 工具

工欲善其事, 必先利其器.

 

oracle 调优方面有很多工具, 目前 UI 个人只打算使用 Toad.

 

重要文件

一. alert log file. (位置 parameter BACKGROUND_DUMP_DEST)

   这个文件中有很多重要的内容, 可以通过调整 LOG_CHECKPOINTS_TO_ALERT 这个参数, 将 checkpoint 内容写到这个文件中.

   使用方法 :

   1. 可以搜索带 ORA 开头的内容, 例如使用 vi 工具的 /ORA, 这样可以快速定位错误的内容加以判断.

   2. 那些可以影响到 database structure and parameters and statements的操作, 例如 create database, startup, shutdown, archivelog and recover.

   3. instance start 时那些不是默认的是否正确

二. User Trace file

   这个文件包含了 sql statement 执行的一些统计信息, 可以是 session 级别的, 也可以是instance 级别的(全部session都包括), 一般我们使用 session 级别的.

   instance 级别, 设置方法是将 sql_trace 这个参数设置为 true. 注意: 这样会造成 user trace file 这个文件很大.

   session 级别, 即只针对某些特殊的 session 来进行 trace file 确认. 设置方法: execute dbms_system.set_sql_trace_in_session(8, 12, true);

   以上设置的参数分别的, 8 是 system identifier , 12 是 serial number, true 表示接下来的 sql statement 可以写到 trace file.

   也可以使用 alter session set sql_trace= true  -- 只针对当前 session 来设置的 sql_trace.

三. 动态视图和数据字典(也不知道这些视图等是否能用上, 先罗列吧)

   这里有很多动态视图和数据字典, 下面一一道来:

数据字典:

dba_tables

dba_tab_columns

dba_clusters

dba_indexes

index_stats

index_histogram

dba_tab_histograms

动态视图: 其中 P 表示 performance tuning, T 表示 Troubleshooting

image

wait event (这个也是 oracle 一个动态视图, wait events provides information on the sessions that had to wait or must wait for different reasons)

v$event_name

v$session_event: waits for an event for each session that had to wait.

v$session_wait: waits for an event for current active session that are waiting

v$system_event: total waits for an event, all session together.

另外, 还有一些参数可以设置你搜集统计信息的级别:

STATISTICS_LEVEL

TIMED_STATISTICS

TIMED_OS_STATISTICS

DB_CACHE_ADVICE

 

重要工具 STATSPACK(目前看来这个工具可以得到上面视图一样的内容, 而且更方便)

statspack 必看文档 rdbms/admin/spdoc.txt

statspack 是一个用户, snapshop 快照存储在表里, 因为 statspack 在执行快照时保存的数据大, 所以最好要创建表空间为 statspack, 然后将所有的 statspack里的所有表都存放在这个表空间里.

1. 安装 statspack: 调用脚本 spcreate.sql

2. 收集统计信息, execute statspack.snap

3. 自动收集统计信息, 调用脚本 spauto.sql

4. 生成report: spreport.sql

5. 有关时间的统计信息, 将参数 TIMED_STATISTICS 设置为 ture.

下面看看 statspack 都能输出哪些我们想要的信息: (注意, 以上的动态视图等也是得到我们想要的信息)

  • database and instance name
  • time at which the snapshots were taken
  • Current sizes of the cache
  • load profile
  • efficiency percentages of the instance top five wait events
  • complete list of wait events
  • information on SQL statements currently in the pool
  • instance activity statistics
  • tablespace and file I/O
  • buffer pool statistics
  • rollback or undo segment statistics
  • latch activity
  • dictionary cache statistics
  • library cache statistics
  • SGA statistics
  • startup values for init.ora parameters

看到上边的内容, 基本可以判断, statspack 输出了我们想要的所有内容.     

posted @ 2014-03-27 14:04  神之一招  阅读(429)  评论(0编辑  收藏  举报