Oracle 查詢佔用臨時表空間大的歷史會話和SQL
alter 日誌中報 ORA-1652: unable to extend temp segment by 128 in tablespace TEMP。
可透過下面方式定為到歷史sql:
--佔用臨時表空大的歷史會話和sql查詢:
select to_char(a.sample_time, 'yyyy-mm-dd hh24'),
a.session_id,
u.username,
a.sql_id
from gv$active_session_history a, dba_users u
where u.user_id = a.user_id
and to_char(a.sample_time, 'yyyy-mm-dd hh24:mi:ss') >
'2021-05-25 20:30:00'
and to_char(a.sample_time, 'yyyy-mm-dd hh24:mi:ss') <
'2021-05-25 20:40:59'
and a.temp_space_allocated > 10000000
and sql_id is not null
group by to_char(a.sample_time, 'yyyy-mm-dd hh24'),
a.session_id,
u.username,
a.sql_id
order by a.sql_id, a.session_id desc;
或
select to_char(a.sample_time, 'yyyy-mm-dd hh24'),
a.session_id,
u.username,
a.sql_id
from dba_hist_active_sess_history a, dba_users u
where u.user_id = a.user_id
and to_char(a.sample_time, 'yyyy-mm-dd hh24:mi:ss') >
'2020-07-09 11:00:00'
and to_char(a.sample_time, 'yyyy-mm-dd hh24:mi:ss') <
'2020-07-09 11:10:00'
and a.temp_space_allocated > 1000000000
and sql_id is not null
group by to_char(a.sample_time, 'yyyy-mm-dd hh24'),
a.session_id,
u.username,
a.sql_id
order by a.sql_id, a.session_id desc;
--檢視sql佔用臨時表空間最大值:
select max(a.temp_space_allocated / 1024 / 1024 / 1024) g
from gv$active_session_history a
where a.sql_id = '6uk7dr0n12f9n';
--查詢當前佔用臨時表空間高的SQL
select se.username,
se.sid,
su.extents,
su.blocks * to_number(rtrim(p.value)) / 1024 / 1024 as used_G,
tablespace,
segtype,
s.sql_id,
s.sql_text
from v$sort_usage su, v$parameter p, v$session se, v$sql s
where p.name = 'db_block_size'
AND su.session_addr = se.saddr
AND s.hash_value = su.sqlhash
AND s.address = su.sqladdr
and su.blocks > 1000
order by su.blocks desc;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21374452/viewspace-2896546/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle下查詢臨時表空間佔用率Oracle
- 臨時表空間被佔滿的原因查詢
- oracle 表空間,臨時表空間使用率查詢Oracle
- oracle 查詢什麼sql佔用臨時段OracleSQL
- [oracle] 查詢歷史會話、歷史執行計劃Oracle會話
- 臨時表空間和回滾表空間使用率查詢
- 臨時表空間的空間使用情況查詢
- oracle查詢表空間的空間佔用情況Oracle
- oracle11g 查詢臨時表空間的使用率和正在使用臨時表空間的使用者Oracle
- 查詢oracle歷史最大連線[會話]數Oracle會話
- oracle 臨時表空間的增刪改查Oracle
- ORACLE 臨時表空間的增刪改查:Oracle
- oracle臨時表空間的增刪改查Oracle
- oracle的臨時表空間Oracle
- Oracle查詢表佔磁碟空間大小及移動表空間Oracle
- MYSQL造資料佔用臨時表空間MySql
- oracle 臨時表空間Oracle
- oracle臨時表空間Oracle
- Oracle 表空間查詢相關sqlOracleSQL
- oracle清理和重建臨時表空間Oracle
- 檢視oracle臨時表空間佔用率的檢視Oracle
- 解決Oracle臨時表空間佔滿的問題Oracle
- 檢視臨時表空間佔用及當前天在執行的sqlSQL
- Oracle 12C RMAN備份佔用大量臨時表空間Oracle
- Oracle 臨時表空間的概念Oracle
- ORACLE臨時表空間的清理Oracle
- 查詢過去一段時間內某條sql使用的臨時表空間大小SQL
- Oracle 臨時表空間概念Oracle
- oracle臨時表空間組Oracle
- Oracle Temp 臨時表空間Oracle
- Oracle修改預設表空間和預設臨時表空間Oracle
- oracle表空間查詢Oracle
- oracle臨時表空間過大的原因&&處理Oracle
- Oracle臨時表空間檢視、新增臨時表空間資料檔案、修改預設臨時表空間 方法!Oracle
- oracle建立臨時表空間和資料表空間以及刪除Oracle
- 【臨時表空間組】臨時表空間組的建立、維護及應用
- ORACLE預設的臨時表空間Oracle
- oracle的臨時表空間temporary tablespaceOracle