How to find fragmentation in INDEX segments

Dear All,
Please tell me the solution for how to find fragmentation in index segments.
Waiting for your reply.
Regards,
.......................

To minimize tablespace fragmentation is to use Locally Managed Uniform Sized Tablespaces. With Oracle 10g, even your system tablespace can now be LMT.
The best way to remove fragmentation of a table or index is to re-create or rebuild it. The same can be accomplosihed this is to use the ALTER TABLE MOVE and ALTER INDEX REBUILD statements.
Alter Table Tab1 move tablespace NEW_LMT_TS;
Alter Index Ind1 rebuild tablespace NEW_LMT_TS;
Even with LMT, indexes can sometimes become fragmented over time due to inserts and deletes of rows in the index leaf pages.
Run an analyze index validate structure on your indexes.
Query the index_stats table. If the percentage of deleted leaf rows to total leaf rows (DEL_LF_ROWS/LF_ROWS) is greater than 20%; then, the index probably should be rebuilt. but sometimes these may be a wrong.
How to remove index fragmentation?
There are two way to remove fragmentation.
1. index coalesce
2. index rebuild

Similar Messages

  • How to find out unused Indexes (regardless of restarts of server or database)?

    Hello colleagues,
    do you know how to get list of unused indexes regardless of restarts of MS-SQL-Server or Database?
    Because (if I understand correctly to information in
    BOL ) all content of dynamic management view sys.dm_db_index_usage_stats is deleted during restart of MS-SQL-Server or Detach Database.
    Due to when I use my next script (to generate report with list of unused indexes) immediately (or after short time) after restart of MS-SQL-Server it contains misleading/confusing information.
    USE [AdventureWorks]
    GO
    DECLARE @CurrDate as varchar(10), @CurrTime as varchar(5), @DatePartsSeparator as char(1), @EmptyDate as smalldatetime;
    SET @DatePartsSeparator = '/';
    SET @CurrDate = RIGHT ('0' + CONVERT(varchar,DATEPART (day,GETDATE())), 2);
    SET @CurrDate = @CurrDate + @DatePartsSeparator;
    SET @CurrDate = @CurrDate + RIGHT ('0' + CONVERT(varchar,DATEPART (month,GETDATE())), 2);
    SET @CurrDate = @CurrDate + @DatePartsSeparator;
    SET @CurrDate = @CurrDate + CONVERT(varchar,DATEPART (year,GETDATE()));
    SET @CurrTime = RIGHT ('0' + CONVERT(varchar,DATEPART (hour,GETDATE())), 2);
    SET @CurrTime = @CurrTime + ':';
    SET @CurrTime = @CurrTime + RIGHT ('0' + CONVERT(varchar,DATEPART (minute,GETDATE())), 2);
    SET @EmptyDate = CONVERT(smalldatetime, '01' + @DatePartsSeparator + '01' + @DatePartsSeparator + '2000');
    SELECT SERVERPROPERTY('servername') AS [Server]
    , DB_NAME(s.database_id) AS [Database]
    , o.type_desc [ObjectType]
    , o.name AS [Object]
    , i.name AS [Index]
    , (user_seeks + user_scans + user_lookups) AS Reads
    , user_updates AS Writes
    , ((SELECT SUM(p.rows) FROM sys.partitions p WHERE p.index_id = s.index_id AND s.object_id = p.object_id) / 100) AS [Rows(1000)]
    , CASE
    WHEN s.user_updates < 1 THEN 100
    ELSE CAST(1.00 * (s.user_seeks + s.user_scans + s.user_lookups) / s.user_updates AS decimal (12,5))
    END AS Reads_per_Write
    , (SELECT TOP 1 luu.[Last_User_Usage] FROM (
    SELECT COALESCE(s.last_user_lookup, @EmptyDate) AS [Last_User_Usage]
    UNION
    SELECT COALESCE(s.last_user_scan, @EmptyDate) AS [Last_User_Usage]
    UNION
    SELECT COALESCE(s.last_user_seek, @EmptyDate) AS [Last_User_Usage]
    ) AS luu ORDER BY luu.[Last_User_Usage] DESC) AS [Last_User_Usage]
    , COALESCE(s.last_user_update, @EmptyDate) AS [Last_User_Update]
    , CASE WHEN i.is_disabled = 0 THEN 'N' ELSE 'Y' END AS [Disabled]
    , i.index_id
    , o.create_date AS [Index_Created]
    , o.modify_date AS [Index_Modified]
    , u.name AS [Index_Owner]
    , @CurrDate AS [This_Report_Created]
    , @CurrTime AS [This_Report_Created_Time]
    , CONVERT(CHAR(40), SUSER_SNAME()) AS [This_Report_Created_by_User]
    , 'DROP INDEX ' + QUOTENAME(i.name) + ' ON ' + QUOTENAME(DB_NAME(s.database_id)) + '.' + QUOTENAME(c.name) + '.' + QUOTENAME(OBJECT_NAME(s.object_id)) as 'drop statement'
    FROM sys.dm_db_index_usage_stats s
    INNER JOIN sys.indexes i ON i.index_id = s.index_id AND s.object_id = i.object_id
    INNER JOIN sys.objects o ON s.object_id = o.object_id
    INNER JOIN sys.schemas c ON o.schema_id = c.schema_id
    LEFT OUTER JOIN sys.database_principals u ON OBJECTPROPERTY ( o.object_id , 'OwnerId' ) = u.principal_id
    WHERE OBJECTPROPERTY(s.object_id,'IsUserTable') = 1
    AND s.database_id = DB_ID()
    AND i.type_desc = 'nonclustered'
    AND i.is_primary_key = 0
    AND i.is_unique_constraint = 0
    AND o.type IN ('U','V')
    AND o.is_ms_shipped = 0
    AND (SELECT SUM(p.rows) FROM sys.partitions p WHERE p.index_id = s.index_id AND s.object_id = p.object_id) > 10000
    ORDER BY Reads;
    GO
    __________________________________________________________ If isn't above described anything, the following applies: Technical details: * OS: Windows Server v2008-R2, English, Enterprise Edition, x64, SP1 ** My User-Account is member of 'Administrators'
    local security group. * MS-SQL-Server: v2008-R2, English, Enterprise Edition, x64, SP1 ** My User-Account is member of 'SysAdmin' db-role.

    Hi,
    You are right. The sys.dm_db_index_usage_stats DMV tells how often and to what extent indexes are used.
    Please check the unused section in the below article to find the unused indexes:
    Uncover Hidden Data to Optimize Application Performance
    http://msdn.microsoft.com/en-us/magazine/cc135978.aspx#S5
    In addition, you can also use Database Engine Tuning Advisor to verify if you have too many indexes. DTA can easily find the bad indexes and provide the recommendation for action.
    Reference:
    http://blogs.technet.com/b/sql_server_isv/archive/2011/04/08/fundamentals-running-database-engine-tuning-advisor-and-selecting-indexes.aspx
    Hope it helps.
    Tracy Cai
    TechNet Community Support

  • How to find our custom indexes in oracle apps

    Hi Experts,
    Can you please suggest how to find out unused custom index ( non-seeded).
    Our DB Version is : 11.2.0.2
    EBS Version: 12.1.3
    Thanks

    Hi,
    You can query select * from dba_objects where object_name like 'ABC%' and object_type='INDEX' and OWNER='APPS';
    and select * from dba_objects where object_name like 'ABC%' and object_type='TABLE' and OWNER='APPS'; for tables.
    Cheers,
    Sachin Thapa

  • How to find which shared memory segment corresponds to which instance.

    If you have two or more instances running on a unix machine, is there a way to find out which shred memory segment and what semaphores are allocated. You could do a "ipcs -a" which will give you all the shared memory segments and semaphores, but how to find what corresponds to what instance.
    Thanks
    Devinder
    PS: I dont know whether this is correct discussion forum or not, cause I could not find anything related to it.
    null

    if you type ipcs -a you could see:
    ipcs -aIPC status from <running system> as of Tue Jan 30 12:02:20 EST 2001
    Message Queue facility inactive.
    T ID KEY MODE OWNER GROUP CREATOR CGROUP NATTCH SEGSZ CPID LPID ATIME DTIME CTIME
    Shared Memory:
    m 0 0x500008c7 rw-rr-- root root root root 1 68 373 373 11:48:11 11:48:11 11:48:11
    m 1 0xb9359140 rw-r--- oracle dba oracle dba 28 109568000 593 8631 11:29:43 12:01:36 11:49:06
    m 2 0x21d38b58 rw-r--- oracle dba oracle dba 53 83746816 654 8630 12:01:15 12:01:15 11:49:58
    T ID KEY MODE OWNER GROUP CREATOR CGROUP NSEMS OTIME CTIME
    Semaphores:
    s 196608 0xbfb87050 ra-r--- oracle dba oracle dba 54 12:01:37 11:49:06
    s 196609 0xcc222a00 ra-r--- oracle dba oracle dba 104 11:53:31 11:49:59
    note that the CTIME shows you when the entry was created... they usually map to within a second between the memory segment and the semaphore (M and S). 11:49:06 and 11:49:59 in my case.
    If I look in my alert_log for each instance I will see:
    --Sun Jan 28 11:49:04 2001
    --Starting ORACLE instance (normal)
    and in the other file
    --Sun Jan 28 11:49:58 2001
    --Starting ORACLE instance (normal)
    This lets me know which instance uses which semaphores/memory segments.
    Just be sure the start your instances at least 30 seconds apart so the times are different enough.
    enjoy.
    null

  • How to find out the index in string.

    Hello Experts,
    I have a requirement in which i have to find out the index of the last space before the 50th position in a string.
    is there any way other than spliting the string.
    e.g. if string is - 'aaaa aaaa aaa........ aaa aaa'(length is more than 50)
    i want the last space before 50th char.because i want to split the string before last word withing 50 th character
    please help.
    Thanks,
    Shweta

    Hi Shweta,
    You can build up the logic from this below program.
    data: line(75) value 'abcdefghijk lmnopqrstuvwxyz zyxwvutsrqponml kjihgfedc ba',
           n_line(50),
           off type i,
           val1(50),
           val2(50).
    CALL FUNCTION 'STRING_REVERSE'
      EXPORTING
        STRING          = line(50)
        LANG            = ' '
    IMPORTING
       RSTRING         = n_line
    EXCEPTIONS
       TOO_SMALL       = 1
       OTHERS          = 2.
    IF SY-SUBRC NE 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    SPLIT n_line at space into val1 val2.
    off = strlen( val1 ).
    off = 50 - off.
    write: 'The index of the last space before the 50th position is at ', off.
    Hope this may help you.
    Regards,
    Smart Varghese

  • How to find failed spatial  index

    hi friends
    i want to query to find failed spatial index in the schema
    so please give me the query
    i think it is "staus" column
    so please paste the query and help me out
    thanks

    Please try this:
    select * from user_sdo_index_info a, user_indexes b
    where a.INDEX_NAME = b.INDEX_NAME and b.domidx_opstatus = 'FAILED';

  • How to find Fragmentation of tables and tablespaces in oracle 8i

    Hi,
    How can i measure the fragmentation of Tables and Tablespaces in oracle 8i.
    Do any one have any handy script to find the same.
    What are the attributes to be determined to do health checkup of a database.

    how many such empty blocks are there in the table and of what size.Again Tom Kyte reference :
    http://asktom.oracle.com/pls/ask/f?p=4950:8:7760471022221195640::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:231414051079
    For tablespace, fragmentation is the regular termAbout tablespace, the link from post above can help.
    Nicolas.

  • BDC - How to find line item index in table control?

    Hi guys,
    I am doing a BDC for VL02N, I am stuck up in positioning the line item index. For example, I have 10 line items, I want to fill quantity for the item 000060 which is in the third line. I am able position the cursor using button for locating item ( ok_code = 'POPO' ), but I could not find the index of the item in the table control, so that I can enter the quantity value as
    PERFORM bdc_field  USING 'LIPSD-G_LFIMG(03)' '100'.
    Any expert to help me on this?

    Depending on the message the line number might be in one of the fields:
    MESSAGE_V1
    MESSAGE_V2
    MESSAGE_V3
    MESSAGE_V4
    Although if the message simply is not meant to include the line number, it won't be there. That's the way it is. If there is a user exit available, you may add your custom messages with the line number. In some user exits (in sales order for sure) there is a special variable (flag), which is set when the BAPI runs the transaction.

  • How to find the event time segment details from delivery document

    Hi,
    In the delivery document at header level in Dates tab i have maintained begining Plan date where Event = Shipment.
    But that field is in structure.
    How to fetch those(Begining Plant Date) details in to report,
    I have tried from Function module side also, i have not found any function module which is related to this field.
    If any body give some solution, that will be great help for me.
    Regards
    Lakshmikanth

    I have tried with those table(TSEGH & TSEGE), i have not found the begin plan date for that event. where event = shipment.
    We are using 4.7 version. Here we have found one function module: TSEG_DIALOG_DATA, but iam unable to find the input details.
    Here the input options are:
    IF_HANDLE
    IF_DIALOG_VIEW
    IF_DIALOG_ZONE
    May i know what are these inputs, what exactly i have to pass to this function module.

  • How to find unused indexes in oracle 10g r2

    Hi all,
    db:oracle 10.2.0.3
    os:solaris
    i want rebuilt the some of the indexes (due poor performence of db)
    how to find the unused indexes in oracle 10gr2 database.?
    can any one help me out plz.

    kk001 wrote:
    Hi all,
    db:oracle 10.2.0.3
    os:solaris
    i want rebuilt the some of the indexes (due poor performence of db)
    how to find the unused indexes in oracle 10gr2 database.?
    can any one help me out plz.You can use V$OBJECT_USAGE.
    But how you decide need rebuilding indexes?
    How you decide problem related indexes?
    What is exactly your mean "due poor performence of db"? some queries hang/long running or whole system hang or has poor performance?
    In generally do not need rebuilding index(unless specially cases),first give we above questions`s answers.

  • How to find out the current index

    Hello Experts,
               How to find the current index and whatever we entered in that table how to ratrieved that entry value.pls give the suggest..

    Hi,
    To get current index write below piece of code in the outbound plug for your F4 help pop up.
    We have to write this in the outbound plug itself otherwise it will not work.
    let me know whethere it worked or not
    cl_chtmlb_config_utility=>outbound_plug_event_info( EXPORTING iv_event_string = lv_event_string
                                                          IMPORTING ev_index        = gv_index ).
    Regards,
    Swapna

  • How to find IDOC Segment Exit

    Dear All,
    I am new to IDOCs. Can someone tell me how to find exit for a segment in IDOC.
    Regards,
    Anurag

    Hi,
       There is no segment exit. If you want populate data and for that there is no corresponding fields in the standard segment, then create the new ZSEGMENT in WE31 with your fields and data element.
    Now if u want to send data in those fields through idoc then
    1) Go to we30 - Select the radio button extension and then add segments which you created to populate the values.
    2) Link the idoc type with message type and add extension ( that u created in WE30)
    3) In we20 add the message type used in outbound
    4) Identify the suitable user exit and write the code in outbound system (sending system) to populate data in idoc
    5) identify the suitable user exit and write code in inbound system to post data from idoc to the database table.
    Now replicate data and check whether your are able to insert data in custom fields.

  • How to remove fragmentation in a table?

    How to find fragmentation in a table?
    How to remove fragmentation in a table?

    Hi,
    sa_index_density --gives the density of stored procedure.
    sa_table_fragmentation-- degree of fragmentation in stored procedure table.
    REORGANIZE THE TABLE -- DOES NOT DISTURB THE DATABASE ACCESS
    REBUILD DATABASE -- DEFRAGMENTS ALL TABLES, INCLUDING SYSTEM TABLESPACE.
    Regards,
    Nirmal([email protected])

  • How to find EXIT where a Extension is getting filled?

    Hi All,
    I have a IDoc extension and its segments are getting filled from an EXITs, Since this IDoc is  getting triggered by output type so only use EXITs to fill the custom segments.
    Please guide me how to find the EXIT where segment of this extension is getting filled.
    I have following information:
    Message Type
    Basic Type
    Extension
    Application class
    Message code
    Regards,
    Nooruddin Bohra

    Nooruddin,
    If you have a TS, that is the easiest way
    In case not, there are 2 other ways that I would follow.
    1. Set the o/p type to process immediately in further options.
    Activate debugging and the hit SAVE. Also activate update debugging.
    Set a break point using AT STATEMENT and enter "CALL CUSTOMER-FUNCTION".
    The debugger should stop in all the customer exits and you can then figure out by looking at the source code.
    2. Find the main FM. For example if your idoc is inbound and used for creation of delivery, then the main FM would be "IDOC*INPUT*DELVRY*.
    open the FM and search for call customer-function and check the exits that are implemented and its respective source code.
    3. If the exit is a BADI, put a break point while debugging at CALL/GET badi or CL_EXIT_HANDLER->GET INSTANCE method.
    Let us know if this helps.
    Thanks,
    Vikram.M

  • Find Link between Field, Segment, Idoc

    Hi Experts
    I would like to know how to find link between IDoc, Segment and Fileds.
    For Example : I know field Name Then i wild like to know Which Idoc and segment contain this field name.
    Thanks in advance,
    Jaykumar.M.

    Hi Jayakumar,
    I think this is the same old question on how to find out in what tables a field may be used.
    Segments are DDIC structures. A where-used-list on the data element of the field (eventually with some restrictions on the resulting objects name) should show the segments where is is used. The you can check table EDISEG recursively.
    Regards,
    Clemens

Maybe you are looking for