当前位置:网站首页>Oracle 11g sysaux table space full processing and the difference between move and shrink
Oracle 11g sysaux table space full processing and the difference between move and shrink
2022-07-02 07:04:00 【Virtuous time】
Received today 11G Table empty tablespace SYSAUX exceed 90% An alarm , The previous idea is to simply add data files , Because space storage is non business data , Table space can be compressed through configuration .
Check what content takes up SYSAUX Table space
SELECT occupant_name "Item",
space_usage_kbytes / 1048576 "Space Used (GB)",
schema_name "Schema",
move_procedure "Move Procedure"
FROM v$sysaux_occupants
ORDER BY space_usage_kbytes DESC;
SYSAUX The space occupied by each segment in the table space
SELECT *
FROM (SELECT owner, segment_name, segment_type, SUM(bytes) / 1024 / 1024 / 1024 GB
FROM dba_segments
WHERE tablespace_name = 'SYSAUX'
GROUP BY owner, segment_name, segment_type
ORDER BY 4 DESC)
WHERE rownum < 10
It is found that the highest occupancy is WRI$_OPTSTAT_HISTGRM_HISTORY This table and the one on it 2 An index
SM/OPTSTAT High occupancy processing
Found to be SM/OPTSTAT That is, the statistical information takes up a high space .
After checking, the system retains 31 Statistics for days , There is no need to use such a high :
select dbms_stats.get_stats_history_retention from dual;
The earliest time to view statistics :
select dbms_stats.get_stats_history_availability from dual;
To set retention 10 That's fine :
EXEC dbms_stats.alter_stats_history_retention(10);
Then delete the data ten days ago :
-- For dozens of G In terms of data , This sql More time-consuming , It needs to be executed when the business is idle
exec dbms_stats.purge_stats(sysdate-10);
High water level treatment
After the above cleaning operation , I found that the space occupancy rate did not drop , Because clean up stored procedures dbms_stats.purge_stats(sysdate-10) The essence is delete sql To delete data , High water level needs to be cleared . Reference resources ORACLE Official documents Doc ID 454678.1
-- The business is executed in idle time
1- Take a full backup of the database
2- Move the tables:
SQL> alter table WRI$_OPTSTAT_TAB_HISTORY move;
SQL> alter table WRI$_OPTSTAT_OPR move;
SQL> alter table WRI$_OPTSTAT_IND_HISTORY move;
SQL> alter table WRI$_OPTSTAT_HISTHEAD_HISTORY move;
SQL> alter table WRI$_OPTSTAT_HISTGRM_HISTORY move;
SQL> alter table WRI$_OPTSTAT_AUX_HISTORY move;
3- For indexes, find the indexes for the above tables and rebuild them. In case an index is unusable, please see the following example:
SQL> select status from dba_indexes where index_name='I_WRI$_OPTSTAT_IND_OBJ#_ST';
SQL> select status from dba_indexes where index_name='I_WRI$_OPTSTAT_TAB_ST';
Assuming that indexes: I_WRI$_OPTSTAT_IND_OBJ#_ST & I_WRI$_OPTSTAT_TAB_ST are unusable, then, we have to do the following:
a.Determine the DDL's for the indexes using dbms_metadata package as shown in the example below SQL> set long 4000 SQL> select dbms_metadata.get_ddl('INDEX','I_WRI$_OPTSTAT_IND_OBJ#_ST','SYS') from dual;
SQL> select dbms_metadata.get_ddl('INDEX','I_WRI$_OPTSTAT_TAB_ST','SYS') from dual;
b.Then drop and recreate the indexes using the obtained DDL's. c.Once done you can confirm the status by running the following query for example : SQL> select status from dba_indexes where index_name='I_WRI$_OPTSTAT_IND_OBJ#_ST';
SQL> select status from dba_indexes where index_name='I_WRI$_OPTSTAT_TAB_ST';
4- To ensure that statistics history will be retained for at least 8 days:
SQL> exec dbms_stats.alter_stats_history_retention(8);
Or just for WRI$_OPTSTAT_HISTGRM_HISTORY The table is indexed online
SQL> alter table WRI$_OPTSTAT_HISTGRM_HISTORY move;
Table altered.
SQL> alter index I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST rebuild online;
Index altered.
SQL> alter index I_WRI$_OPTSTAT_H_ST rebuild online;
Index altered.
SQL> exec dbms_stats.alter_stats_history_retention(8);
P.S. move and shrink The difference between
shrink
shrink The premise is , Start the migration first .
alter table WRI$_OPTSTAT_HISTGRM_HISTORY enable row movement;
alter table WRI$_OPTSTAT_HISTGRM_HISTORY shrink space cascade;
Grammatical sketch :
alter table TABLE_NAME shrink space [compact|cascade]
Segment shrink Two stages of implementation :
1、 Data reorganization (compact):
Through a series of insert、delete operation , Arrange the data in front of the segment as much as possible . In this process, you need to add RX lock , That is, lock only the rows that need to be moved .
Because of the rowid Changes , need enable row movement. At the same time disable be based on rowid Of trigger. This process has little impact on the business .
2、HWM adjustment : The second stage is to adjust HWM Location , Free data block .
This process requires adding... To the table X lock , Will cause all on the table DML Statement blocking . It may have a great impact on the system with particularly busy business .
Be careful :shrink space Both phases of the statement execute .
shrink space compact Only perform the first stage . If the system business is busy , You can do it first shrink space compact Reorganizing data , Then execute when the business is not busy shrink space Reduce HWM Free data block .
give an example
alter table TABLE_NAME shrink space compact; –- Just defragment Do not recycle space ,
alter table TABLE_NAME shrink space; –- Defragment and reclaim space .
alter table TABLE_NAME shrink space cascade; – Defragment and reclaim space And sort it out together with the cascading objects of the table ( Such as the index )
alter table pt_table modify PARTITION P1 shrink space cascade; -- Partition table
shrink The advantages of
1. It can be executed online
2. Parameters can be used cascade, At the same time, shrink the index on the table
3. The index will not be invalidated after execution
4. Avoidable alter table move The execution process takes up a lot of table space ( If the table 10G size , that alter table move It's almost necessary 10G Space can be executed ).
move
1、move table The function of :
①: Will a table From the present tablespace Move up to another tablespace On :
②: To change table Existing block The storage parameters of , Such as :alter table t move storage (initial 30k next 50k);
③:move Operation can also be used to solve table The problem of row migration in .
2、 Use move Some do's and don 'ts :
①:table Upper index need rebuild:
We discussed earlier ,move After the operation , Data rowid It has changed , We know ,index It's through rowid Come on fetch Data row , therefore ,table Upper index Yes, we must rebuild Of .
alter index index_name rebuild online;
②:move When the table Lock in
When we are right table Conduct move In operation , Inquire about v$locked_objects View can find ,table Added exclusive lock
③: About move The use of time and space :
When we use alter table move To reduce table Of HWM when , There is one thing that needs attention , At this time , Current tablespace Need to have 1 Twice as much as table Free space for use .
3、 ... and 、move and hrink Is the difference between the :
1、move after , The position of the table in the table space will certainly change , It may move forward or backward , Generally speaking, if there is enough space in the table space in front of the table to accommodate the table , Then move forward , Otherwise move back .
2、shrink after , The position of the table in the table space must not change , That is, the position of the segment header of the table will not change .
3、Move It moves the high water level , But it's not going to free up space for applications , It's below the high water level (below HWM) The operation of .
4、shrink space It also moves high water levels , But it also frees up space for applications , It's up and down the high water level (below and above HWM) There are operations .
5、 Use move when , It's going to change some records ROWID, therefore MOVE Then the index becomes invalid , need REBUILD.
6、 Use shrink space when , The index is maintained automatically . If you do compression when the business is busy ,
You can start with shrink space compact, To compress data without moving it HWM, Wait until it's not busy shrink space Mobile HWM.
7、shrink Indexes can be compressed separately ,alter index xxx shrink space To compress the index . in addition 、 When compressing a table, specify Shrink space cascade The index is compressed at the same time .
Reference documents :
https://blog.csdn.net/csdn201420142015/article/details/100496907
https://blog.csdn.net/renyanjie123/article/details/114832842
https://blog.51cto.com/fengfeng688/1955137
https://www.modb.pro/db/26483
边栏推荐
- SQL injection closure judgment
- php中的数字金额转换大写数字
- Brief analysis of PHP session principle
- Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
- Huawei mindspire open source internship machine test questions
- Explanation and application of annotation and reflection
- Sqli labs customs clearance summary-page2
- sqli-labs通關匯總-page2
- In depth study of JVM bottom layer (II): hotspot virtual machine object
- DeprecationWarning: . ix is deprecated. Please use. loc for label based indexing or. iloc for positi
猜你喜欢

图解Kubernetes中的etcd的访问

CVE-2015-1635(MS15-034 )远程代码执行漏洞复现

Explain in detail the process of realizing Chinese text classification by CNN

Sqli labs customs clearance summary-page3

oracle apex ajax process + dy 校验

CSRF攻击

Cve-2015-1635 (ms15-034) Remote Code Execution Vulnerability recurrence

PgSQL learning notes

解决微信小程序swiper组件bindchange事件抖动问题

IDEA2020中PySpark的两表关联(字段名相同)
随机推荐
php中树形结构转数组(拉平树结构,保留上下级排序)
Oracle rman半自动恢复脚本-restore阶段
2021-07-05C#/CAD二次开发创建圆弧(4)
How to call WebService in PHP development environment?
Explain in detail the process of realizing Chinese text classification by CNN
SQL injection closure judgment
RMAN增量恢复示例(1)-不带未备份的归档日志
PXC high availability cluster summary
MapReduce与YARN原理解析
Date time API details
Ceaspectuss shipping company shipping artificial intelligence products, anytime, anywhere container inspection and reporting to achieve cloud yard, shipping company intelligent digital container contr
解决微信小程序swiper组件bindchange事件抖动问题
Differences between ts and JS
2021-07-19c CAD secondary development creates multiple line segments
php中判断版本号是否连续
Browser scrolling for more implementations
Win10: add or delete boot items, and add user-defined boot files to boot items
JS divides an array into groups of three
Sqli Labs clearance summary - page 2
In depth study of JVM bottom layer (II): hotspot virtual machine object