查詢表或索引增長的歷史資訊
在Oracle 10g開始awr自動負載倉庫引入了dba_hist_seg_stat檢視,該檢視記錄了快照時間內segment-level段級的歷史統計資訊:DBA_HIST_SEG_STAT displays historical information about segment-level statistics. This view captures the top segments based on a set of criteria and captures information from V$SEGSTAT. The total value is the value of the statistics since instance startup. The delta value is the value of the statistics from the BEGIN_INTERVAL_TIME to the END_INTERVAL_TIME in the DBA_HIST_SNAPSHOT view.
我們可以透過以下SQL指令碼來列出相關段物件在 快照時間內的使用空間的歷史變化資訊
column owner format a16
column object_name format a36
column start_day format a11
column block_increase format 9999999999
select obj.owner, obj.object_name,
to_char(sn.BEGIN_INTERVAL_TIME,'RRRR-MON-DD') start_day,
sum(a.db_block_changes_delta) block_increase
from dba_hist_seg_stat a,
dba_hist_snapshot sn,
dba_objects obj
where sn.snap_id = a.snap_id
and obj.object_id = a.obj#
and obj.owner not in ('SYS','SYSTEM')
and end_interval_time between to_timestamp('01-JAN-2000','DD-MON-RRRR')
and to_timestamp('02-FEB-2013','DD-MON-RRRR')
group by obj.owner, obj.object_name,
to_char(sn.BEGIN_INTERVAL_TIME,'RRRR-MON-DD')
order by obj.owner, obj.object_name
/
例項:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn maclean/maclean
Connected.
SQL>
SQL>
SQL>
SQL> create table check_size tablespace users as select * from dba_objects where rownum=0;
Table created.
SQL> exec dbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
SQL> insert into check_size select * from dba_objects;
75536 rows created.
SQL> insert into check_size select * from check_size;
75536 rows created.
SQL> /
151072 rows created.
SQL> commit;
Commit complete.
SQL> insert into check_size select * from check_size;
302144 rows created.
SQL> insert into check_size select * from check_size;
604288 rows created.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
SQL> exec dbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
SQL> @seg_hist
OWNER OBJECT_NAME START_DAY BLOCK_INCREASE
---------------- ------------------------------------ ----------- --------------
DBSNMP BSLN_STATISTICS 2012-MAR-18 224
DBSNMP BSLN_STATISTICS_PK1 2012-MAR-18 192
MACLEAN CHECK_SIZE 2012-MAR-22 96176
SH CUSTOMERS 2012-MAR-17 0
SQL> select data_object_id from dba_objects where object_name='CHECK_SIZE';
DATA_OBJECT_ID
--------------
78062
SQL> select seg.snap_id,
2 seg.ts#,
3 seg.space_used_total,
seg.space_allocated_total,
seg.SPACE_ALLOCATED_DELTA
from dba_hist_seg_stat seg
where seg.DATAOBJ#=78062
/ 4 5 6 7 8
SNAP_ID TS# SPACE_USED_TOTAL SPACE_ALLOCATED_TOTAL SPACE_ALLOCATED_DELTA
---------- ---------- ---------------- --------------------- ---------------------
354 4 30909079 36700160 36700160
355 4 123645655 149946368 113246208
SPACE_USED_DELTA Delta value for space used
SPACE_ALLOCATED_DELTA Delta value for space allocated
本文轉載自
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/543979/viewspace-720634/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何查詢以往的session歷史資訊Session
- 查詢某個表的索引資訊索引
- SQL Server中如何找到歷史增長資訊SQLServer
- 根據表查詢索引資訊索引
- 查詢oracle表的資訊(表,欄位,約束,索引)Oracle索引
- Flowable查詢歷史任務
- oracle查詢表資訊(索引,外來鍵,列等)Oracle索引
- [oracle] 查詢歷史會話、歷史執行計劃Oracle會話
- 查詢表資訊
- 查詢SQL Server的歷史執行記錄SQLServer
- 表和索引並行查詢索引並行
- 表空間查詢資訊
- SQL Server 查詢歷史執行的SQL語句SQLServer
- SAP MM 物料成本價格修改歷史的查詢
- 鎖表的相關資訊查詢
- Oracle 查詢佔用臨時表空間大的歷史會話和SQLOracle會話SQL
- MySQL 覆蓋索引、回表查詢MySql索引
- 查詢瘋狂增長的arch-續
- 查詢oracle歷史最大連線[會話]數Oracle會話
- SqlServer查詢資料改動歷史記錄SQLServer
- Oracle OCP(22):查詢表資訊Oracle
- mysql查詢表基礎資訊MySql
- 【索引】Oracle查詢指定索引提高查詢效率索引Oracle
- [20220421]完善查詢表分析的歷史th.sql指令碼.txtSQL指令碼
- mysql 的自增長的策略(查詢與更改初值)MySql
- 查詢表上的索引及對應的欄位索引
- SQL查詢table或index異常增長問題 - space_usage (show_space)SQLIndex
- GBase 庫中查詢表的列資訊
- Oracle索引或這類索引的分割槽處於不可用狀態 查詢Oracle索引
- 中國城市降雨量歷史記錄查詢 All In One
- MySQL 庫大小、表大小、索引大小查詢命令MySql索引
- 分割槽表分割槽索引查詢效率探究索引
- Mysql建表、索引、函式、查詢使用中的坑!!!MySql索引函式
- django 兩個表或多個表聯合查詢Django
- MySQL查詢索引的選擇性、索引欄位、註釋等基本資訊的SQLMySql索引
- MySQL 查詢索引的選擇性、索引欄位、註釋等基本資訊的SQLMySql索引
- Oracle查詢表空間的每日增長量Oracle
- INTEL CPU 歷史表 收藏Intel