Rebuilding indexes with monotonically increasing sequences

Hi
I have been reading this paper
http://richardfoote.files.wordpress.com/2007/12/index-internals-rebuilding-the-truth.pdf
*On page 91 we  have*
CREATE TABLE test_empty_block (id NUMBER, name VARCHAR2(30));
Table created.
INSERT INTO test_empty_block SELECT rownum, 'BOWIE' FROM dual
CONNECT BY level <= 10000;
10000 rows created.
COMMIT;
CREATE INDEX test_empty_block_idx ON test_empty_block(id);
Index created.
On page 92 we have
SQL> DELETE test_empty_block WHERE id between 1 and 9990;
9990 rows deleted.
SQL> COMMIT;
Commit complete.
SQL> ANALYZE INDEX test_empty_block_idx VALIDATE STRUCTURE;
Index analyzed.
SQL> SELECT lf_blks, del_lf_rows FROM index_stats;
LF_BLKS DEL_LF_ROWS
21 9990
On page 93
SQL> INSERT INTO test_empty_block SELECT rownum+20000, 'ZIGGY' FROM dual CONNECT BY level <= 10000;
10000 rows created.
SQL> COMMIT;Commit complete.
SQL> ANALYZE INDEX test_empty_block_idx VALIDATE STRUCTURE;
Index analyzed.
SQL> SELECT lf_blks, del_lf_rows FROM index_stats;
LF_BLKS DEL_LF_ROWS
21 0
when the DEL_LF_ROWS is 0
How come Richard goes on to state that on page 96.
Although deleted index space is generally reusable, there can be wasted space
Monotonically increasing index values and deletions
Edited by: 899881 on Jan 3, 2012 9:05 PM
Edited by: 899881 on Jan 3, 2012 9:06 PM

899881 wrote:
How come Richard goes on to state that on page 96.
Although deleted index space is generally reusable, there can be wasted space
Monotonically increasing index values and deletions
I believe this is addressed in page 103 of the same document you posted a link to.

Similar Messages

  • SSIS 2008 Rebuild Index Task increasing Log Size

    I am testing SSIS 2008 Rebuild Index Task on a single database (db1). I shrank the
    db1's log file to initial size. I also checked the box Sort results in tempdb on the SSIS package.
    However, when I run the package, db1's log file size increased about 55 times the original size.
    When I run a rebuild of all the index on db1
    with (sort_in_tempdb=ON) ; there was only a slight increase in the log file size ( did not even double the initial size).
    Is this a SSIS bug? The check box is not actually sorting in tempdb?

    I am testing SSIS 2008 Rebuild Index Task on a single database (db1). I shrank the
    db1's log file to initial size. I also checked the box Sort results in tempdb on the SSIS package.
    However, when I run the package, db1's log file size increased about 55 times the original size.
    When I run a rebuild of all the index on db1
    with (sort_in_tempdb=ON) ; there was only a slight increase in the log file size ( did not even double the initial size).
    Is this a SSIS bug? The check box is not actually sorting in tempdb?
    Arthur can you please move this thread in Database engine forum. IMO its what changed from 2008 .Index rebuild is fully logged from 2008 onwards it was previously (in 2005) minimally logged .Refer below link for information regarding same
    http://support.microsoft.com/kb/2407439/en-gb
    Now about when sort intempdb is used.The intermediate sort results that are used to build the index are stored in tempdb .When you rebuild without sort_in_tempdb ( i guess your data and log file are on same drive) index will utilize disk space on which it
    resides so it might seem to you log has increased.Is it so ,am i correct.
    What query you used to measure log file size,are you absolutely sure it was log file that increased
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Multiple objects with same name when rebuilding index online

    I am looking for advice on how to handle a race-condition in sql server, related to reading metadata while an online index rebuild is being performed.
    The problem is as follows:
    At some point we execute the following statement:
    SELECT 
    obj.object_id AS id, 
    scm.name AS scm, 
    obj.name AS name, 
    obj.type AS type, 
    ds.name AS dataspace_name, 
    prop.value AS description, 
    part.data_compression_desc as compression_desc
    FROM sys.objects AS obj
    INNER JOIN sys.schemas AS scm ON obj.schema_id = scm.schema_id
    INNER JOIN sys.indexes AS idx ON obj.object_id = idx.object_id AND idx.type IN (0,1)
    INNER JOIN sys.data_spaces AS ds ON idx.data_space_id = ds.data_space_id
    INNER JOIN (SELECT object_id, data_compression_desc FROM sys.partitions WHERE index_id IN (0,1) /*Heap, Clustered*/) AS part ON part.object_id = obj.object_id
    LEFT OUTER JOIN sys.extended_properties AS prop ON obj.object_id = prop.major_id AND prop.minor_id = 0 AND prop.class = 1 AND prop.name = 'Description'
    WHERE obj.type = 'U' OR obj.type = 'S'";
    The statement returns some metadata for indexes (indices?), the purpose of wich is not the subject.
    When executed while an online index rebuild is running, a race condition occurs: When the rebuilding enters the final phase, the new index, which have the same name, becomes visible and thus results in two rows with the same name (from sys.object). I am unaware
    if this only occurs for clustered index (which is what we have observed).
    We became aware of this behaviour, as we added the metadata to a .Net Dictionary using name as key, and received a duplicate key exception. We have, hoewever, not been able to reproduce the situation, due to the nature of the race condition, and we found very
    little documentation on the subject.
    What we would like to do now, is to differentiate between the two. We see two options:
    1) We could just use the first of the rows and ignore the second. This solution would require that the metadata for both rows are identical.
    2) We could discern the "real" index from the "rebuilding" index. This requires some kind of extension of the Where-part.
    We have not been able to determine if the requirements for either option is present, as we havent found any documentation, nor have we been able to test for differences, as we cannot reproduce the situation.
    We would also like some way of reproducing the situation, so ideas as to how to do that is welcome.
    Can anyone direct me to relevant documentation, or alternate solutions.
    HRP

    1. Use the index with the lower fragmentation to identify the newly rebuilt index (as it almost always will have lower fragmentation)
    2. To reproduce, block the online index rebuild process by trying to alter the table's definition in a transaction (and don't commit, which will place schema lock on the table)
    Satish Kartan http://www.sqlfood.com/

  • When to rebuild indexes

    How can iddentify indexes that need to be rebuild?
    Thanks

    This is a question that comes up frequently and generally devolves into a flame war. I'm sure you can do a search and have threads to read for the next couple years.
    The best presentation on the topic is Richard Foote's [Oracle Index Internals|http://richardfoote.files.wordpress.com/2007/12/index-internals-rebuilding-the-truth.pdf].
    The summary though, is that most indexes never have to be rebuilt.
    Occasionally, you may need to do a 1-time rebuild on an index if
    - the index is on a monotonically increasing (or decreasing) column (i.e. a sequence or a date), AND
    - you delete a substantial fraction but not all of the data below a particular value (i.e. you delete 90% of the rows inserted more than a year ago)
    Extremely rarely, it may be beneficial to rebuild indexes on a schedule. Programmatically identifying the particular indexes that need to be rebuilt is probably not possible (there are various formulas floating around that are, to be kind, not particularly valid) if only because it requires information about the data that will be inserted in the future. If you have a window where no one is using the system (i.e. it is absolutely, totally inactive) and you have a well-tested rebuild script and you don't believe there is a risk that your rebuild script will fail to rebuild an index and cause problems, it generally doesn't hurt to rebuild an index (other than wasting a lot of CPU and IO to do so). If you reclaim space by rebuilding the index, though, it's not uncommon that you would cause some (generally small) performance decrease as your OLTP operations have to re-expand an index to its steady state size.
    So generally, if you're asking the question, I'd argue that the answer is "functionally never". But read Richard's presentation for more information.
    Justin

  • SCCM database Modified date doesn't change / rebuild indexes

    Hi all,
    I have 2 questions
    1)
    We have a month ago upgraded our SCCM environment from SCCM 2012 RTM -> SCCM 2012 SP1 (no CU), and we have upgraded SQL 2008 R2 (CU6) to SQL 2008 R2 SP2.
    We have a SCCM 2012 primary site and an SCCM 2012 CAS site from both these sites its database file has not changed its modified date since the data of upgrade (SQL is installed on the same server so the database is local). However the WSUS database and the
    reporting DB that exist on the same server updates its modified date.
     SCCM is running and all status messages are OK. All component status's are updating and have correct dates based on when e.g. the last backup ran (that is at 6 pm every night) with no errors. To make a long story short, everything works
    as it should. Deployments and advertisements and OSD arrive, collections get updated, no errors appear in the log files or in the component or site status, but the database on these servers (CAS and Primary) does not modify its date. SCCM backup of these servers
    is running and the database file in that backup also contains the same modified date.
    Anyone knows why this happens , or do we have an issue ?
     2)
    Maintenance task rebuild indexes
    Is there a best practice according to the maintenance task rebuild indexes?
    In our environment we have not enabled this maintenance task, both sites run for over one year.
    Can we enable this task without disturbing or is it a better idea to enable this task in the weekend when there is less workload , and afterwards schedule this task once a week
    regards and thx in advance
    Johan

    As stated “The time stamp will also change if the database files size are expanded as well when the database grow”
    does that mean that after our upgrade a month ago the database has not grown with new data??
    It depends. Data might have been added to the database (which it was fur sure with ConfigMgr), but the timestamp will only change if the file size was increased too. That has something to do with the initial and max file size settings in SQL and the autogrowth
    settings.
    Torsten Meringer | http://www.mssccmfaq.de

  • REBUILD INDEXES IN OFFLINE MODE

    hi all
    we got SQL 2012 enterprise edition on our production server, As our frag levels are more we are planning to do defragmentation but when we scheduled rebuild indexs last time this ran for 7-8hrs and drive spaces decreased rapidly so we have killed
    the process in the middle. I heard that offline indexes will be the better solution as it will be done quickly and keeping in simple recovery prevents the log file increase. could some one tell me how to schedule maintenance plan  for rebuild  with
    offline mode in sql 2012 enterprise edtion or some other efficient way.
    proposed plan for rebuilding->take full backup for DB
    change recovery model to simple
    configure m plan with offline mode
    change to full after the plan finished
    run dbcc update usage
    take full backup after all done
    could you please help me in this by letting me know is this correct way to do and how to configure plan which rebuils in offline mode
    with regards,
    ram.

    ->setting recovery model from full to simple is to save the disk space, as log will not increase
    ->As of now we are not taking any T-log backup due to some internal issues so there will be no issue with log chain break
    Frankly, I get scared. OK, I don't know what your system is doing, and what your SLA is saying, but someone is paying a lot of money to use Enterprise Edition. But you are not taking log backups? I can only hope that your system does not have a disaster,
    because if you have and you are not able to restart the business, you need to be in a country with very high labour security to not lose your job.
    ->won't the DB files size increase wen we do this bulk logged
    Obviously, if you are not taking log backups, the log file file will keep growing, but it will grow less in bulk-logged recovery. On the other hand, the log backups - had you taken any - will be larger.
    Please correct me If iam wrong, could you please tell me the procedure for REBUILD IN OFFLINE MODE through maintenance plan.
    If you are talking about the maintenance plans you see in SSMS, I only have one advice: don't use them. Instead go to
    http://ola.hallengren.com
    for an enterprise solution.
    Erland Sommarskog, SQL Server MVP, [email protected]

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

  • DML operations performance on table indexed with CTXCAT

    Hi,
    I have a table with 2M records. The table is batch updated once a day, and the number of record movements (update/delete/insert) should be around 100K.
    The table is indexed with CTXCAT.
    If I create the index from scratch, it takes 5minutes.
    If I perform delete/insert/update operations involving 40K records, it takes a lot more (especially for delete and update operations, something like 30 minutes).
    In this particular case I can drop the index and recreate it from scratch every night. The problem is that the 2M records table is only the first step in adoption of Oracle Text. The next step will be a 40M records table, on which the initial index creation takes something like 2hours (so I can't rebuild it every night).
    Do you have any suggest?
    Thanks.
    -- table DDL
    CREATE TABLE TAHZVCON_TEXT
    CONSUMER_ID NUMBER(10) NOT NULL,
    COMPANY_NAME VARCHAR2(4000 CHAR),
    CITY VARCHAR2(30 BYTE),
    PROVINCE VARCHAR2(3 CHAR),
    POST_CODE VARCHAR2(10 BYTE)
    CREATE UNIQUE INDEX TAHZVCON_TEXT_PK ON TAHZVCON_TEXT (CONSUMER_ID);
    begin
    ctx_ddl.drop_preference('mylex');
    ctx_ddl.create_preference('mylex', 'BASIC_LEXER');
    ctx_ddl.set_attribute('mylex', 'printjoins', '.#');
    ctx_ddl.set_attribute('mylex', 'base_letter', 'YES');
    ctx_ddl.set_attribute('mylex', 'index_themes','NO');
    ctx_ddl.set_attribute('mylex', 'index_text','YES');
    ctx_ddl.set_attribute('mylex', 'prove_themes','NO');
    ctx_ddl.drop_preference('mywordlist');
    ctx_ddl.create_preference('mywordlist', 'BASIC_WORDLIST');
    ctx_ddl.set_attribute('mywordlist','stemmer','NULL');
    ctx_ddl.set_attribute('mywordlist','SUBSTRING_INDEX', 'NO');
    ctx_ddl.set_attribute('mywordlist','PREFIX_INDEX','NO');
    ctx_ddl.drop_index_set('tahzvcon_iset');
    ctx_ddl.create_index_set('tahzvcon_iset');
    ctx_ddl.add_index('tahzvcon_iset','city');
    ctx_ddl.add_index('tahzvcon_iset','province');
    ctx_ddl.add_index('tahzvcon_iset','post_code');
    end;
    CREATE INDEX TAHZVCON_TEXT_TI01 ON TAHZVCON_TEXT(COMPANY_NAME)
    INDEXTYPE IS CTXSYS.CTXCAT
    PARAMETERS ('lexer mylex wordlist mywordlist index set tahzvcon_iset')
    PARALLEL 8;
    Andrea

    Hi kevinUCB,
    I've decided to use CTXCAT indexes because I had to perform queries involving different columns (company name, city, region, etc.). So I thought CTXCAT was the right index for me.
    Now I've discovered that if I index an XML with CONTEXT, I can perform a search on single XML fields, so CONTEXT is suitable for my needs.
    Preliminary test on the 2M record table looks very good.
    Bye,
    Andrea

  • Recommeded way to rebuild Indexes in EBS 11.5.10.2

    What is the recommended way to rebuild all the possible indexes for better performance in EBS 11.5.10.2?
    Is there any seeded script / concurrent program, that which could be made use of?

    I have been using bde_rebuild.sql (available from Metalink) with pretty good success. It seems to work better doing it schema by schema rather than supplying % for schema name (gets hung up and never completes).
    bde_rebuild.sql - Validates and rebuilds indexes occupying more space than needed
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=182699.1
    How to Rebuild All Indexes in a Database
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=300327.1

  • Issue in rebuilding index after restoring database from sql server 2005 to 2012

    Hi All,
    We have recently restored a database named DBA_admin from our sql server 2005 instance to sql server 2012 and we have added the database to out weekly maintenance plan. After adding the database to maintenance plan the job is failing every weekend due to
    below error message.
    Error message from maintenance plan history:
    Executing the query "ALTER INDEX [PK_lsttype] ON [dbo].[lstAssign..." failed with the following error: "Invalid object name 'admin.dbo.databaselog'.
      ALTER_INDEX - dbo.PK_lsttype". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Below is the code within the maintenance plan which the rebuild index task is using for database dba_admin:
    USE [dba_admin]
    GO
    ALTER INDEX [PK_lstType] ON [dbo].[lstType] REBUILD PARTITION = ALL WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 98, DATA_COMPRESSION = PAGE)
    Please let me know if any one knows how to fix this issue.
    Thanks in Advance.

    Sorry for the confusion.
    Here is what is happening.
    The query is failing while trying to rebuild index [Pk_lsttype] on table [lstAssign], both these objects belong to database
    admin.
    I have verified the old instance there is table databaselog within the database
    dba_admin, but in new SQL instance within the database dba_admin the table is not present.
    Even I'm not sure of what this table databaselog has to do with rebuilding indexes on table
    lstAssign within the admin database.
    I have manually tried to execute the alter index command within the database
    admin and it is failing with the below error.
    ALTER_TABLE - dbo.Query_pnb_sms
    Msg 208, Level 16, State 1, Procedure ddlDatabaseTriggerLog, Line 39
    Invalid object name 'dba_admin.dbo.databaselog'.

  • How to analyse Indexes with PL/SQL witch a $ in it's name

    Hello there, I'm working on several sniplets of PL/SQL Code. In the end result there should be a PL/SQL Routine which decides which indexes to analyse online.
    I just get stopped by some indexes which have the $ in It's name. Our Apllication provider uses uncommon names like ttols.pk_$lock for some of his indexes.
    So when this procedure try to analyse the ttols.pk_$lock it gives me errors.
    Can someone lend me a hand how I can analyse Indexes with PL/SQL with a $ in it'S name.
    CREATE OR REPLACE PROCEDURE TTOOLS_DBA.rebuild_nonpart_idx
    AS
    BEGIN
    FOR idxq IN (SELECT owner AS obj1, index_name AS obj2
    FROM dba_indexes
    WHERE partitioned = 'NO'
    AND owner = 'TTOOLS'
    AND index_name NOT LIKE '%$%')
    LOOP
    DBMS_OUTPUT.put_line ( 'ALTER INDEX '
    || idxq.obj1
    || '.'
    || idxq.obj2
    || ' REBUILD ONLINE COMPUTE STATISTICS;'
    EXECUTE IMMEDIATE 'ALTER INDEX '
    || idxq.obj1
    || '.'
    || idxq.obj2
    || ' REBUILD ONLINE COMPUTE STATISTICS';
    END LOOP;
    END;
    Greetings from sdohn

    how I can analyse Indexes with PL/SQL with a $ in it'S name.You can try
    create or replace procedure ttools_dba.rebuild_nonpart_idx
    as
    begin
         for idxq
              in (select owner as obj1, index_name as obj2
                        from dba_indexes
                     where partitioned = 'NO'
                         and owner = 'TTOOLS'
                         and index_name not like '%$%')
         loop
              dbms_output.put_line (
                   'ALTER INDEX ' || idxq.obj1 || '."' || idxq.obj2 || '" REBUILD ONLINE COMPUTE STATISTICS;'
              execute immediate   'ALTER INDEX '
                                         || idxq.obj1
                                         || '."'
                                         || idxq.obj2
                                         || '" REBUILD ONLINE COMPUTE STATISTICS';
         end loop;
    end;
    /but actually I don't think that the $ sign should cause an error.
    Can you show us the actual error message?
    Also please always mention your db version.
    Edited by: michaels2 on Aug 10, 2009 9:45 AM

  • Rebuild indexes?

    I am working with a large scale database with approximately 100 tables where some tables grow with 100-500 million rows per year. The performance in of the system is fairly good but I was wondering if anyone has any input regarding how often indexes should be rebuilt?
    Kind regards,
    Sumpen

    martinmorono wrote:
    Inside my company, We are using this self-made rules to consider an index as candidate to be rebuild:
    Index is considered as candidate for rebuild when :
    - when deleted entries represent 20% or more of the current entries
    - when the index depth is more then 4 levels.(height starts counting from 1 so > 5)
    - Index is (possible) candidate for a bitmap index when :
    - distinctiveness is more than 99%
    That'll come from the old metalink guidance. It doesn't exist now. Oracle reviewed it and pulled it. You might want to think about a 1 billion row table (2 years of the OP's highest growth rate). Would an index on a randomly distributed varchar column on that table of a height of 5 be especially inefficient?
    I don't understand 'distinctiveness'
    Niall Litchfield
    http://www.orawin.info/

  • Run Rebuild Index Task daily on database but about 77 tables still highly fragmented over 80% !!!

    Hello everyone
    On our particular database server, we run the Rebuild Index Task (Using classic Maintenance Plan Designer) every night. Running the  script below, I saw that about 77 tables had an avg_fragmentation_in_percentage between 80% and 99% !!
    SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
    ind.name AS IndexName, indexstats.index_type_desc AS IndexType,
    indexstats.avg_fragmentation_in_percent
    FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
    INNER JOIN sys.indexes ind
    ON ind.object_id = indexstats.object_id
    AND ind.index_id = indexstats.index_id
    WHERE indexstats.avg_fragmentation_in_percent > 30--You can specify the percent as you want
    ORDER BY indexstats.avg_fragmentation_in_percent DESC
    I dont understand why these tables are highly fragmented after a daily index rebuild! Unless the users are doing heavy inserts/updates/deletes during the day.
    Anyone has an idea of the possible causes of these results??
    Thank you all in advance

    Hallo Efyuzegeekgurl,
    this is a normal behaviour when your table is only a small one. The reason for that behaviour is the following:
    The dmv sys.dm_db_index_physical_stats counts each page which is not located at the very next one of the same table as a "fragment". If the first data page is 1700 and the second one is located on 1705 SQL server will count it as a fragment.
    The basic allocation algorithm of Microsoft SQL Server is that new data pages will be created in "mixed extents". An extent is a contigious line of 8 consecutive data pages. This is for historical reasons when storage was expensive and data should
    use as much as possible of allocated storage.
    If a new table will be created the very first 8 pages are not located one after the other but "could" be located on different extents. If your table has only 9 data pages than 8 pages will count as "fragmented" because of their non consecutive
    allocation. After 8 pages have been allocated Microsoft SQL Server will ALWAYS use a full extent for the next 8 pages (and so on!).
    To understand this behaviour use the following example which creates a table with a record length of 8K. The next command will create 10 records (which means 10 data pages).
    CREATE TABLE dbo.foo
    Id INT NOT NULL IDENTITY (1, 1),
    c1 CHAR(8000) NOT NULL DEFAULT ('filler')
    GO
    SET NOCOUNT ON;
    GO
    INSERT INTO dbo.foo DEFAULT VALUES
    GO 10
    When you check the page allocation you'll find the first 8 data pages not in a consecutive row but "scrambled" into different pages:
    SELECT database_id,
    index_id,
    partition_id,
    allocation_unit_type_desc,
    extent_page_id,
    allocated_page_page_id,
    is_mixed_page_allocation,
    page_type_desc
    FROM sys.dm_db_database_page_allocations
    DB_ID(),
    OBJECT_ID('dbo.foo', 'U'),
    0,
    NULL,
    'DETAILED'
    ) AS DDDPA
    WHERE
    DDDPA.is_allocated = 1
    ORDER BY
    DDDPA.is_iam_page DESC,
    DDDPA.page_level DESC;
    GO
    You will see that the first 8 pages are located in a MIXED extent. Although the pages are in a consecutive order in the extent 221112 it is not guaranteed!
    You can see from the very first three records that they are not in a consecutive row stored.
    Now the fragmentation of the data seems to be quite high because we have 4 breaks in the rows. If we compare this value to the "fragmentation in sys.dm_db_index_physical_stats we will see at least the same result:
    SELECT index_type_desc,
    alloc_unit_type_desc,
    DDIPS.avg_fragmentation_in_percent,
    DDIPS.fragment_count,
    DDIPS.page_count,
    avg_page_space_used_in_percent
    FROM sys.dm_db_index_physical_stats
    DB_ID(),
    OBJECT_ID('dbo.foo', 'U'),
    NULL,
    NULL,
    'DETAILED'
    ) AS DDIPS;
    So - just from my point of view - don't count only to the fragmentation in percent because if the table is to small it will ALWAYS be over 30%. Take more into account the density of the pages and - as all others have mentioned - the number of pages of the
    index.
    I would consider indexes with more or equal to 1.000 pages.
    Another tip: Forget about the f... maintenance plans. These "plans" are not worth the time and money because you cannot control it in a more precise way. Have a look to the solution of Ola Hallengren and implement his solution - a great master
    piece of index maintenance:
    http://ola.hallengren.com
    All the best to the community :)
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

Maybe you are looking for

  • My imac hangs up after upgrading to new os

    After upgrading to new OS my imac hangs up where it never has done this before. My apple care has long sinse expired and I am really bummed. It was clearly related to the new OS. Any suggestions for relief?

  • Apple tv2 no signatures, can't update

    Repeatedly failed to update reporting this device is not eligible for requested build. Downloaded "tinyumbrella" and it reported no signatures to save Anything I can do?

  • Not all my purchase history showing up for redownload

    OK, so I'm enjoying iOS 5 on my iPhone 4 and finally have access to download previous purchases directly from the iTunes app. The thing is, not all my songs or albums are showing up as available to redownload. I took a look at my history through iTun

  • How to sync Contacts and Calendars between 2 computers and ipod?

    I'm having difficulty syncing contacts on 2 computers and an iPod. Although I'm able to sync contacts from an iBook (G4/OS10.4) to an iPod Classic, when I attempt to sync the iPod to an empty address book on an Mac Pro (Intel/OS10.4) the synch goes t

  • Windows CD does not run

    I have Windows XP Service Pack 2, the full retail version (not a pirate copy) and after partitioning my drive I continued to install Windows. Firstly, my Mac kept spitting out the disk, so I checked it - I found no scratches or other problems on the