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.

Similar Messages

  • 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

  • Addendum to David's rebuild index solution

    David (from Barcelona) posted some great info on fixing a fault that can prevent you from searching mail properly.
    http://discussions.apple.com/thread.jspa?threadID=447915#2157235
    My addendum to this is that you can view the progress of the indexing (my drive is fairly silent or my room is fairly loud)
    by clicking on Spotlight. Spotlight will show progress percentage.

    Okay, thx.  That actually answered my question.  I could be wrong but I thought back in 2000 you had to drop and rebuild indexes in a certain order in order to eliminate fragmentation and compress pages, etc.  But, anyway, history doesn't matter
    so I will just do ALTER INDEX ALL REBUILD.  Thx...
    About how non clustred indexes are affected when CI is rebuilt Erland is correct but just for information you should read below link. Behavior was
    little different in SQL Server 2000
    http://blogs.msdn.com/b/sqlserverstorageengine/archive/2007/06/07/what-happens-to-non-clustered-indexes-when-the-table-structure-is-changed.aspx
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles

  • Incompatible PDB format in 'filename'; delete and rebuild

    Hi !
    I have installed VS 2012 , but i have VS 2010 also. After I open  VS 2010 projects with VS 2012 and  click "update", but while i debug it ,there is a error message:
    LINK : fatal error LNK1207: incompatible PDB format in 'C:\Users\Admir\Documents\Visual Studio 2010\Projects\nr.fjaleve.while\Debug\nr.fjaleve.while.pdb'; delete and rebuild.
    What can I do to solve this?
    verify

    Hi verify,
    It seems that it is not the VS debug issue.
    LINK : fatal error LNK1207: incompatible PDB format in 'C:\Users\Admir\Documents\Visual Studio 2010\Projects\nr.fjaleve.while\Debug\nr.fjaleve.while.pdb'; delete and rebuild.
    Please Clean and Rebuild your app under “Build” menu, check it again. If still no help, maybe you could delete it manually, and then rebuild it again. Hope it could help.
    Reference:
    Linker Tools Error LNK1207
    Best Regards,
    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thank you Jack!
     I cleaned my app, ang rebuild it again, and it works.
    verify

  • 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

  • How to find out if an INDEX is corrupt and how to rebuild it ?

    How can I find out (from SQL script) if a given INDEX is corrupt and needs to be rebuild ?
    And how do I rebuild it ?

    How can I find out (from SQL script) if a given INDEX is corruptin 9i (not sure about 10g):
    ANALYZE INDEX index_name VALIDATE  STRUCTURE ;

  • "There is a problem with your mailboxes, please quit and rebuild index"

    Is the error message I am seeing about every 5 minutes now but hadn't seen ever until about 2 weeks ago. What is wrong with Apple Mail and how can I sort this out? Rebuilding does nothing apart from waste my time.

    rebuild the entire mail index. quit mail and delete the file home directory/library/mail/envelope index. then start mail and say yes when it asks to import your messages. see if it works ok after that.

  • Automated Delete and Rebuild of BIA Indexes

    We have several cubes that we will be loading into BIA that use non-cumulative key figures.  We have heard that it is necessary to periodically rebuild these indexes to keep the BIA performance high.  My question is how do we automate this process?  I don't see a process chain step or program for deleting an index. 
    There is program RSDDTREX_AGGREGATES_FILL, but will this rebuild an index if it already exists?

    Hi
    Deleting and rebuilding the Cube indexes will improve the the loading performance.
    It is very much required for for Full loads and Big loads.
    When it comes to Delta loads or Small loads, then it depends upon the volume of data you are going to get.
    Say like you are getting below 10000 records in daily delta's, then i think no need to delete and rebuild indexes.
    If you know that you will get more than1 lack records, then it's good to go for deletion and rebuild of indexes.
    Example : I load an Infocube once by week in full upload (3 millions of records) after deleting all the content of the previous week. Is it a good idea to add steps of deleting/rebuilding indexes in this case ?
    In this case, it is required.
    Note: 1) If you want you can test in your development system, run the same load first time by deleting indexes and second time without deleting the indexes. you will come to know the time difference.
    2) Anyhow deletion and rebuilding of indexes step will take less than 2 or 3 mins time unless if you have huge volume of uncomressed data in your cube.
    Regards,
    Venkatesh.

  • Update Statistics and Rebuild of Indexes

    Hi friends,
    If I execute the Update statistics for a given table thru DB20 does it have any effect on the indexes of this table or is it necessary to rebuild the index using db02
    Regards
    Aliila

    Updating Statistics does not rebuild index while in update states logs it will show you information regarding which indexes needs to be rebuiled which you can rebuild by brtools or executing rsanaora prg in se38.
    Shivam

  • How to rebuild index on a table in a faster way

    Hi All,
    We have using Oracle 9.2.0.3
    On weekly basis we are loading around 20-30 million of data into a table using sqlloader.
    Before loading the data into the table, we are dropping all the indexes adn rebuilding the same once done.
    There are 6 index on the table and rebuilding them takes around 10-11 hours.
    Is there any ways to reduce the time of index rebuilding.
    Rgds,
    Amol

    Doing it that way a
    alter session set skip_unusable_indexes=truemight also be necessary.

  • Rebuilding indexes on a scheduled basis:

    can you please help mefor this :
    1)can you give me a sample schedualr program that rebuilds the indexes on the particular tables for every weekends.

    909551 wrote:
    I am having particualr tables where dml operations are performed in a very frequent manner and in with the huge no of rows i want to rebuid the indexes for these tables every once per week so that i want schedular program for rebuilding the indexes for this one i want sample schedular programSo what is the problem? Why do the indexes need to be rebuild?
    Are the indexes dropped before the DML? And then rebuild? Does not sound like it.
    Instead is sounds like you expect there is something wrong with the indexes after DML and then this needs to be corrected using an index rebuild. So what is wrong with the indexes after the DML?
    How about reading this asktom thread on the topic?

  • How CSSCAN determines which indexes need to be rebuild ?

    Hi everybody,
    i'm currently migrating 3 Oracle databases that contain CP1252 characters unproperly stored in WE8ISO8859P1 instances.
    The key steps of the migration are :
    1. ALTERing CHARACTERSET to WE8MSWIN1252
    2. changing CHARACTER SEMANTIC LENGTH for CHAR and VARCHAR2 columns
    3. truncating data stored in VARCHAR2(4000) columns
    2. Full export
    3. Full import in a ALL32UTF8 instance
    To do all of this (and especially the step 3), i use the CSSCAN utility (very practical !!!).
    And i have a question about CSSCAN: how CSSCAN determines which indexes need to be rebuild. What is the logic ?
    Looking at the CSSCAN report, i have a lot of cells/columns that are affected by the characterset migration, and i have just a few index to rebuild.
    Why would i like to understand the logic ? Because i would like to rebuild ONLY indexes that REALLY need to be rebuilt and i am not sure that all the indexes specified by CSSCAN really need to be rebuilt.
    Thanks for any information about that.
    (and sorry for my english)
    NB: i have managed "function-based indexes" specifically: i drop them before the export, and i recreate them after the import. So my question mostly target the "regular indexes"

    1. All indexes whose key contains at least one character column with convertible or exceptional data, excluding indexes with names equal to some constraint name for the same owner.
    plus
    2. All functional indexes on tables that have columns needing conversion, excluding indexes with names equal to some constraint name for the same owner.
    The condition regarding constraints does not seem to be very fortunate but it comes from times when the appropriate flag in index metadata was not yet available.
    But note that in your migration scenario, you do not actually have to care much about indexes. Step 1 & 2 do not need any modifications to the user data and hence to index contents. Step 3, if done through UPDATE, will modify affected indexes automatically. Step 4 does not affect the database. Step 5 will recreate all existing indexes anyway.
    -- Sergiusz

  • 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

  • "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/

Maybe you are looking for