Академический Документы
Профессиональный Документы
Культура Документы
html
All Oracle segments have an upper boundary containing the data within the segment. This upper boundary is
called the "high water mark" or HWM. The high water mark is an indicator that marks blocks that are allocated to
a segment, but are not used yet. This high water mark typically bumps up at 5 data blocks at a time.
This post, I just needed to tested about determining HWM and reducing it by shrink space.
Tested INSERT/DELETE data:
declare
i number;
begin
for i in 1..10 loop
execute immediate 'delete from TB_DATA1 where rownum <=100000';
execute immediate 'insert /*+ append (TB_DATA1) */ into TB_DATA1 select * from dba_objects
where rownum <= 100000';
commit;
end loop;
end;
/
Determining HWM, You can use *_tables for BLOCKS, EMPTY_BLOCKS - some information for high water
mark.
BLOCKS: Number blocks that has been formatted to recieve data
EMPTY_BLOCKS: Among the allocated blocks, the blocks that were never used
1/6
---------- ------------ ----------
33163 6 74650
Table analyzed.
On 11g, You can compare table size with table actual size.
*** block size: 8192, BLOCKS*8192 = table size ***
*** NUM_ROWS*AVG_ROW_LEN = actual size ***
System altered.
Explained.
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------
----------
Plan hash value: 4008610712
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74650 | 7290K| 8994 (1)| 00:00:03 |
| 1 | TABLE ACCESS FULL| TB_DATA1 | 74650 | 7290K| 8994 (1)| 00:00:03 |
2/6
------------------------------------------------------------------------------
COUNT(*)
----------
74650
Elapsed: 00:00:00.68
Table altered.
Table altered.
From picture "ALTER TABLE TB_DATA1 SHRINK SPACE COMPACT", that not reduce HWM... check it.
Table analyzed.
3/6
BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
33163 1653 74650
Table altered.
Table altered.
Table analyzed.
System altered.
Explained.
PLAN_TABLE_OUTPUT
4/6
------------------------------------------------------------------------------------------------------------------------
----------
Plan hash value: 4008610712
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74650 | 7290K| 292 (1)| 00:00:01 |
| 1 | TABLE ACCESS FULL| TB_DATA1 | 74650 | 7290K| 292 (1)| 00:00:01 |
------------------------------------------------------------------------------
COUNT(*)
----------
74650
Elapsed: 00:00:00.09
After, HWM was reduced, query faster than and "Cost (%CPU)" value less than.
then used dbms_stats.gather_table_stats procedure also.
Explained.
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------
----------
Plan hash value: 4008610712
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74650 | 7071K| 292 (1)| 00:00:01 |
| 1 | TABLE ACCESS FULL| TB_DATA1 | 74650 | 7071K| 292 (1)| 00:00:01 |
------------------------------------------------------------------------------
Shrinking helps to improve the performance of scan and DML operations on that segment.
On Oracle Version 10.2, You know Automatic Segment Advisor. On 11g, You know Automated Segment Advisor.
It's feature what is helpful for DBA. You don't need to determine HWM by yourself. You can retrieve information
generated by the Segment Advisor.
On "Oracle Database 11g Performance Tuning Recipes" book was also written about Automated Segment
Advisor and showed SQL sample to retrieve information generated by the Segment Advisor.
SELECT
'Segment Advice --------------------------'|| chr(10) ||
5/6
'TABLESPACE_NAME : ' || tablespace_name || chr(10) ||
'SEGMENT_OWNER : ' || segment_owner || chr(10) ||
'SEGMENT_NAME : ' || segment_name || chr(10) ||
'ALLOCATED_SPACE : ' || allocated_space || chr(10) ||
'RECLAIMABLE_SPACE: ' || reclaimable_space || chr(10) ||
'RECOMMENDATIONS : ' || recommendations || chr(10) ||
'SOLUTION 1 : ' || c1 || chr(10) ||
'SOLUTION 2 : ' || c2 || chr(10) ||
'SOLUTION 3 : ' || c3 Advice
FROM
TABLE(dbms_space.asa_recommendations('FALSE', 'FALSE', 'FALSE'))
/
6/6