You are on page 1of 16

SEGMENT ADVISOR The segment advisor is used to find out if a segment is a candidate for shrink operation.

Generally tables on which frequent update,delete and insert operations are performed gets fragmented. As a result of which the table occupies more space than what is required by it. This leads to reading of more data blocks during full scan. Thus increasing the response time of queries on that table. In order to overcome this type of problem we need to identify the tables that are candidates for shrink operation. The S G! "T A#$IS%& enables us to do so. 'or the demonstration let us do the followings () *reate a table +) ,opulate it with records -) #elete few records .) Again insert few records /) &epeat steps + 0 . few times in order to create the fragmentation 1) 'inally run the segment advisor to get recommendations 2) Shrink the segment S345 create table hr.emp + as - select 6 from hr.employees . where (78(9 1 Table created.

S345

2 S345 begin + . / for i in (..(::: loop insert into hr.emp select 6 from hr.employees9 end loop9

1 end9 ,4;S34 procedure successfully completed.

S345 commit 9 *ommit complete.

S345 delete from hr.emp where department<id8/:9

./::: rows deleted.

S345 begin + . / 1 for i in (../:: loop insert into hr.emp select 6 from hr.employees9 commit9 end loop9

2 end9 = ;

,4;S34 procedure successfully completed.

S345 begin + . / 1 for i in (../:: loop insert into hr.emp select 6 from hr.employees9 commit9 end loop9

2 end9 = ;

,4;S34 procedure successfully completed.

S345 delete from hr.emp where department<id8-:9

(+::: rows deleted.

S345 commit9

*ommit complete.

S345 delete from hr.emp where department<id8(::9

(+::: rows deleted.

S345 commit9

*ommit complete.

S345 delete from hr.emp where department<id8/:9

./::: rows deleted.

S345 commit9

*ommit complete.

S345 delete from hr.emp where department<id8=:9

1=::: rows deleted.

S345 commit9

*ommit complete.

S345 alter table hr.emp enable row movement9

Table altered.

S345 7emctl start dbconsole T> set to Asia;*alcutta %racle nterprise !anager (:g #atabase *ontrol &elease (:.+.:.(.: *opyright ?c) (@@1, +::/ %racle *orporation. All rights reserved. httpA;;station.:.eBample.comA//:-;em;console;aboutApplication Starting %racle nterprise !anager (:g #atabase *ontrol ........................ started. 000000000000000000000000000000000000000000000000000000000000000000 4ogs are generated in directory ;u:(;app;oracle;product;(:.+.:;db<(;station.:.eBample.com<mydb;sysman;log

S345

Start nterprise !anager *lick on the Administration tab Go to the bottom of the page *lick on Advisor *entral 4ink *lick on Segment Advisor 'ollow the Steps to gather recommendations

S345 eBecute dbms<stats.gather<table<stats?CD&C,C !,C)9

,4;S34 procedure successfully completed.

--No of blocks consumed by the table before the shrink operation. S345 select table<name,blocks + from dba<tables - where table<name8C !,C . and owner8CD&C9

TAE4 <"A!

E4%*FS

000000000000000000000000000000 000000000000 !, (2/1

S345 alter table hr.emp shrink space cascade9

Table altered.

S345 eBecute dbms<stats.gather<table<stats?CD&C,C !,C)9

,4;S34 procedure successfully completed.

--No of blocks consumed by the table after the shrink operation. S345 select table<name, + blocks

- from dba<tables . where owner8CD&C / and table<name8C !,C9

TAE4 <"A! 000000000000000000000000000000 !,

E4%*FS 000000000000 +=-

Gou can note that the number of blocks have reduced incredibly after the shrink operation.

You might also like