Skip to Main Content
  • Questions
  • dbms_repair.rebuild_freelists v.s Move v.s Shrink

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sahar.

Asked: January 20, 2017 - 2:37 pm UTC

Last updated: January 24, 2017 - 12:48 am UTC

Version: 11.2

Viewed 1000+ times

You Asked

Hi,

In the link https://asktom.oracle.com/pls/apex/f?p=100:11:::NO:RP:P11_QUESTION_ID:9527343800346989243 you explained about Move and Freelist which updates the HWM. Could you please explain to update HWM which option is better dbms_repair.rebuild_freelists, move or shrink?and why? Is there better way to update the HWM (which caused performance issue).

and Connor said...

dbms_repair.rebuild_freelists is more or less "obsolete" in that most tablespaces nowadays will be ASSM, and hence freelist management is no longer done in that fashion.

For exmaple

SQL> exec dbms_repair.rebuild_freelists('MCDONAC','T');
BEGIN dbms_repair.rebuild_freelists('MCDONAC','T'); END;

*
ERROR at line 1:
ORA-10614: Operation not allowed on this segment
ORA-06512: at "SYS.DBMS_REPAIR", line 401
ORA-06512: at line 1


In a nutshell... if you're happy to have the table locked and can rebuild the indexes, then MOVE, otherwise look at SRHINK.

And before either... see if you really are going to get a benefit.

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Sahar, January 23, 2017 - 8:40 pm UTC

Thanks. If the database is using ASSM isn't better to use SHRINK as opposed to MOVE since SHRINK rebuilds the indexes as well?

Also you mentioned a good point. How do we really know if shrinking the segment (releasing HWM) is going to be worthy? Is it going to help the database performance?

Thanks,
Sahar
Connor McDonald
January 24, 2017 - 12:48 am UTC

SHRINK does *not* "rebuild" anything - it simply shifts rows about to fill in 'gaps' so that the high water mark can be moved. Its roughly equivalent to doing a series of deletes/inserts, which is why the indexes dont need to be rebuilt.

MOVE is more "dramatic" - its like a unload/reload of the data, and hence a full rebuild of the indexes is needed.

re: "How do we really know if shrinking the segment (releasing HWM) is going to be worthy?"

If you have lots of queries that do full scans, then a 'lower' HWM should assist them. If all of your access is index lookups, then performance benefits would be expected to be smaller (if any)

Sahar, January 24, 2017 - 3:59 pm UTC


More to Explore

DBMS_REPAIR

More on PL/SQL routine DBMS_REPAIR here