Rebuild DBMS_SPACE

I seem to have corrupted the DBMS_SPACE package. How can I rebuild it?
Thanks

Pl post your full OS, EBS and DB versions. Pl post output of following command
SQL> select owner, object_name, object_type from dba_objects where object_name='DBMS_SPACE_ADMIN';HTH
Srini

Similar Messages

  • How much time it take to rebuild an index for a table with 20 millions rows

    Hi all,
    i need to rebuild the index of a table containing 20 000 000 row (i don't know why the other people working on this didn't think of rebuilding the index regularly, because i asked and apparently it has never been done :cry: :cry:) i am not a sql developper nor a DBA so i can't mesure how long it take to rebuild the index, does any one have an idea (aproximativly of course :aie:), the other question is there any formula to use in order to calculate how often to rebuild the indexes (i can for example retieve how much rows are delated or inserted daily ...)
    Thanks again
    Taha

    taha wrote:
    :aie: that's why i am asking because i don't know (and to be sure which solution is best)
    so the table is like this (the columns) :
    45 varchar2, 5 timestamp, 30 Number no LOB columns, (15 indexes : 5 unique indexes and that those indexes uses at a maximum 4 columns)15 indexes - 100,000 deletes: this could mean 1,500,000 block visits to maintain index leaf blocks as the table rows are deleted. If you're unlucky this could turn into 1,500,000 physical block read requests; if you're lucky, or the system is well engineered this could be virtually no physical I/O. The difference in time could be huge. At any rate it is likely to be 1,500,000 redo entries at 250 - 300 bytes per entry for a total of about 400MB of redo (so how large are your redo logs and how many log switches are you going to cause).
    yes the tables is used by an application so (update, insert ) can take place at any time
    for the deletion , there is the batch which does a mass delete on the table ( 4 or 5 time each day)
    You haven't answered the question - how long does it take to do a sample batch delete.
    If you can enable SQL tracing, or take a before/after snapshot of v$sesstat or v$session_event for the session as it does the delete then you can get some idea of where the time is going - for all you know it might be spending most of its time waiting for a lock to do away.
    >
    "How many leaf blocks are currently allocated to the index(es) ?" how can i answer to this question ? may be if i check the all_objects table ?
    If you keep your statistics up to date then dba_indexes is a good place, cross-checked with dba_segments, and you can use the dbms_space package for more detail. I have a code sample on my blog which allows you to compare the current size of your indexes with the size they would be if rebuilt at some specific percentage: http://jonathanlewis.wordpress.com/index-sizing/ (It's such good code that Oracle Corp. has copied it into MOS note 989186.1)
    Regards
    Jonathan Lewis

  • Rebuild Table

    Table where lots of deletion or insertion takes place , probably has High HWM. If the HWM is high , it is better to rebuild table segment for performance sake.
    my question is when to rebuild a table/index and how to find that a table has High water mark?
    please revert me with the answer.

    hi
    to find high water mark ...
    here it is .......
    There is no single system table which contains the high water mark (HWM) for a table. A table's HWM can be calculated using the results from the following SQL statements:
    SELECT BLOCKS
    FROM DBA_SEGMENTS
    WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
    ANALYZE TABLE owner.table ESTIMATE STATISTICS;
    SELECT EMPTY_BLOCKS
    FROM DBA_TABLES
    WHERE OWNER=UPPER(owner) AND TABLE_NAME = UPPER(table);
    Thus, the tables' HWM = (query result 1) - (query result 2) - 1
    NOTE: You can also use the DBMS_SPACE package and calculate the HWM = TOTAL_BLOCKS - UNUSED_BLOCKS - 1.
    and if the index rebuild...
    http://www.quest-pipelines.com/newsletter-v2/rebuild.htm
    hope this helps
    CHeers

  • Rebuilding an iTunes Library: How to Do It & What to Expect

    When iTunes is performing poorly--sluggishness, weird Podcast updating behavior, etc.--and you have tried everything, the prospect arises of rebuilding the iTunes Library. Instructions are simple. The idea is that the XML Library file will inevitably be "cleaner" than the possibly corrupted ITL file which is the file that iTunes edits in managing your iTunes content, and that after rebuilding your library from the xml file, you will have a fresh, clean ITL file. So, back up your machine. Then, go to your iTunes folder and TRASH the file "iTunes ibrary.itl" in the ~/Music/Tunes Folder. Do not empty the Trash. Also, MOVE the file "iTunes Music Library.xml" to your Desktop. Then start iTunes, select Import in the File Menu and select the iTunes Music Library.xml" that is on your Desktop. It could take hours depending on the size and you can just wait until the automatic rebuild is complete. Incidentally, I strongly recommend that you also disconnect your Mac from the Internet during this entire procedure; more on that later.
    Here is the caveat in rebuilding your Library: Apple purposely does not document the ITL file and will only say that most but not all of the information is written to the XML file, a file that technically only exists so that third party applications might be able to work with the iTunes Library. So what information will be missing after you rebuild you library from the XML file? Here is what I found:
    i. Music library and playlists: Good news, this remains intact. However, if your ITL file was corrupted you will discover some funny business. For example, there may be items such as Podcasts you have converted to Music files that reappear as Podcast files. You may find that there are files that are missing or files that you know you have, but seem to be missing from the new iTunes Library. There are various utilities or iTunes plugins such as those from the Doug's Applescripts site that will automate the discovery of these and other problems. Also, alas, the Date Added for all files will be today's date and time, not the day and time from as long as 10 years ago.
    Your iDeivces (iPods, iPhones, and iPads) will see this rebult library as entirely new. Thus, you will need to decide which Playlists, Artists, etc. to manage/import into each of your iDevices as though they are brand new. Basically, this is a time consuming slog, but you will need to do it. All will be erased and reimported even though they are already on your device. Dumb but there you have it.
    Movies, TV Shows, Audiobooks, Books, and Photos: These will remain intact with the same general caveats and iDeivce reimport issues as with the Music files. Namely, you will need to decide what you want to sync anew.
    Apps: Here is something that is not included n the XML file. Fortunately, the fix is to simply drag the contents of the Mobile Applications folder into iTunes and drop it. The import will be automatic. However, there may be multiple versions of some of your apps. about which iTunes will warn you and ask for a decision. Unfortunately, the file names of the multiple version apps are not given. So, my technique is to keep the newest version and leave the older one where it is, keeping a list of all of the ones you did not import. After you are done with the import you can go to the Apps window in iTunes, find the imported versions of those files, right click the icon, and then select "Show in Finder." You will then know the file name of the kept file and by inference can identify and decide what you want to do with the other version. In may cases it turns out to be a downrev version that can be moved elsewhere. However, it could also be a version for, say, your iPhone, that does not work with your iPad. In this case, import it and keep it. I would suggest keeping all of the seemingly orphaned apps around for awhile just in case you later find you need them.
    Good news: When you connect your iDevice(s) to iTunes you will find that iTunes accepts the apps already installed on them. You need do nothing further in most cases. Wonderful.
    Podcasts: Hopefully you heeded my advice to disconnect from the Internet. Because Podcasts seem to be the most problematic of the Library. If connected to the Internet you may, for example, find that the Podcasts will begin to download episodes willy nilly and contrary to your preferred settings. You don't need this right now! So, that said, the Podcasts will be restored including Podcasts that may not currently have any current episodes in them. However, you may find that you will need to Subscribe to some podcasts even though you already had a subscription. In fact, some this having to Subscribe may persist over a few days. Just go ahead and do it of you want the subscriptions. Also, make sure that the Settings for each Podcast are as you like them. You can then connect your iDevice and set it up just as though it is new and iTunes will tediously build your new Podcast library on your iDevice just as with your Music files. Of course you will need to do this for each of your iDevices.
    One other thing to watch in connection with Podcasts is your Music section. I ended up with almost 3000 podcast episodes that were not current that were listed in my Music section but greyed out and identified as Streaming content. Rooting these out was a simple matter of selecting for "Genre" and deleting all of the genre "Streaming" from the Library. This list had nothing to do with the settings for Podcasts. It may be a bug or just one of the symptoms of corruption of my particular original ITL file. Notably, I was connected to the Internet when I rebuilt my Library and this is one of the reasons I highly recommend disconnecting before the rebuild. However, this gremlin could occur when you do reconnect. I don't know and I am not about to test for it, So watch for this or for other funny business.
    Cloud/iTunes Match stuff: If you had turned on iTunes Match I have no help for you. I have never used it. Intuitively, I suspect this could be an epic mess in the context of rebuilding your Library from the XML file. But maybe not--hopefully not!
    iPads, iPhones and the Library: In my case it appears that much of the problem with my iTunes Library file had to do with anomalies and differences betwen what my iTunes Library thought was on a device and what was actually there. Do not be surprised if you feel that you need to restore one of your iDevices. However, prior to doing so consider making an encrypted backup of your iDevice. Encrypted backups include settings and other information that could take hours to reenter and is not included on regular style backups. After a restore, you can be sure that this restoration will be the canonical status of both what is on your iDevice and what iTunes thinks is on your device. Thus you can work with this and then modify it confidently.
    Epilogue: For me, this procedure restored performance to iTunes that had been getting steadily worse for about two years. The new ITL file was about 1MB smaller than the old one. Incidentally, even though the ITL fle was modified by iTunes with most major iTunes versions, it traced its provenance back to 2004 when I got my first iPod. That is very long time and so the development of errors and weirdness is not terribly surprising.

    Because the Nano was previous synced to another comuter/iTunes library.
    See the following:
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive: Apple Support Communities

  • Rebuilding indexes after importing...

    My coworker and I are discussing whether it is necessary, or advised, to rebuild indexes after an import of the schema.
    My thinking is that the index data is put into fresh blocks thereby creating a very flat index tree without any fragmentation.
    But my coworker suspects that perhaps the blocks are built exactly as they existed in the source database.
    I could understand, perhaps, if the refresh were done by using RMAN which copies block by block, but even then I'm not sure.
    Can you help us understand this please?
    Thanks.
    Ed

    Hi,
    Normally, the indexes are build and statistics upfated after the import automatically. You do not ned to generate the statistics after the import until unless you are running very old version of database.
    Regards
    [sfa-dev1:oracle:10.2.0] $ imp help=Y
    Import: Release 10.2.0.4.0 - Production on Fri Nov 13 11:49:56 2009
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    You can let Import prompt you for parameters by entering the IMP
    command followed by your username/password:
    Example: IMP SCOTT/TIGER
    Or, you can control how Import runs by entering the IMP command followed
    by various arguments. To specify parameters, you use keywords:
    Format: IMP KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
    Example: IMP SCOTT/TIGER IGNORE=Y TABLES=(EMP,DEPT) FULL=N
    or TABLES=(T1:P1,T1:P2), if T1 is partitioned table
    USERID must be the first parameter on the command line.
    Keyword Description (Default) Keyword Description (Default)
    USERID username/password FULL import entire file (N)
    BUFFER size of data buffer FROMUSER list of owner usernames
    FILE input files (EXPDAT.DMP) TOUSER list of usernames
    SHOW just list file contents (N) TABLES list of table names
    IGNORE ignore create errors (N) RECORDLENGTH length of IO record
    GRANTS import grants (Y) INCTYPE incremental import type
    INDEXES import indexes (Y) COMMIT commit array insert (N)
    ROWS import data rows (Y) PARFILE parameter filename
    LOG log file of screen output CONSTRAINTS import constraints (Y)
    DESTROY overwrite tablespace data file (N)
    INDEXFILE write table/index info to specified file
    SKIP_UNUSABLE_INDEXES skip maintenance of unusable indexes (N)
    FEEDBACK display progress every x rows(0)
    TOID_NOVALIDATE skip validation of specified type ids
    FILESIZE maximum size of each dump file
    STATISTICS             import precomputed statistics (always) On 10gR2
    Edited by: skvaish1 on Nov 13, 2009 11:50 AM

  • Index rebuild

    Hi Team,
    Please tell me any difference b/w alter index <index> rebuild or alter index <index> rebuild move.
    Is there any difference that more space will be released if I move index to diffrenet tablespace and move move back to orginal tablespace.
    I know that if we use move option we can move index to different tablespace,
    Regards,
    jit

    Even if you would do lots of dml's, that's not certainly means that you need the rebuilding of the index. If your assertion is based on this that there would be some "holes" within the leaf blocks which wont be reused and would require a rebuild, it's wrong then since Oracle would take care of these things on its own. So again, what criteria, other than an OLTP db you used to conclude that you need rebuilding of indexes?
    But I just wanted to know If I go for alter index rebuild or alter index rebuild move and move back the indexes, which option will be best for me mean by which option I can reclaim more space.Well, I am sorry to say but I think you really don't know very well both the commands. The commands don't differ in the space reclaim given by them but in the way they do the rebuild. Please read the documentation to know what both commands do and how? BTW, from where you picked the command alter index rebuild move since I am not sure that such command exists?
    Aman....

  • Different b/w index rebuild and index rebuild online

    hi..guys could u plz tel me difference between index rebuild and index rebuild online

    There is no difference in both the commands. Both will rebuild the index structure from the scratch.But in the first case with only Rebuild, as long as the index, its temporary segment is not prepared and merged together, index is not available for the other users for use. The Online clause makes the index available for others even while being rebuild.
    Rebuilding index online has the same concept of creating them online to some extent,
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96521/indexes.htm#3062
    HTH
    Aman....

  • Difference between "REBUILD ONLINE" and "REBUILD" while altering index

    Hi Everyone,
    Please go through this link.
    [http://docs.oracle.com/cd/B28359_01/server.111/b28310/indexes004.htm#i1006864]
    Now if Rebuilding online enables you to update base tables at the same time that you are rebuilding, then when the base table is getting updated while Rebuilding without online option?
    Regards,
    BS2012

    Hi,
    I believe it work like this way
    rebuild without online option => table and index is locked in exclusive mode preventing any translations on the table.
    With online index rebuild, transactions can still access the table and index.

  • What is the difference between the drop and create the index and rebuild index ?

    Hi All,
    what is the difference between drop and create index & rebuild index ? i think both are same...Please clarify if both are same or any difference...
    Thanks in Advance,
    rup

    Both are same. Rebuilding an index drops and re-creates the index. 
    Ref:
    SSMS - https://technet.microsoft.com/en-us/library/ms187874(v=sql.105).aspx
    TSQL - https://msdn.microsoft.com/en-us/library/ms188388.aspx
    I would suggest you to also refer one of the best index maintenance script as below:
    https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

  • Online Rebuild Index Vs Shrinking With Compact Segment with Release space

    Hi All,
    I want to know which is the better option from these as far as availabiltiy of index
    is concerned
    I have been doing online INdex rebuild and haven't faced much problems but new to Shrinking
    What Grid COntrol says about shrinking is
    "This will first compact the segments and then release the recovered space to the tablespace.
    During the short space release phase, any cursors referencing this segment may be
    invalidated and queries on the segment could be affected"
    I dont know how much is that affect...Can anybody share their experience and knowledge
    about shrinking .....
    My Idea is to reclaim the space from the INdexes
    Thanks
    Gagan

    It depends on many factors of which you have mentioned none.
    The affect of cursor invalidation, for example, might be different on Monday than on Tuesday.
    You should test this in as real a simulated environment as you can but likely any issues will be minimal.
    Just don't be surprised by a surprise or two.

  • REBUILD INDEX vs DROP/CREATE INDEX

    Hi there,
    Does anyone has already got some performance degradation after REBUILD INDEXes ? Would it be better to perform DROP/CREATE INDEX instead ?
    Thank you very much for anu reply.
    Best regards,
    Helena

    Hi,
    >>so is it then better to DROP/CREATE them ?
    Well, In fact I learned that when you rebuild an index, Oracle creates a new index from the old index and does not perform sorting while building the new index, which results in performance enhancement. In this case, depending of the size of your data it's necessary sufficient space on a tablespace for storing the old as well as the new index (while creating the new index). Other advantage, is that Oracle can use the old index for answering queries while it builds the new index too using [alter index <index_name> rebuild online].
    Cheers

  • Rebuild Index VS Drop and Rebuild?

    Hey all,
    I am currently redesigning a weekly process (weekly coz we pre determined the rate of index fragmentation) for specific indexes that get massive updates. The old process has proved to be able to fix and maintain reports performance.
    In this process we rebuild specific indexes using the below command:
    Alter index index_name rebuild online;
    This command takes around 10 min for selected indexes.
    Testing the below took 2 min for 6 or 7 indexes.
    Drop Index Index_Name;
    Create Index Index_Name on Table_name (Col1, col, ..);
    I know that indexes might not be used, and the application performance would be degraded with stale or non-existent stats. But our production and all our test DBs have procedures that daily gather stats on them.
    I tested the below script to make sure that execution plan does not change:
    SELECT ProductID, ProductName, MfrID FROM PRODUCT WHERE MFRID = 'Mfr1';
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 37 | 3737 | 13 (0)|
    | 1 | TABLE ACCESS BY INDEX ROWID| PRODUCT | 37 | 3737 | 13 (0)|
    | 2 | INDEX RANGE SCAN | PRODUCT_X1 | 37 | | 3 (0)|
    dropping PRODUCT_X1 and recreating it only changed the cost to 12.
    Gathering the stats again took the cost to 14.
    No performance issues were faced and index was still used.
    My question is: Is there any oracle recommendation that requires rebuilding the index instead of dropping and recreating it?
    Is there any side effect to my approach that I did not consider?
    Thank you

    Charlov wrote:
    I am currently redesigning a weekly process (weekly coz we pre determined the rate of index fragmentation)Nice. Not only have you defined and located index fragmentation but have also measured the rate at which it occurs.
    Could you please share your definition of index fragmentation, how you detect it, and how you measure the rate of change of this fragmentation.
    I am curious about all this since it can be repeatedly shown that Oracle btree indexes are never fragmented.
    http://richardfoote.files.wordpress.com/2007/12/index-internals-rebuilding-the-truth-ii.pdf
    The old process has proved to be able to fix and maintain reports performance.Great so you have traces and run time statistics from before and after the rebuild that highlight this mysterious fragmentation and show how the fragmentation caused the report to be slow, details what effects the rebuild had that caused the reports to perform better.
    Please share them as these would be an interesting discussion point since no one has been able to show previously how an index rebuild caused a report to run faster or even show the fragmentation that caused it to be slow in the first place.
    I mean it would be a pity if the report was just slow because of an inefficient plan and compressing an index or two that probably shouldn't be used in teh first place appears to temporarily speed it up. Could you imagine rebuilding indexes every week, because some developer put the wrong hint in a query? That would be pretty funny.

  • "analyze index"  vs  "rebuild index"

    Hi,
    I don't undestand the difference between "analyze index" and "rebuild index".
    I have a table where I do a lot of "insert" and "update" and "query", What is the best thing to do ??
    thanks
    Giordano

    When you use dbms_stats.gather_schema_stats package with cascade=>true option, you are also collecting stats for the indexes, no need to collects stats separately using dbms_stats.gather_index_stats.Of course, but I refered to the rebuild index question. Therefore I only mentioned the GATHER_INDEX_STATS.
    Auto_sample_size has many problems/bugs in 9iOk didn't know that - I'm using 10gR2.
    But this discussion made me curious. So I tried something (10gR2):
    CREATE TABLE BIG NOLOGGING AS
    WITH GEN AS (
    SELECT ROWNUM ID FROM ALL_OBJECTS WHERE ROWNUM <=10000)
    SELECT V1.ID,RPAD('A',10) C FROM GEN V1,GEN V2
    WHERE ROWNUM <=10000000;
    SELECT COUNT(*) FROM BIG;
    COUNT(*)
    10000000
    So I had a Table containing 10 Million rows. Now I indexed ID:
    CREATE INDEX BIG_IDX ON BIG(ID)
    I tested two different methods:
    1.) GATHER_TABLE_STATS with estimate 10%
    EXEC DBMS_STATS.GATHER_TABLE_STATS(TABNAME=>'BIG',OWNNAME=>'DIMITRI',CASCADE=>TRUE,ESTIMATE_PERCENT=>10);
    It took about 6 seconds (I only set timing on in sqlplus, no 10046 trace) Now I checked the estimated values:
    SELECT NUM_ROWS,SAMPLE_SIZE,ABS(10000000-NUM_ROWS)/100000 VARIANCE,'TABLE' OBJECT FROM USER_TABLES WHERE TABLE_NAME='BIG'
    UNION ALL
    SELECT NUM_ROWS,SAMPLE_SIZE,ABS(10000000-NUM_ROWS)/100000 VARIANCE,'INDEX' OBJECT FROM USER_INDEXES WHERE INDEX_NAME='BIG_IDX';
    NUM_ROWS SAMPLE_SIZE VARIANCE OBJEC
    9985220 998522 ,1478 TABLE
    9996210 999621 ,0379 INDEX
    2.) GATHER_TABLE_STATS with DBMS_STATS.AUTO_SAMPLE_SIZE
    EXEC DBMS_STATS.DELETE_TABLE_STATS(OWNNAME=>'DIMITRI',TABNAME=>'BIG');
    EXEC DBMS_STATS.GATHER_TABLE_STATS(TABNAME=>'BIG',OWNNAME=>'DIMITRI',CASCADE=>TRUE,ESTIMATE_PERCENT=>DBMS_STATS.AUTO_SAMPLE_SIZE);
    It took about 1,5 seconds. Now the results:
    NUM_ROWS SAMPLE_SIZE VARIANCE OBJEC
    9826851 4715 1,73149 TABLE
    10262432 561326 2,62432 INDEX
    The estimate 10% was more exact - also a 1,7 and 2,6 percent variance is still ok. It's also very interesting, that using AUTO_SAMPLE_SIZE
    causes oracle to execute a estimate 5% for the index and a estimate 0.5 for the table.
    I tried again with a table containing only 1 Million records and oracle did an estimate with 100% for the index.
    So for me I will continue using AUTO_SAMPLE_SIZE. Its very flexible, fast and accurate.
    Dim
    PS: Is there a way to format code like one can do in HTML using <code> or <pre>?

  • Rebuild index vs Analyze index

    Hi All,
    I am realy confused about rebuilding index versus Analyzing index.
    Could anyone plz help me out what is the diffrence between them.
    How to Perform analyze of indexes and Rebuld of Indexes for both Oracle 9i and 10g databases.
    Thanks a lot

    CKPT wrote:
    You can see the posts of experts by jonathan
    I am realy confused about rebuilding index versus Analyzing index. tell us you are getting confused why we need to ananlyze before reubild index? if so
    if index analyzed the whole statistics of index will be gathered.... then you can check what is the hieght of the index.. according to the height of the index you need to take step is index need to be really rebuild or not...
    lets see furhter posts from experts if not clear..Thanks OK, so you determine the height of an index is (say) 4. What then ? If you decide to rebuild the index and the index remains at a height of 4, what now ? Was it really worth doing and do you rebuild it again as the index height is still 4 and still within your index rebuild criteria ? At what point do you decide that rebuilding the index just because it has a height of 4 is a total waste of time in this case ?
    OK, so you determine the index only has a height of (say) 3, does that mean you don't rebuild the index ? But what if by rebuilding the index, the index now reduces to a height of just 1 ? Perhaps not rebuilding the index even though it has just a height of 3 and doesn't currently meet your index rebuild criteria is totally the wrong thing to do and a rebuild would result in a significantly leaner and more efficient index structure ?
    So what if it's pointless rebuilding an index with a height of 4 but another index with a height of 3 is a perfect candidate to be rebuilt ?
    Perhaps knowing just the height of an index leaves one totally clueless after all as to whether the index might benefit from an index rebuild ...
    Cheers
    Richard Foote
    http://richardfoote.wordpress.com/

  • Q/s on rebuilding index

    Hi All
    in one of our applications we want to rebuild index which his craete as below, this is on 11G 11.2.0.3.0 Solaris 64bit
    CREATE INDEX idx_id ON scott.branch(bank_id)
    INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS
    ('FILTER CTXSYS.NULL_FILTER SECTION GROUP CTXSYS.HTML_SECTION_GROUP');
    Is rebuilding the index a reasonable option or will that be much slower than a sync ?
    secondly is ctx_ddl package installed by default
    thanks

    hi,
    you should ask this question to: Text for get answers faster.
    by the way, if you installed Oracle Text (which is default on installation) ctx_ddl package is also comming too.

Maybe you are looking for