当前位置: 首页 > news >正文

检查是否存在占用内存过大的SQL

1:此语句检查是否存在占用内存过大的SQL

SELECT *
FROM ( SELECT
A.SESS_ID,
A.THRD_ID,
A.USER_NAME ||':' || A.CURR_SCH LOGIN_INFO,
A.SQL_TEXT,
C.STATUS TRX_STATUS,
DATEDIFF(SS, LAST_RECV_TIME, SYSDATE) SS,
CAST( M.TS * 1.0/1024/1024 AS NUMBER(38,2)) USED_MEMORY_M,
'SP_CLOSE_SESSION(' ||A.SESS_ID ||');' KILL_SESS,
SF_GET_SESSION_SQL(A.SESS_ID) FULL_SQL ,
A.APPNAME|| A.CLNT_IP CLNT_INFO,
A.TRX_ID,
B.IO_WAIT_TIME,
B.LOGIC_READ_CNT,
B.PHY_READ_CNT,
B.RECYCLE_LOGIC_READ_CNT,
B.RECYCLE_PHY_READ_CNT,
C.UPD_CNT,
C.DEL_CNT,
C.INS_CNT
FROM V$SESSIONS A,
V$SQL_STAT B,
V$TRX C,
(SELECT SUM(TOTAL_SIZE) TS,CREATOR FROM V$MEM_POOL GROUP BY CREATOR) M
WHERE A.STATE ='ACTIVE'
AND A.SESS_ID = B.SESSID
AND A.TRX_ID = C.ID
AND A.SESS_ID = C.SESS_ID
AND A.THRD_ID = M.CREATOR)
ORDER BY SS DESC;

2:数据库层面查看内存大概占有多少,请使用以下sql进行查询

select
(select sum(cast(n_pages as bigint)* page_size)/1024/1024 from v$bufferpool)||'MB' as BUFFER_SIZE,
( select sum(cast(total_size as bigint))/1024/1024 from v$mem_pool)||'MB' as mem_pool,
(select sum(cast(n_pages as bigint) * page_size)/1024/1024 from v$bufferpool)+(select sum(cast(total_size as bigint))/1024/1024 from v$mem_pool)||'MB' as TOTAL_SIZE
From dual;

3 单个会话内存使用总量

SELECT A.CREATOR ,
B.SQL_TEXT ,
SUM(A.TOTAL_SIZE)/1024.0/1024.0 TOTAL_M,
SUM(A.DATA_SIZE) /1024.0/1024.0 DATA_SIZE_M --实际使用量
FROM V$MEM_POOL A,
V$SESSIONS B
WHERE A.CREATOR = B.THRD_ID
GROUP BY A.CREATOR,
B.SQL_TEXT
ORDER BY TOTAL_M DESC;

缓冲区

SELECT
(
SELECT
SUM(CAST(PAGE_SIZE AS NUMBER) *CAST(N_PAGES AS NUMBER))/1024/1024
FROM
V$BUFFERPOOL
) ||'MB' AS 缓冲区总大小,
(
SELECT
SUM(TOTAL_SIZE)/1024/1024
FROM
V$MEM_POOL
)||'MB' AS 池总大小,
(
SELECT
SUM(CAST(PAGE_SIZE AS NUMBER) *CAST(N_PAGES AS NUMBER))/1024/1024
FROM
V$BUFFERPOOL
) +
(
SELECT
SUM(TOTAL_SIZE)/1024/1024
FROM
V$MEM_POOL
) ||'MB' AS 总内存大小
FROM DUAL;

http://www.mrgr.cn/news/96783.html

相关文章:

  • Unity中 粒子系统使用整理(一)
  • Vue3.5 企业级管理系统实战(十二):组件尺寸及多语言实现
  • Cesium学习(未完继续)
  • 虚幻5入门
  • 【目标检测】【深度学习】【Pytorch版本】YOLOV2模型算法详解
  • vue3使用v-md-editor完成Markdown内容展示
  • 01_使用Docker将Coding上项目部署到k8s平台
  • 编译玄铁处理器RISC-V指令测试用例
  • EasyExcel导出导入excel工具类
  • Go+Gin实现安全多文件上传:带MD5校验的完整解决方案
  • MySQL 进阶 面经级
  • 一起学习大语言模型-常用命令及模型介绍
  • 2023第十四届蓝桥杯大赛软件赛省赛C/C++ 大学 B 组(真题题解)(C++/Java题解)
  • 41、当你在 index.html 中引用了一个公共文件(比如 common.js),修改这个文件后,用户访问页面时仍然看到旧内容,因为浏览器缓存了旧版本
  • Kafka 4.0入门到熟练
  • 41.C++哈希6(哈希切割/分片/位图/布隆过滤器与海量数据处理场景)
  • ML 聚类算法 dbscan|| OPTICS
  • 【C++】vector常用方法总结
  • Springboot学习笔记3.28
  • JVM——模型分析、回收机制