https://yoku0825.blogspot.com/2020/10/innodbhistory-list-length.html
(8.0.22)
-- 1. REPEATABLE-READ読み取り一貫性用のUNDOレコード数
あるトランザクションからテーブルを繰り返し更新、コミットすると同時に
別セッションからトランザクションを開始してそのテーブルを参照すると増えていく
select *
from sys.metrics
where variable_name = 'trx_rseg_history_len'
;
select *
from information_schema.innodb_metrics
where name = 'trx_rseg_history_len'
\G
SHOW ENGINE INNODB STATUS\G のTRANSACTIONSに
History list length 653814
として表示される
-- 2. 更新後コミット前ロールバック用のUNDOレコード数
コミットせずに大量更新すると増えていく
SHOW ENGINE INNODB STATUS\G のTRANSACTIONSに
undo log entries 81845
として表示される
-- 3. UNDOページ数
select page_type, count(*) from information_schema.innodb_buffer_page
group by page_type
order by page_type
;
(19c)
alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss';
select * from V$UNDOSTAT;
BEGIN_TIME
END_TIME
UNDOBLKS 対象期間の使用ブロック数の累積。(更新量が多い場合、UNDO表領域ブロック数を超えることもある)
ACTIVEBLKS 対象期間のある時点におけるアクティブブロック数
UNEXPIREDBLKS 対象期間のある時点における期限内ブロック数
EXPIREDBLKS 対象期間のある時点における期限切れブロック数
UNDO表領域ブロック数 ≒ ACTIVEBLKS + UNEXPIREDBLKS + EXPIREDBLKS
select
BEGIN_TIME
,END_TIME
,UNDOBLKS
,ACTIVEBLKS
,UNEXPIREDBLKS
,EXPIREDBLKS
from v$undostat
order by begin_time;
select used_ublk from v$transaction
where addr = ( select taddr from v$session where sid = 29 )
;
select b.value
from v$statname a, v$mystat b
where a.statistic# = b.statistic#
and a.name = 'undo change vector size'
;
単位はバイト数の模様
select b.value
from v$statname a, v$mystat b
where a.statistic# = b.statistic#
and a.name = 'data blocks consistent reads - undo records applied'
;
(13)
select n_dead_tup from pg_stat_user_tables where relname = 'tab1';
repeatable readの分離レベルで他セッションから参照している場合
vacuumしてもdead_tupは回収されないことから、
このdead_tupの中にUNDOに相当するものが含まれると思われる。
(2019)
select count(*) , sum(record_length_first_part_in_bytes)/1024/1024 mb
from sys.dm_tran_version_store;