Scripts:找出使用最高的10个表的脚本perf_top_10_tables.sql
2014-06-02 17:09
471 查看
-- +----------------------------------------------------------------------------+
-- | Jeffrey M. Hunter |
-- | jhunter@idevelopment.info |
-- | www.idevelopment.info |
-- |----------------------------------------------------------------------------|
-- | Copyright (c) 1998-2011 Jeffrey M. Hunter. All rights reserved. |
-- |----------------------------------------------------------------------------|
-- | DATABASE : Oracle |
-- | FILE : perf_top_10_tables.sql |
-- | CLASS : Tuning |
-- | PURPOSE : Report on top 10 tables with respect to usage and command type. |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
SET LINESIZE 145
SET PAGESIZE 9999
SET VERIFY off
COLUMN ctyp FORMAT a13 HEADING 'Command Type'
COLUMN obj FORMAT a30 HEADING 'Object Name'
COLUMN noe FORMAT 999,999,999,999,999 HEADING 'Number of Executions'
COLUMN gets FORMAT 999,999,999,999,999 HEADING 'Buffer Gets'
COLUMN rowp FORMAT 999,999,999,999,999 HEADING 'Rows Processed'
BREAK ON report
COMPUTE sum OF noe ON report
COMPUTE sum OF gets ON report
COMPUTE sum OF rowp ON report
SELECT
ctyp
, obj
, 0 - exem noe
, gets
, rowp
FROM (
select distinct exem, ctyp, obj, gets, rowp
from (select
DECODE( s.command_type
, 2, 'Insert into '
, 3, 'Select from '
, 6, 'Update of '
, 7, 'Delete from '
, 26, 'Lock of ') ctyp
, o.owner || '.' || o.name obj
, SUM(0 - s.executions) exem
, SUM(s.buffer_gets) gets
, SUM(s.rows_processed) rowp
from
v$sql s
, v$object_dependency d
, v$db_object_cache o
where
s.command_type IN (2,3,6,7,26)
and d.from_address = s.address
and d.to_owner = o.owner
and d.to_name = o.name
and o.type = 'TABLE'
group by
s.command_type
, o.owner
, o.name
)
)
WHERE rownum <= 10;
-- | Jeffrey M. Hunter |
-- | jhunter@idevelopment.info |
-- | www.idevelopment.info |
-- |----------------------------------------------------------------------------|
-- | Copyright (c) 1998-2011 Jeffrey M. Hunter. All rights reserved. |
-- |----------------------------------------------------------------------------|
-- | DATABASE : Oracle |
-- | FILE : perf_top_10_tables.sql |
-- | CLASS : Tuning |
-- | PURPOSE : Report on top 10 tables with respect to usage and command type. |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
SET LINESIZE 145
SET PAGESIZE 9999
SET VERIFY off
COLUMN ctyp FORMAT a13 HEADING 'Command Type'
COLUMN obj FORMAT a30 HEADING 'Object Name'
COLUMN noe FORMAT 999,999,999,999,999 HEADING 'Number of Executions'
COLUMN gets FORMAT 999,999,999,999,999 HEADING 'Buffer Gets'
COLUMN rowp FORMAT 999,999,999,999,999 HEADING 'Rows Processed'
BREAK ON report
COMPUTE sum OF noe ON report
COMPUTE sum OF gets ON report
COMPUTE sum OF rowp ON report
SELECT
ctyp
, obj
, 0 - exem noe
, gets
, rowp
FROM (
select distinct exem, ctyp, obj, gets, rowp
from (select
DECODE( s.command_type
, 2, 'Insert into '
, 3, 'Select from '
, 6, 'Update of '
, 7, 'Delete from '
, 26, 'Lock of ') ctyp
, o.owner || '.' || o.name obj
, SUM(0 - s.executions) exem
, SUM(s.buffer_gets) gets
, SUM(s.rows_processed) rowp
from
v$sql s
, v$object_dependency d
, v$db_object_cache o
where
s.command_type IN (2,3,6,7,26)
and d.from_address = s.address
and d.to_owner = o.owner
and d.to_name = o.name
and o.type = 'TABLE'
group by
s.command_type
, o.owner
, o.name
)
)
WHERE rownum <= 10;
相关文章推荐
- Scripts:找出10个最高使用的过程perf_top_10_procedures.sql
- Scripts:找出使用最多buffer get的SQL脚本perf_top_sql_by_buffer_gets.sql
- Scripts:找出磁盘读最多的SQL的脚本 perf_top_sql_by_disk_reads.sql
- Scripts:查看使用PGA最多的10个SQL的脚本hpga10.sql
- Scripts:查询每个数据文件使用效率的脚本perf_file_io_efficiency.sql
- Scripts:查询使用临时表空间最多的10个SQL htemp10.sql
- Scripts:查询每个session命中率的脚本perf_hit_ratio_by_session.sql
- Scripts:查询sga中各组件使用率的脚本perf_sga_usage.sql
- Scripts:查看耗用buffer cache最多的10个SQL的脚本hbuf10.sql
- Scripts:查询物理读最多的10个SQL的脚本hphy10.sql
- Scripts:查询数据文件IO使用率的脚本 perf_file_io.sql
- Scripts:从shared_pool中创建并删除profile的脚本(注意,此脚本危险比较高,生产环境不要使用)flush_sql10p.sql
- Scripts:给出系统pid找出sql的脚本pid4sql.sql
- Scripts:找出后台trace文件的脚本sess_user_trace_file_location.sql
- Scripts:查询db_block_buffer使用率的脚本perf_db_block_buffer_usage.sql
- Scripts:查询每个数据文件等待时间的脚本perf_file_waits.sql
- Scripts:根据sql文本找出相应SQL信息的脚本find_sql.sql
- Scripts:报告数据库中的top segment的脚本dba_top_segments.sql
- Auto generate change scripts in SQL Server Management Studio (SSMS) for tables
- getSQLinfo.vbs 获得SQL数据/日志空间使用情况的脚本