When is a secondary index used (in select or where)

HI All,
We are confused (and new to ABAP) on the various postings on SDN concerning this topic.  Replies seem to vary.
We have the following select statement:
SELECT date1 FROM table2
WHERE material (from a stored internal table) = material-table2
AND order (from a stored internal table) = order-table2
AND delivery method (from a stored internal table) = specific value of table2.
For a second index to be created, would we create the index for only date1 (since it's the only field we are selecting from table 2) or an index with date1, material, order, delivery method or just what's in the WHERE clause of material, order and delivery method?
How can you be sure that an index will be used?
Thank you!

> We are confused (and new to ABAP)
seem you are very very new.
Your question is actually not ABAP indexes etc are SQL and can be found in many textbooks also on Wiki pages. ABAP uses SQL, but does not change much.
The use index is determined nearly only by the WHERE clause. You want to know the phone number of somebody and you know the name and the address. The Index uses the name and the address as a telephone book. The phone number comes from the table not the index! This is not the secondary index, but the primary index.
If you search in the internet for phone number, then you can use also a secondary index, i.e. you know only the complete address but not the name. A phone book would not help here.
Which index is used, if often very simple as in the example, but can become very difficult. That is done by a sophisticated program of the database, the optimizer. Check other resoucres for details.
Siegfried

Similar Messages

  • Use two secondary indexes in a select statement

    hi, i want to use two secondary indexes in a select statement.
    how can i do it?

    Hello,
    To do it use the WHERE stm in the same order as the secondary stm is on SE11....To check if the index is used go to tcode ST05.
    example
    select * from ztable
    WHERE BUKRS EQ 'BUK1' AND
                 ZFIELD EQ 'BOY'.
    on se11 on the ZTABLE indexes setion must have a secondary index with
    BUKRS and
    ZFIELD.
    BYE!!
    Hope this helps!!
    Gabriel

  • Primary index and secondary index in a select query

    Hii,
    How to use a primary or secondary  index in a select query?  How does this indexes actually work?
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Jan 21, 2012 8:38 PM

    rajan please just google or search SDN. there are large number of post for this..
    to give you a head start: for using a particular index in the select query a %_HINTS ORACLE 'INDEX clause is added

  • What is the "No database index" means when you Creating Secondary Indexes?

    HI,
       I'm Creating Secondary Indexes in the maintenance screen of the table(se11)
       There are three options under "Non-unique Index":
       1.Index on all database systems
       2.For selected database systems
       3.No database index
    My questions is :
      What do u mean by "No Database Index" and when is it used.
      Can anybody plz tell me what's the difference of this three options ?
      Here is what i found in the help:
       No database index: The index is not created in the database. If you
       choose this option for an index that already exists in the database,
       it is deleted when you activate this option.

    Hi,
    It is clear from the help documentation,
    Here see what the help document says:
    Create the index in the database (selection)
    Whether an index improves or worsens performance often depends on the database system. You can therefore set whether an index defined in the ABAP Dictionary should be created in the database.
    This makes it easier to install a platform-specific customer system.
    You can set this option as follows:
    1. Index in all database systems: The index is always created in the database.
    2. In selected database systems: The index is created depending on the database system used. In this option, you must specify the databases in which the indexes are to be created. You can do this either on an inclusive (list of systems on which it should be created) or an exclusinve (list of systems on which it should not be created) basis. In either case, you can list up to four different database systems.
    3. No database index:: The index is not created in the database. If you set this option for an index that already exists in the database, it is deleted when you activate the table in the ABAP Dictionary.
    Note: Unique indexes have an extra function, and must therefore always be created in the database. The database system prevents entries or index fields being duplicated. Since programs may rely on this database function, you cannot delete unique indexes from the database.
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • Error When Creating Oracle Text index using Lexer Keyword

    Hi All,
    I am getting following error when i creating oracle text index using lexer & stoplist keyword.
    Pls Help me if any body know.
    Thanks in Advance.
    Error starting at line 1 in command:
    CREATE INDEX TXT_INX_TEXT_SEARCH ON TEXT_SEARCH (BFILE_DOC)
    Post INDEXTYPE IS "CTXSYS"."CONTEXT" LOCAL (
    PARTITION "BEFORE_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)') ,
    PARTITION "Q1_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q2_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q3_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q4_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q1_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q2_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q3_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q4_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q1_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q2_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q3_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q4_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "THE_REST" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)')
    Error at Command Line:1 Column:13
    Error report:
    SQL Error: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-20000: Oracle Text error:
    DRG-11000: invalid keyword LEXER
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 365
    29855. 00000 - "error occurred in the execution of ODCIINDEXCREATE routine"
    *Cause:    Failed to successfully execute the ODCIIndexCreate routine.
    *Action:   Check to see if the routine has been coded correctly.
    Regards,
    Jack R.

    Hi,
    it works if you put an extra PARAMETERS clause at the end so the creation looks like:
    CREATE INDEX TXT_INX_TEXT_SEARCH ON TEXT_SEARCH (BFILE_DOC)
    INDEXTYPE IS "CTXSYS"."CONTEXT" LOCAL (
    PARTITION "BEFORE_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)') ,
    PARTITION "Q1_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q2_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q3_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q4_2007" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q1_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q2_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q3_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q4_2008" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q1_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q2_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q3_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "Q4_2009" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)'),
    PARTITION "THE_REST" PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)')
    PARAMETERS ('LEXER dd_lexer STOPLIST dd_stoplist SYNC (ON COMMIT)') <== Added
    Hope this helps
    Herald ten Dam

  • Index using in select statement

    Hi All ,
    i'm new using pl/sql and i have a doubt , i have the following query and want to use index...but use two different tables..how can i do that?
    SELECT /*+ index(TA TABLE1) */
    TA.USER , TA.DATE ,TB.DATA
    FROM TABLEA TA , TABLE B
    WHERE TA.USER=TB.USER
    in this case ..how i can use index to both tables...TABLE A and TABLE B?
    Thanks in advance.
    rgds,

    At best with your current query you can use an index on just one table while doing a full table scan on the other since you have no other limiting criteria. It doesn't make sense to use indexes on both tables.
    If one table is significantly smaller than the other, better to do the full table scan on the smaller table and use an index on the other one.
    Again, full table scans is not a bad thing. It depends on how large the table is.
    As Eric suggested, in most cases let the compiler determine when and which index to use. You should be using a hint only when absolutely necessary when you have some information about the data being searched for that the compiler could not know.

  • Firefox freezes when opened on secondary monitor using default profile. Other profile okay.

    Windows 7. Firefox 28.0. Hardware acceleration is off in both profiles.
    Default profile behaves normally in the primary monitor (I have two monitors). When I open the default in the secondary monitor, it appears to be at maximize size but only the top bar of the screen is visible. If I shrink it, it locks up, but I can slide it over to the primary monitor where it then works normally.
    If I open it in the primary monitor then move it to the secondary, it shows in a less than full screen. When I maximize it, a duplicate screen partially opens and both freeze, and menus freeze when I open them. I can slide it back to the primary where it works normally.
    My other profile is an old one with all the bookmarks, settings and history. It works fine on both monitors.

    You can check for problems caused by a corrupted localstore.rdf file.
    *http://kb.mozillazine.org/Corrupt_localstore.rdf

  • When I right-click a page and select 'copy' where does the copy go on my computer?

    I'm just trying to copy the page but I don't know where it goes. I'm assuming that's what the copy function is for?

    Copy means to copy something to the clipboard. If there's any selected text, for instance, that text will copied. Depending on where you click, you can copy images and links to the clipboard.
    To copy a page to your disc drive, you use the Save Page As... function on the right click menu.
    Note that you will not see the Save Page function on the right click menu if any text is selected (highlighted) on the page or if you right click on an image.

  • Help me with Points to be noted While creating a Secondary Index.

    Hi,
    There is a Secondary index created on a Z table which already have 9 secondary indexes. This is the 10th index that is created.
    The Index is created as follows
    MANDT             Client
    DOCNUM_REF     Document number
    The Table data is huge and it is more than 4Lakh records.
    I have done the following analyses.
    1) The fields to be used are not in any other indexes.
    2) The Data is mostly different, i.e. The document reference field is having distinct data
      select a~docnum a~werks_o a~docnum_ref a~natop
             a~m_icms a~m_ipi
             b~lgort_out b~mov_est
             b~item b~matnr
        appending table ti_requisicoes
        from zsytmm_reqnfcb as a
       inner join zsytmm_reqnfit as b
          on a~branch_o eq b~branch_o
         and a~requi    eq b~requi
         and a~mask     eq b~mask
         for all entries in ti_doc_saida_del
       where a~docnum_ref   eq ti_doc_saida_del-docnum.
    What else I need to check , so that the index improves the performance. The table is using in 300 reports.

    Ravishankar Lanjewar wrote:
    @SAP LEARNER,
    >
    > There is a Secondary index created on a Z table which already have 9 secondary
    > indexes. This is the 10th index that is created.
    >
    >
    > I will not recommand to create index any more on this table. If you want to create secondary index for on above table which you have mention. You don't create index only for hamper of performance of single program/report.
    >
    > Don't create more than 4 to 5 index on sinlge table.
    >
    > Refere the tread Link:[Why to create Secondary index ?|Re: When is a secondary index used (in select or where)]
    Sounds like another myth that is widely spread across SAP community.
    Remember, complex systems like modern DBMS do not like generalizations. I personally know standard SAP tables with 9 standard secondary indexes. In the meantime the hardware became fast enough to update several secondary indexes without really significant problems. Of course indexes require space, of course one should create indexes that are not similar and differ from each other with more than one field for example. In other words, think before creating!
    But it's again incorrect to say "do not create because you already have 9 others". You did not even ask what fields are in the affected table, what are the existing indexes.
    Ravishankar Lanjewar wrote:
    > I will recommand to delete all the index and create 4 to 5 fresh index while doing analysis for all SQL statement using where use list  depends on where condition of SQL.
    I am now trying to imagine the effort to analyze 300 reports using this table and all corresponding selects. And probably you will drop supporting indexes for several reports. Some of them may be CEO/CFO-relevant reports that will run minutes/hours instead of seconds. And I would like to see the reaction of CEO when he finds out that it was the result of your "optimization" activities.

  • SELECT QUERY  BASED ON SECONDARY INDEX

    Hi all,
    CAN ANYONE TELL ME HOW TO WRITE SELECT QUERY BASED ON SECONDARY INDEX.
    IN WHAT WAY DOES IT IMPROVE PERFORMANCE.
    i KNOW WHEN CREATING SECONDARY INDEX I NEED TO GIVE AN INDEX NO -iT SHOULD BE ANY NUMBER RIGHT?
    I HAVE TO LIST ALL PRIMARY KEYS FIRST AND THEN THE FIELD FOR WHICH I AM CREATING SECONDARY INDEX RIGHT?
    LETS SAY I HAVE 2 PRIMARY KEYS AND I WANT TO CREATE SEONDARY INDEX FOR 2 FIELDS THEN
    I NEED TO CREATE A SEPERTE SECONDARY INDEX FOR EACH ONE OF THOSE FIELDS OR ONE SHOULD BE ENOUGH
    pLS LET ME KNOW IF IAM WRONG

    HI,
    If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVINGclauses, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
    You create secondary indexes using the ABAP Dictionary. There you can create its columns and define it as UNIQUE. However, you should not create secondary indexes to cover all possible combinations of fields.
    Only create one if you select data by fields that are not contained in another index, and the performance is very poor. Furthermore, you should only create secondary indexes for database tables from which you mainly read, since indexes have to be updated each time the database table is changed. <b>As a rule, secondary indexes should not contain more than four fields</b>, <b>and you should not have more than five indexes for a single database table</b>.
    <b>What to Keep in Mind for Secondary Indexes:</b>
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eb2d446011d189700000e8322d00/content.htm
    http://www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
    Regards
    Sudheer

  • Use secondary index in internal tables.

    what are the uses of secondary index in internal table?

    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eb47446011d189700000e8322d00/content.htm
    Creating Secondary Indexes
    Proceed as follows to create a secondary index on a table:
    In the field maintenance screen for the table, choose Goto --> Indexes.
    1. If you went to the field maintenance screen of the table in display mode, only correct the index (and not the table).
    If indexes already exist on the table, a list of these indexes is displayed. Choose Create. A dialog box appears in which you must enter the three-place index identifier. If there are no indexes, go directly to the dialog box.
    2. Enter the index identifier and choose Continue.
    You will go to the maintenance screen for indexes.
    3. Enter an explanatory short text in the field Short text.
    Choose TabFields.
    4. A list of all the fields of the table is displayed.
    5. Select the fields which you want to copy to the index.
    6. Choose Copy.
    The selected fields are copied to the index.
    7. If the values in the index fields already uniquely identify each record of the table, select Unique index.
    A unique index is automatically created on the database during activation because a unique index also has a functional meaning (prevents double entries of the index fields).
    8. If it is not a unique index, leave Non-unique index selected. In this case you can use the corresponding radio buttons to define whether the index should be created automatically on the database for all database systems, for selected database systems or for no database system.
    9. If you chose For selected database systems, you must specify these systems.
    You have two possibilities here:
    List of inclusions: The index is only created automatically during activation for the database systems specified in the list. The index is not created on the database for the other database systems.
    List of exclusions: The index is not created automatically on the database during activation for the specified database systems. The index is automatically created on the database for the other database systems.
    Click on the arrow symbol behind the radio buttons. A dialog box appears in which you can define up to 4 database systems. Use the corresponding radio buttons to decide whether this list should be treated as a list of inclusions or exclusions.
    10. Activate the index with Index ® Activate. The activation log tells you about the flow of the activation. Call it with Utilities ® Act.log. If an error occurred when activating the secondary index, you will automatically go to this log.
    The secondary index is automatically created on the database during activation if the corresponding table has already been created there and index creation was not excluded for the database system.
    Reward points if useful.

  • How to combine spatial and secondary index, when extracting?

    Hi spatiallers,
    vers.: (32 bit) Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production on Sun/SunOS 5.8 (64 bit)
    In our DataWarehouse the table topo_geodata stores all topographic data in Denmark. The table has a spatial index (QT) on its SDO_geometry column named utm_geo as well as a primary key on the column topo_geo_id and 4 secondary indexes on other columns.
    The query to find all geomtries in a given munipalicy is as follows
    select count(*) as antal_AnyInteract_topo_geodata
    from topo_geodata k, topo_geodata tg
    where SDO_RELATE(tg.utm_geo, k.utm_geo, 'mask=AnyInteract querytype= WINDOW') = 'TRUE'
    and k.topo_geo_id = 961 -- geometry of a municipality
    and it returns a count of 19445 in 4 minuttes. However our users are only interested in extracting certain object types, that is a very small subselection of the 19445 geometries. The subselection is typically based on some value or a range of values in the secondary indexed columns.
    Question: How can I make the SELECT use a combination of the spatial index index and a secondary index?
    Only when a pinpoint 1 particular value of the primary key do I get fast response. When pinpointing 1 value in a secondary index as in
    select count(*) as antal1
    from topo_geodata k, topo_geodata tg
    where SDO_RELATE(tg.utm_geo, k.utm_geo, 'mask=AnyInteract querytype= WINDOW') = 'TRUE'
    and k.topo_geo_id = 961 -- Gladsaxe
    and tg.mtk_obj_id = 58476 -- has secondary index
    the performance deteriorates back to 4 min., and the queryplan shows some weird bitmap conversion followed by a bitmap-and operation.
    - Thanks in advance,
    Jens Ole Jensen
    Kort & MatrikelStyrelsen (WWW: http://www.kms.dk)
    Danmark

    Hi Jens,
    I'm not sure I understand the question, or what it is that works fast.
    In this case, the SDO_RELATE with the anyinteract mask has to be done first.
    If this takes 4 minutes, then adding additional criteria to reduce the amount of
    data returned from that subset will only add time.
    The spatial portion of the query has to be done using the spatial index, which is
    a monolithic index for the whole table, so all of the geometry data has to be searched,
    and the anyinteract applied to all of this data.
    After that set of rows comes back, then the additional predicate is applied.
    I'm not sure what this means:
    Only when a pinpoint 1 particular value of the primary key do I get fast response. You do have a few options to try to make things work faster:
    If queries included additional predicates on mtk_obj_id, you might try
    to use range partitioning.
    If the predicates on mtk_obj_id is very selective, then you might want to select
    values based on that column, then use sdo_geom.relate between that very
    small subset and the query window.
    Hope this helps, and all is well with you.
    Dan

  • Regarding secondary index

    how and when we create secondary indexes and what are the advantages and disadvantages of secondary indexes?

    Hi
    Index: Technical key of a database table.
    Primary index: The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.
    Secondary index: Additional indexes could be created considering the most frequently accessed dimensions of the table.
    Structure of an Index
    An index can be used to speed up the selection of data records from a table.
    An index can be considered to be a copy of a database table reduced to certain fields. The data is stored in sorted form in this copy. This sorting permits fast access to the records of the table (for example using a binary search). Not all of the fields of the table are contained in the index. The index also contains a pointer from the index entry to the corresponding table entry to permit all the field contents to be read.
    When creating indexes, please note that:
    An index can only be used up to the last specified field in the selection! The fields which are specified in the WHERE clause for a large number of selections should be in the first position.
    Only those fields whose values significantly restrict the amount of data are meaningful in an index.
    When you change a data record of a table, you must adjust the index sorting. Tables whose contents are frequently changed therefore should not have too many indexes.
    Make sure that the indexes on a table are as disjunctive as possible.
    (That is they should contain as few fields in common as possible. If two indexes on a table have a large number of common fields, this could make it more difficult for the optimizer to choose the most selective index.)
    Accessing tables using Indexes
    The database optimizer decides which index on the table should be used by the database to access data records.
    You must distinguish between the primary index and secondary indexes of a table. The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
    The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
    If the index fields have key function, i.e. they already uniquely identify each record of the table, an index can be called a unique index. This ensures that there are no duplicate index fields in the database.
    When you define a secondary index in the ABAP Dictionary, you can specify whether it should be created on the database when it is activated. Some indexes only result in a gain in performance for certain database systems. You can therefore specify a list of database systems when you define an index. The index is then only created on the specified database systems when activated
    Regards

  • Secondary Index on Table having 0 record?

    Dear All,
    Currently one of the SAP table, BKORM, has 0 records. When we execute statement "select * from BKORM" it fetches 0 record and took more than a minute. When we create secondary index, the same statement provides result in a second.
    My question is, what actually Optimizer do when there isn't any record. What could be the reason ?
    I found SAP Note 305225 which says its an Oracle bug but it is with the case when JOINs are used. Through SQL Trace (Transaction ST05) i tried to figure out but it results the same. Any suggestions or hints?
    Thanks
    Nayab

    better ask this question in abap or basic forum
    A,

  • Slow secondary indexes creation

    I have a database table where each record is a fixed length of 16 bytes and the key length is 4 bytes.
    The table has ~3G records, giving file size of 61GB.
    The access method is DB_QUEUE.
    I'm using the 5.1.25 version.
    I'm trying to create two secondary indexes using DB_HASH as access method.
    I set the pagesize to 65K, cachesize to 65M.
    When I start to build the indexes I see that the creation time of the indexes will take me something like 3 days which I think is reasonable. But after a day the performances are dropping drastically, giving me approximately creation time of 1 month.
    What should I do in order to boost performance on such case?
    Edited by: 868434 on Jun 26, 2011 2:07 AM

    Hi,
    I set the pagesize to 65K, cachesize to 65M.You probably mean 64KB; see the DB->set_pagesize() documentation.
    When I start to build the indexes I see that the creation time of the indexes will take me something like 3 days which I think is reasonable. But after a day the performances are dropping drastically, giving me approximately creation time of 1 month. Are you recreating the secondary indexes on a regular basis? If so, what is the reason for this?
    Once you open, associate and populate the secondary (using the DB_CREATE flag for the associate() call), you should keep the secondary databases around and not remove them just to recreate them again. Whenever the primary database is updated, the appropriate updates are performed in the secondaries as well to reflect the changes; see Secondary indexes documentation section.
    Opening (creating a new database file handle) and populating a secondary database on open are potentially very expensive operations; see the subheading on DB_CREATE in the DB->associate() documentation section.
    What should I do in order to boost performance on such case?The best approach would be to not remove and recreate the secondary indexes regularly, but rather create, populate and keep them around as long as the application runs.
    If however you need to recreate them again and again, and given that they use the Hash access method, here are some suggestions:
    1. If you have a support contract and can access MOS (My Oracle Support) have a look over Doc ID 463613.1 and Doc ID 463507.1 notes in the KM repository (they discuss tuning Hash databases' configuration for speeding up insertion times).
    If you cannot access them, let me know and I can make a summary with further guidance.
    2. Review the Hash access method specific configuration doc section and try to experiment with appropriately calculated values for the density / page fill factor, hash table size (estimated no of elements that will be stored in the database), and with a hash function that evenly distributes the (secondary) keys across buckets (and eventually with a Hash key comparison function that sorts the keys appropriately respecting their structure/format, data type and size).
    3. I assume that this is happening in a transactional environment. If so, it might worth trying to use a transaction handle in the DB->associate() call, which has been opened with the DB_TXN_WRITE_NOSYNC or DB_TXN_NOSYNC flag (see DB_ENV->txn_begin()).
    Some general tuning suggestions, that could be used are also given in the following documentation sections: Access method tuning, and Transaction tuning.
    Regards,
    Andrei

Maybe you are looking for