当前位置:网站首页>An analysis and treatment of abnormal growth of Oracle database table space
An analysis and treatment of abnormal growth of Oracle database table space
2022-04-22 16:18:00 【Ink Sky Wheel】
Preface :
the other day , During my daily inspection of the database, I found , There is a database with little business volume at ordinary times ( Through archiving frequency 、 Memory footprint 、 The number of conversations, etc ), Its table space is still in 700MB/ The speed of days is increasing , It doesn't make sense . So I analyzed it by the following means , Found out " Behind the scenes ".
One 、 View tablespace growth

Two 、 Find out which tablespaces are growing

3、 ... and 、 Find out which tables in the corresponding table space caused the abnormal growth of space
I wanted to dba_hist_seg_stat View to get useful information , As a result, I found that the information in it was not complete , And the data obtained are not accurate , In the end, I didn't find any useful clues through this view .
So-called “ All roads lead to Beijing ”, The road above is blocked , I'll take a slightly detour to get the information I want . Now that we know which table space is growing abnormally , Then I just need to write a stored procedure , Regularly record the data changes of all tables in this table space .
– First create a table to record data
create table TB_USAGE_RECORD
(
ctime DATE,
segment_name VARCHAR2(200),
partition_name VARCHAR2(200)
segment_type VARCHAR2(30),
header_file NUMBER,
header_block NUMBER,
size_gb NUMBER
)
create table TB_USAGE_RECORD_TOTAL
(
ctime DATE,
total_gb NUMBER
);
– Create stored procedure ( The sensitive information in this article has been rewritten and processed )
create or replace procedure gather_tb_size_increase authid current_user
is
begin
insert into TB_USAGE_RECORD select sysdate ctime,segment_name,partition_name,segment_type,header_file,header_block,round(bytes/1024/1024/1024,3) size_gb
from dba_segments where tablespace_name=‘THE_EXCEPTION_TBS’;
insert into TB_USAGE_RECORD_TOTAL select sysdate ctime,round(sum(bytes)/1024/1024/1024,3) total_gb from dba_segments where tablespace_name=‘THE_EXCEPTION_TBS’;
commit;
end;
ok, Now I can execute the stored procedure once , Then set a timing job, Let it be executed again at this time tomorrow . When tomorrow's data is available , You can analyze the problem !
Four 、 Find out the root cause of the problem
Write the following sql And implement , Find the table where the data changes :
See how much data is in the table :
Only found 102 Row data , Looking at the table structure, it is found that there are no large fields , Should not occupy 100 many M What a space ! Then analyze :
-- Collect statistics :analyze table LIST_20220415 compute statistics; Check the actual occupied space :select segment_name,partition_name,round(bytes/1024/1024,2) size_mb from dba_segments where segment_name='LIST_20220415' SEGMENT_NAME PARTITION_NAME SIZE_MB1 LIST_20220415 152 Check how many blocks are actually occupied , Is there an empty block :select table_name,num_rows,blocks,empty_blocks from dba_tables where table_name='LIST_20220415' TABLE_NAME NUM_ROWS BLOCKS EMPTY_BLOCKS1 LIST_20220415 102 222 19234
In fact, the data only uses 222 Block , There are still... Below the high water mark 19234 Empty blocks , That's why 102 Row data takes up (222+19234)*8/1024=152 MB, And dba_segments The values found in are the same .
therefore , The business side should write a lot of data to this table , And then I did delete operation , A large amount of data was deleted , Cause high water mark .
5、 ... and 、 How to deal with the problem
According to the several tables that led to data growth found before , I found that they are all named after specific dates . And I also found the method to create these historical tables in the relevant stored procedures of the database sql. As for the creation of daily history table , It is initiated by the application side directly calling the stored procedure . During this period, the application performs a series of operations on the history table , This creates a high water level . To save storage space , On the one hand, after communicating with the business , The history table should be backed up and cleaned up in time , On the other hand, we should clean up the high water mark of these historical tables every day .
The following is after clearing the high water mark , Table space usage :
SEGMENT_NAME PARTITION_NAME SIZE_MB1 LIST_20220415 0.31
It can be seen that the effect is still very significant , The space occupied is directly occupied by 152MB Down to 0.31MB.
( The end of this paper )
版权声明
本文为[Ink Sky Wheel]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221614455202.html
边栏推荐
- Transforme结构:位置编码 | Transformer Architecture: The Positional Encoding
- The number of distinct data in the query table count MySQL Oracle takes the specified number
- SolidWorks插入内六角螺丝
- Greenplum [environment construction 05] GP latest version V6 20.3 configuration and installation verification (description of kernel parameters + initialization parameters)
- 【Idea】日志的使用
- It's too voluminous ~ (2022 version) large factory face experience + detailed notes to help you finish the interview
- Calculation method of numerator and denominator of system driven by stepping servo motor for rotation angle control
- mobaXterm连接虚拟机后不能拖拽上传文件
- redis简单存储建立文件夹
- The short video produced by we media is very vague? Teach you three ways to make the video clear
猜你喜欢

【洛谷】P1157 组合的输出(dfs)

实验三 FFT及其在卷积计算和谱分析中的应用
![[experience sharing] Why is the green screen displayed after the video picture decoding fails?](/img/c3/e6f290ed781b948f010c84ee928b5c.png)
[experience sharing] Why is the green screen displayed after the video picture decoding fails?

NFT platform security guide

Altium designer automatic cabling for nets other than GND

TCP/IP协议之四TCP协议(上)—理论+实践给你讲清楚

国标GB28181视频平台EasyGBS关闭了录像计划,为何还有录像文件生成?

Want to do self media operation but can't write? 4 valuable operational skills

Servlet 的使用与对应的九个内置对象

Wukong's private collection of "architecture" books recommended
随机推荐
接口测试实战| GET/POST 请求区别详解
Crystal Chem 大豆 ELISA 试剂盒 II说明书
华为交换机配置
领域驱动模型DDD(三)——使用Saga管理事务
Unittest-单元测试2
solidworks两条线重合了如何选其中一条
Altium designer 生成PCB制作文件及打样流程(以嘉立创商城为例)
SolidWorks insert socket head cap screw
One page submits two forms to the same place
电力导线三维模型
万元礼品奖池!玩转「Lighthouse」有奖征文来袭
ICMP与IPv6全局单播地址动态分配
Hx711 weight sensor wiring
NLP之TM:基于gensim库调用20newsgr学习doc-topic分布并保存为train-svm-lda.txt、test-svm-lda.txt
The number of distinct data in the query table count MySQL Oracle takes the specified number
C language insertion sort
设某二叉树采用二叉链表表示(即结点的两个指针分别指示左、右子树),当该二叉树包含k个结点时,其二叉链表结点中必有( )个空的左右指针。
Shell脚本尝试
每周推薦短視頻:存量時代如何重構企業核心競爭力?
Eltable style modification. Parent child components pass values. Fuzzy query