首页 > 数据库 >temp表空间满分析oracle

temp表空间满分析oracle

时间:2023-11-13 12:05:13浏览次数:31  
标签:1024 date temp 空间 yyyymmdd sql oracle id hh24mi

1.查看当前temp使用率,尤其是执行计划是hash join,一定要关注temp

select df.tablespace_name “Tablespace”,
df.total space “Total(MB)”,
nvl(FS.Used Space, 0) “Used(MB)”,
(df.total space - nvl(FS.Used Space, 0)) “Free(MB)”,
round(100 * (1 - (nvl(fs.Used Space, 0) / df.total space)), 2) “Pct.Free(%)”
FROM (SELECT tablespace_name, round(SUM(bytes) / 1048576) Total Space
FROM dba_TEMP_files
GROUP BY tablespace_name) df,
(SELECT tablespace_name,
ROUND(SUM(bytes_used) / 1024 / 1024) Used Space
FROM v$temp_extent_pool
GROUP BY tablespace_name) fs
WHERE df.tablespace_name = fs.tablespace_name(+)

2.查看过去TEMP使用率

select a.SAMPLE_TIME,
sum(temp_space_allocated) / 1024 / 1024 / 1024,
sqL_id
from dba_hist_active_sess_history a
where a.TEMP_SPACE_ALLOCATED is not null
and sample_time between to_date(‘xxxxxxxxxxx,’ yyyymmdd hh24mi) and
to_date(‘xxxxxxxxxx’, yyyymmdd hh24mi)
group by a.SAMPLE_TIME, sql_id
order by2 desc;

3.查看某个时段占用TEMP空间的SQL

select SQL_ID,
sum(trunc(TEMP_SPACE_ALLOCATED / 1024 / 1024 / 1024)) used GB
from gv$active_session_history
where (SAMPLE_TIME between to_date(‘2021112300’, ‘yyyymmdd hh24mi’) and
to_date(‘202111240059,’ yyyymmdd hh24mi))
and sql_id in (‘xxxxxx’, xxxxxxxxxx ',‘xxxxxxxxxx’)
and TEMP_SPACE_ALLOCATED is not null
and event like ‘%temp%’
group by sql_id;

4.查看SQL文本

select sqL id, to_char(sql_fulltext), plan_hash_value
from v$sql
where sqL_id in (select distinct SQL ID
from DBA_HIST_ACTIVE_SESS_HISTORY
where (SAMPLE_TIME between
to_date(‘xxxxxxxx’, ‘yyyymmdd hh24mi’) and
to_date(‘xxxxxxxx’, ‘yyyymmdd hh24mi’))
and event like ‘%temp%’);

5.查看这批SQL分别占用多少TEMP空间

select *
from (select sample_time,
session_id,
session_serial#,
sql_id,
sum(trunc(TEMP_SPACE_ALLOCATED / 1024 / 1024)) usedMB,
count(*)
from v$active_session_history
where TEMP_SPACE_ALLOCATED is not null
and sample_time between to_date(‘xxxxxxxxxxx’, ‘yyyymmdd hh24mi’) and
to_date(‘xxxxxxxxxxx’, ‘yyyymmdd hh24mi’)
group by sample_time, session_id, session_serial#, sqL_id)
where usedMB > 800
order by 1;
select a.SAMPLE_TIME,
sql_id,
round(sum(temp_space_allocated) / 1024 / 1024, 3) sum_MB
from v$active_session_history a
where a.TEMP_SPACE_ALLOCATED is not null
and sample_time between to_date(‘xxxxxxxxx’, ‘yyyymmdd hh24mi’) and
to_date(’ xxxxxxxxxxx’, ‘yyyymmdd hh24mi’)
group by a.SAMPLE_TIME, sqL_id
order by2 desc;
select a.SAMPLE_TIME,
sql_exec_id,
sql_exec_start,
sum(temp_space_allocated) / 1024 / 1024 / 1024,
sql_id
from dba_hist_active_sess_history a
where a.TEMP_SPACE_ALLOCATED is not null
and sample_time between to_date(‘xxxxxxxxxxx’, ‘yyyymmdd hh24mi’) and
to_date(‘xxxxxxxxxxxx’, ‘yyyymmdd hh24mi’)
and sql_id = ‘xxxxxxxx’
group by a.SAMPLE_TIME, sql_exec_id, sql_exec_start,sql_id
order by 1;

–找到SQL对应的对象

select to_char(wm_concat(distinct ‘’‘’ || current_obj# || ‘’‘’)) currentobj
from dba_hist_active_sess_history
where sample_time between to_date(‘xxxxxxxxx’, ‘yyyymmdd hh24mi’) and
to_date(‘xxxxxxxxx’, ‘yyyymmdd hh24mi ‘)
and sql_id = ‘xxxxxxxx’
group by current_obj#select distinct owner, object_name
from dba_objects
where object_id in (’¤t obj’)

例1:如果查询到一个sql持续占用temp表空间且使用率越来越高,需要关注这个sql,后面故障点sql可能是受害者

temp表空间满分析oracle_sql

例2:并发开启的多个进程,没有集中在一个sql

temp表空间满分析oracle_temp_02

标签:1024,date,temp,空间,yyyymmdd,sql,oracle,id,hh24mi
From: https://blog.51cto.com/u_13482808/8340314

相关文章

  • oracle 在线重定义表
    使用Oracle的在线重定义技术,可以将Oracle的普通表改为分区表。参考&感谢https://blog.csdn.net/qq_32784541/article/details/81507719?spm=1001.2101.3001.6650.13&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-13-81507719-b......
  • Oracle database 清理日志文件
    Oracledatabase清理日志文件(listener.log/alertlog)监听日志清理(listener.log)以oracle用户登录,切换到以下目录[oracle@oracledb/]$cd$ORACLE_BASE/diag/tnslsnr/服务器用户名/listener/trace/停止监听服务进程(tnslsnr)记录日志[oracle@oracledbtrace]$lsnrctlsetlo......
  • fgui 怎么将"UI空间下的世界坐标"转换成"fgui空间下的世界坐标( global pos )" cocosc
    嗨~如果本文对你有帮助,点个推荐吧!这样能让文章在搜索中更靠前,帮助到更多有需要的人!首先通过坐标系转换一步步地进行计算我尝试过,但卡在了将屏幕坐标转换为fgui空间的全局坐标上。但发现了一个巧妙的做法。//随便的一个Cocoscreator的NodevaranyCCUINode=this._labe......
  • SpringBoot: RestTemplate中文乱码
    1.问题原因RestTemplate的构造器创建了一个默认字符集为ISO-8859-1的StringHttpMessageConverter对象,它的默认编码格式为ISO-8859-1,所以需要修改这个StringHttpMessageConverter对象的编码格式即可2.解决方案@BeanpublicRestTemplategetRestTemplate(){......
  • 2023-2024-1学期20232412《网络空间安全导论》第十周学习总结
    教材学习内容总结本周主要学习《网络空间安全导论》第一章的内容,初步了解了网络空间安全的概念以及学科所覆盖的内容,了解了相关的法律法规,并且接触了之前从未了解的信息安全标准。通过第一章的学习,我也正式开始对我们专业的学习,认识到网络空间安全的重要性,掌握了计算机学习与其他......
  • 2023-2024-1 20232421 《网络空间安全导论》第10周学习总结
    教材学习总结国内外网络安全的现状网络空间安全的内容网络空间安全受到重视的原因课程涵盖内容思维导图教材学习中的问题和解决过程问题1:混淆信息安全与网络空间安全的概念,并执着于将其区分开。问题1解决办法:研读教材:教材中由信息安全引出网络空间安全,援引信息论的论述......
  • 2023-2024-1 20232426刘嘉成 《网络空间安全导论》第1周学习总结
    2023-2024-120232426刘嘉成《网络空间安全导论》第1周学习总结教材学习内容总结简要总结本周学习内容:本周我自学了《网络空间安全导论》第一章:网络空间安全概述,分别从信息时代与信息安全,网络空间安全学科浅谈,网络空间安全法律法规,信息安全标准四个方面进行了学习。对我国网......
  • 《2023-2024-1 202324《网络空间安全导论》第十一周学习总结》
    《2023-2024-1202324《网络空间安全导论》第十一周学习总结》教材学习内容总结本周学习了《网络空间安全导论》的第一章,着重学习了网络空间安全的概念与内涵,我国关于网络空间安全的法律法规,信息安全标准等内容。由于对于这门课的了解不够深刻,知识要点不清晰,好像就只是看了一遍......
  • 网络空间安全导论第一章
    学期(2023-2024-1)学号(20232418)《网络》第1周学习总结教材学习内容总结第一章网络空间安全概述教材学习中的问题和解决过程问题1:监测预警与紧急处理问题1解决方案:检索国务院有关法律法规,了解国家对于预警与紧急处理的应对方案问题2:什么是网络空间安全学科问题2解决方案:了......
  • 《网络空间安全导论》第一章 网络空间安全概述
    1.1信息时代与信息安全1.1.1信息技术与产业空前繁荣1.我国已经成为信息技术与产业大国,网民规模世界第一,超级计算机技术居世界领先水平。2.量子信息技术高速发展,推动了量子计算机、量子通信和量子密码的发展。1.1.2信息安全形式严峻1.敌对势力的破坏:美国国家安全局NSA对我国......