这段时间发现生产环境数据库查询变得异常慢,即使是只有两条数据的表查询也要花6s!!
推测是最近测试系统功能,点开了一张以前没有点开过的表,表里390w+数据,造成临时表空间爆了。
查看表空间使用率
SELECT a.tablespace_name "表空间名称",
total / (1024 * 1024) "表空间大小(M)",
free / (1024 * 1024) "表空间剩余大小(M)",
(total - free) / (1024 * 1024 ) "表空间使用大小(M)",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name;
查看临时表空间的数据文件及存放路径
select tablespace_name,
file_name,
user_bytes/bytes,
bytes / 1024 / 1024 "file_size(M)",
autoextensible
from dba_temp_files t
where t.TABLESPACE_NAME = 'TEMP';
发现只有29M(图片是扩大后的)
执行sql扩大到4G
alter database tempfile 'FILE_NAME' resize 4G;
速度显著提升!
但没过十分钟,又开始卡起来,但这次不是数据库卡了
检查了系统进程和内存占用也没到60%
jvisualvm显示线程内存占用也不高
测速网测试延迟也只有20ms,上下都有500+mbps
实在找不到原因了
求知道的大神提供一点思路