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

Similar Messages

  • Select query based on userinput

    Hi Folks...
    I posted this in another forum, but no reply,so I am posting it here too. I am trying to make a select query based on a user input. Earlier I was having probelms making a select query and printing out the result in the stack trace,with the advice given, I managed to solve that. I am now modifying that code to make a query based on user input, however it's not working, following is the code:
    String userId = request.getRemoteUser();  String sql = "SELECT hoursused FROM sysuser WHERE iduser = ?";    try      {        Connection connection = dataSource.getConnection();        PreparedStatement preparedStatement = connection.prepareStatement(sql);        preparedStatement.setString(1, userId);                ResultSet srs = preparedStatement.executeQuery(sql);                            while(srs.next()) {                          String hoursused = srs.getString("hoursused");                          System.out.println("The hours used are " + hoursused);    }                  }    catch (SQLException e)      {    e.printStackTrace();    }        } 
    stack trace seems to suggest I may have a probelm with this statement:
    "SELECT hoursused FROM sysuser WHERE iduser = ?"; 
    I am not sure how to rectify this, I hope someone can advise, thanks.

    Hi jschell..
    Thanks for responding, I appreciate it. The problem has been solved. No 'sysuser' is not a reserved word in Mysql. Based on the advice given in another forum and also from this site, I managed to solve the problem. I only made one change. This:
    ResultSet srs = preparedStatement.executeQuery(sql);     was changed to this:
    ResultSet srs = preparedStatement.executeQuery();  Thanks.

  • Select Query Based on date condition

    Hi ,
    Is it Possible.
    i want to run select query based on date condition.
    Eg...
    if the date between 01-jan-01 and 01-jan-05 then
    select * from table1;
    if the date between 02-jan-05 and 01-jan-08 then
    select * from table2;
    Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
    i dont want plsql here Just SQL needed.
    thanks,
    -R
    Edited by: infant_raj on May 5, 2009 11:48 PM

    Helo Kanish,
    this is not the one i was asking..
    wht i mean was .
    i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
    EG..
    select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
    select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
    Run any one of the two . not all
    thanks,
    _raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Select query based LOV for tabular form attributes

    Hi HTMLDB Team,
    Congrats u all for the new release of HTMLDB in htmldb.oracle.com.
    I badly need a solution of the below problem.
    Say , i have table called user_col_comments now i want to display the table_name ,column_name and comments in a tabular form.I displayed only one row for the tabular form.Now i create a select query based LOV for attribute table_name where i got all table_name in drop down list.
    Point is that after selecting any data from drop down table list i want to get the corresponding fields to be populated in column_name attributes.How can i wrote the select query based LOV for the attibute column_name.
    I wrote it as 'select column_name d,column_name r from user_col_comments where table_name=:TABLE_NAME Its not working?
    Similarly i want same thing to display for comments after matching both table_name and column_name.
    Any solution to get rid of those problem will be highly appreciable...
    If u need my htmldb.oracle.com userid and password to solve the problem i will sure let u email it.
    Cheers,
    Eman

    hi rchalton,
    can u plz little bit more clearer .I know hopefully u can imagine the problem and may u guide me thru proper way.....One think i understand that there must be multiple process and submit but "only when..." that u have said i cant understand that part........
    U are welcome to give me proper solution.....
    Thanks for the reply ....atleast one can pay hid to me.....
    Cheers,
    Eman

  • Select query based on joining of tables from different database is taking too long

    Hi Team,
    Select query on table with millions of records is taking very long time. It took 50mins, the below query is joining on multiple table from two databases DB1.dbo.Table1 contains 100 million records and also Table3 and Table4 (of different database) might
    contain close to 1million records.
    Select T1.*
    From DB1.dbo.Table1 T1
    Join DB1.dbo.Table2 T2 on RTRIM(T1.Col3) = RTRIM(T2.Col3)
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    Join Table3 U on CA.Col2 = U.Col2 AND RTRIM(T2.Col2) = U.Col3
    Where U.Col4 NOT IN ('A1', 'A2', 'A3', 'A4', 'A5', 'A6','A7','A8','A9')
    And (T1.flg IS NULL OR T1.flg = 'N')
    And LTRIM(RTRIM(T2.Col2)) NOT IN ('B1','B2')
    How can i improve the performance of this query. Actual thing is update the data in Db1.dbo.table1 based on the conditions but if the select is taking close to 1hr then update will take hours together. Indexes already implemented on all the tables.
    Thanks,
    Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

    Thanks.
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    This join is not working with spaces if Rtrim is not used.
    Thanks! Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

  • Want to select query based on sample data.

    My Oracle Version
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    I am creating inventory valuation report using FIFO method . here sample data .
    create table tranx(
    TRXTYPE     varchar2(10) ,ITEM_CODE varchar2(10),     RATE number,qty number
    insert into tranx values('IN'     ,'14042014',     457.2     ,10);
    insert into tranx values('OUT','14042014',     0,          10);
    insert into tranx  values('IN','14042014',     458.1,     35);
    insert into  tranx values('OUT','14042014',     0,          11);
    insert into  tranx values('OUT','14042014',     0,          6);
    insert into  tranx values('IN','     14042014',     457.2     ,10);
    insert into tranx  values('OUT','     14042014',     0,          3);
    insert into tranx  values('OUT','     14042014',     0,          4);
    insert into tranx  values('IN','     14042014',     457.2,     20);
    insert into tranx  values('OUT','     14042014',     0,          5);
    insert into tranx  values('OUT','     14042014',     0,          9);
    insert into tranx  values('OUT','     14042014',     0,          8);
    current output
    TRXTYPE     ITEM_CODE     RATE      QTY
    IN     14042014     457.2     10
    OUT     14042014     0          10
    IN     14042014     458.1     35
    OUT     14042014     0          11
    OUT     14042014     0          6
    IN     14042014     457.2     10
    OUT     14042014     0          3
    OUT     14042014     0          4
    IN     14042014     457.2     20
    OUT     14042014     0          5
    OUT     14042014     0          9
    OUT     14042014     0          8above data populate based on first in first out . but out rate is not comes from that query. suppose fist 10 qty are OUT its rate same as IN. but when qty start out from 35 rate will be 458.1 till all 35 qty will not out. like out qty 11,6,3,4,5,9 now total are 38 .
    when qty 9 will out the rate are 6 qty rate 458.1 and other 3 out rate of 457.2 means total value of 9 out qty value is 4120.20 .
    Now 35 qty is completed and after that rate will continue with 457.2 till 10 qty not completed.
    I think you understand my detail if not please tell me .
    thanks
    i am waiting your reply.

    As SomeoneElse mentioned, there is no row order in relational tables, so you can't tell which row is first and which is next unless ORDER BY is used. So I added column SEQ to your table:
    SQL> select  *
      2    from  tranx
      3  /
    TRXTYPE    ITEM_CODE        RATE        QTY        SEQ
    IN         14042014        457.2         10          1
    OUT        14042014            0         10          2
    IN         14042014        458.1         35          3
    OUT        14042014            0         11          4
    OUT        14042014            0          6          5
    IN         14042014        457.2         10          6
    OUT        14042014            0          3          7
    OUT        14042014            0          4          8
    IN         14042014        457.2         20          9
    OUT        14042014            0          5         10
    OUT        14042014            0          9         11
    TRXTYPE    ITEM_CODE        RATE        QTY        SEQ
    OUT        14042014            0          8         12
    12 rows selected.
    SQL> Now it can be solved. Your task requires either hierarchical or recursive solution. Below is recursive solution using MODEL:
    with t as (
               select  tranx.*,
                       case trxtype
                         when 'IN' then row_number() over(partition by item_code,trxtype order by seq)
                         else 0
                       end rn_in,
                       case trxtype
                         when 'OUT' then row_number() over(partition by item_code,trxtype order by seq)
                         else 0
                       end rn_out,
                       count(case trxtype when 'OUT' then 1 end) over(partition by item_code) cnt_out
                 from  tranx
    select  trxtype,
            item_code,
            rate,
            qty
      from  t
      model
        partition by(item_code)
        dimension by(rn_in,rn_out)
        measures(trxtype,rate,qty,qty qty_remainder,cnt_out,1 current_in,seq)
        rules iterate(10) until(iteration_number + 1 = cnt_out[0,1])
         rate[0,iteration_number + 1]          = rate[current_in[1,0],0],
         qty_remainder[0,iteration_number + 1] = case sign(qty_remainder[0,cv() - 1])
                                                   when 1 then qty_remainder[0,cv() - 1] - qty[0,cv()]
                                                   else qty[current_in[1,0],0] - qty[0,cv()] + nvl(qty_remainder[0,cv() - 1],0)
                                                 end,
         current_in[1,0]                       = case sign(qty_remainder[0,iteration_number + 1])
                                                   when 1 then current_in[1,0]
                                                   else current_in[1,0] + 1
                                                 end
      order by seq
    TRXTYPE    ITEM_CODE        RATE        QTY
    IN         14042014        457.2         10
    OUT        14042014        457.2         10
    IN         14042014        458.1         35
    OUT        14042014        458.1         11
    OUT        14042014        458.1          6
    IN         14042014        457.2         10
    OUT        14042014        458.1          3
    OUT        14042014        458.1          4
    IN         14042014        457.2         20
    OUT        14042014        458.1          5
    OUT        14042014        458.1          9
    TRXTYPE    ITEM_CODE        RATE        QTY
    OUT        14042014        457.2          8
    12 rows selected.
    SQL> SY.

  • Select query based on Simple Type field in JDT

    Hello Experts,
    We have a JDT table consisting of a field "CONSUMPTION_ID" which refers to a Simpletype.So at oracle level the datatype of the field shows as CLOB instead of String. I am unable to use this simple type field in the WHERE clause in my bean .
    Following are the queries i have tried and the errors i have got executing them :
    Query1 -  SELECT * FROM TEST_TABLE WHERE CONSUMPTION_ID <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM "TEST_TABLE " WHERE "REF_MAT_DOC_NO" = ? AND "REF_MAT_DOC_YEAR" = ? AND "CONSUMPTION_ID" <> 'RT'" contains the semantics error[s]: - 1:84 - type check error: the expression >>"CONSUMPTION_ID"<< (CLOB) is not comparable and must not be used with "<>"
    - 1:84 - type check error: the left hand side >>"CONSUMPTION_ID"<< (CLOB) and the right hand side >>'RT'<< (CHAR) of a comparison operator are not comparable
    Query 2 - SELECT * FROM TEST_TABLE WHERE to_char(CONSUMPTION_ID) <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM TEST_TABLE  WHERE REF_MAT_DOC_NO = ? AND REF_MAT_DOC_YEAR = ? AND to_char(CONSUMPTION_ID) <> 'RT'" contains the syntax error[s]: - 1:91 - SQL syntax error: the token "(" was not expected here
    Please let me know if any one has used WHERE clause on fields which refer to a simpletype in JDT, or any other solution to the above problem
    Regards,
    Virag

    Hello Experts,
    We have a JDT table consisting of a field "CONSUMPTION_ID" which refers to a Simpletype.So at oracle level the datatype of the field shows as CLOB instead of String. I am unable to use this simple type field in the WHERE clause in my bean .
    Following are the queries i have tried and the errors i have got executing them :
    Query1 -  SELECT * FROM TEST_TABLE WHERE CONSUMPTION_ID <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM "TEST_TABLE " WHERE "REF_MAT_DOC_NO" = ? AND "REF_MAT_DOC_YEAR" = ? AND "CONSUMPTION_ID" <> 'RT'" contains the semantics error[s]: - 1:84 - type check error: the expression >>"CONSUMPTION_ID"<< (CLOB) is not comparable and must not be used with "<>"
    - 1:84 - type check error: the left hand side >>"CONSUMPTION_ID"<< (CLOB) and the right hand side >>'RT'<< (CHAR) of a comparison operator are not comparable
    Query 2 - SELECT * FROM TEST_TABLE WHERE to_char(CONSUMPTION_ID) <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM TEST_TABLE  WHERE REF_MAT_DOC_NO = ? AND REF_MAT_DOC_YEAR = ? AND to_char(CONSUMPTION_ID) <> 'RT'" contains the syntax error[s]: - 1:91 - SQL syntax error: the token "(" was not expected here
    Please let me know if any one has used WHERE clause on fields which refer to a simpletype in JDT, or any other solution to the above problem
    Regards,
    Virag

  • "Improving SQL query performance using secondary indexes"

    I have a very old copy of this document from 1997. I'm hoping to find newer version, if one exists, but the search facility on SDN is not working at the moment. Does anyone have a more up to date copy or link they can point me to ?
    thanks,
    Malcolm.

    HI,
    check it out , may be it will help you
    [http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10743/schema.htm]
    [http://teradata.uark.edu/research/wang/indexes.html]
    [http://www.geekinterview.com/question_details/33720]

  • Secondary Index Picked with one field short in select query

    Hi,
    We have a select query as follows
    select  single lgort       vgbel        vgpos
        into   (lips-lgort,lips-vgbel,lips-vgpos)
        from    lips
       where         vbeln          Eq p_zlcpp-vbeln
         and         matnr          Eq p_zlcpp-matnr
         and         charg          Eq p_zlcpp-charg
    The secondary index ZB has the fields as follows:
    MANDT     Client
    MATNR     Material Number
    CHARG     Batch Number
    BWART     Movement Type (Inventory Management)
    When seen in the trace it seems the select query picks this secondary index. Whether it is correct? since i find no BWART in the select query. Because of this index the query take large time. I used the Hint statement as follows:
    select  single lgort       vgbel        vgpos
        into   (lips-lgort,lips-vgbel,lips-vgpos)
        from    lips
       where         vbeln          Eq p_zlcpp-vbeln
         and         matnr          Eq p_zlcpp-matnr
         and         charg          Eq p_zlcpp-charg   %_HINTS ORACLE 'INDEX("LIPS" "LIPS~0")' .
    and it now works fast. Please advice the best way to make the select query work on itself without using the hint statement to pick the index LIPS~0 instead of the invalid secondary index ZB.
    Thanks & Regards,
    Selvakumar M.
    Edited by: Selva on Jun 17, 2011 7:35 PM

    Hello Selva,
    your problem here is the decision of the optimizer that does not exactly know the selectivity of the fields.
    If your deliveries are normally small (not too many items), then selecting via the document number will be relatively fast.
    And selecting via the material number + batch will be slow in case if many deliveries are having same product from the same batch delivered.
    I assume that the latest is the case in your system. That's why the selection with ZB index is slow.
    If the data distribution is as I described above, then your hint is quite OK and I advise you to stick to the hint.
    From my PoV this is the better solution rather changing the coding and throwing out MATNR field from the WHERE clause to filter later in ABAP.
    Another solution would be trying to play with histograms. But you'll need %SUBSTITUTE VALUES% or %SUBSTITUTE LITERALS% hint anyway, so I find your solution better.
    So, please stay with hint. Even SAP standard development does it for some select statements.
    Regards,
      Yuri

  • Mentioning the index in the select query?

    Hi All,
    I want to write a query on AUFM table having where condition for AUFNR field. This table has 2 secondary indexes.
    1st one on {MATNR,CHARG,WERKS, BWART,BUDAT}
    and 2nd one on
    I want to specify 2nd index in my select query . How can I mention that in select query?
    rgds,
    Madhuri

    When you make use of AUFNR only in ur select query then automatically secondary index pertaining to that would be invoked.

  • How to use secondary index

    Hi abapers,
    Iam creating secondary index for the database table MSEG. ....How to write select query for the secondary index that i have created..
    Regards,
    Ramya

    how to create secondary index in tables
    https://forums.sdn.sap.com/click.jspa?searchID=933015&messageID=2971112
    Guidelines to create secondary index
    https://forums.sdn.sap.com/click.jspa?searchID=933015&messageID=2009801
    Secondary index;
    http://help.sap.com/saphelp_47x200/helpdata/en/cf/21eb2d446011d189700000e8322d00/content.htm
    this will definitely help you, dont forget to award points if found helpful

  • 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

  • Check Index used in an oracle select query

    Hi Friends,
    I have partitioned an oracle table and created Local Index for the Partitioned table .
    Now i want to make sure that the Local index is being used when i perform select query on the Table partition.
    How do i confirm that ?
    can i check the explain plan generted for the select query to confirm local index is being used ?
    Please let me know.
    Regards,
    DB

    Now i want to make sure that the Local index is being used when i perform select query on the Table partition.Why? Have you proven that using this local index is the "best" plan?
    How do i confirm that ?
    can i check the explain plan generted for the select query to confirm local index is being used ?When I asked Google "how to read an oracle explain plan," I found lots of information - what did you find?

  • ST05 Trace on a select query on BSEG table

    hi all,
    this is my select query on table BSEG table:
      SELECT bukrs
             belnr
             gjahr
             buzei
             KOART
             mwskz
             kostl
             lifnr
             aufnr
             werks
             ebeln
             txjcd
             projk FROM bseg
                   INTO TABLE i_bseg
                   FOR ALL ENTRIES IN i_ad_tab
                  WHERE bukrs EQ i_ad_tab-bukrs  AND
                        belnr EQ i_ad_tab-belnr  AND
                        gjahr EQ i_ad_tab-gjahr.
    when i m doing SQL trace ST05 on this query and in the detail statement showed the following query
    SELECT
      "MANDT" , "BUKRS" , "BELNR" , "GJAHR" , "PAGENO" , "TIMESTMP" ,
      "PAGELG" , "VARDATA"
    FROM
      "RFBLG"
    WHERE
      "MANDT" = ? AND  "BUKRS" = ? AND  "BELNR" = ? AND  "GJAHR" = ?
    ORDER BY
      "MANDT" , "BUKRS" , "BELNR" , "GJAHR" , "PAGENO"
    what is RFBLG table in SE11, but could not find it.
    what is RFBLG?also, the above select query giving me performance issues.. the "for all entries" clause is used as per norms...
    please suggest a solution..

    hi
    good
    The famous BSEG table is a cluster table.
    It is as was correctly stated part of the Accounting Document Segment. It is part of the Pool cluster RFBLG and lives in the package: FBAS (Financial accounting 'Basis').
    You can't read a cluster table exactly the way you read a database (old speak, transparent table).
    You can use a program to read called RFPPWF05
    Note 435694: Display BSEG item by calling FB09D (modified FB09)
    Other possiblity: Other possibility: CALL DIALOG 'RF_ZEILEN_ANZEIGE', but since this is a dialog I don't think this would work.
    In any event go to FBAS Package (development class) to see your business objects, class library and functions.
    you must use keyfields bukrs , belnr, gjahr
    (so 1st select table bkpf) to select bseg.
    or use secondary index tables:
    bsas, bsis, bsik, bsak, bsid, bsad
    Regards,
    Raj.

  • Secondary Index with or without MANDT field

    HI ABAP Guru's,
    What is necessary to add field MANDT while creation of secodary index in DBS.
    But i some body my superiors challanged to me with out using MANDT our secoday index won't works.
    But i tested few scenarios i am not get differnce.
    please advice me exactly which scenarios it is mandatory.
    Below are the Time taken with deffrent scnarios i created one test program to get the time with secondary index with out secodary index secondary index with mndat fiels
    **&with out creation of seconday index
    *1st time -57,103,681
    2nd Time-55,388,294
    **before creation of seconday index with out mandt
    I1st time execution-324,119
    2nd time progrm execution--391,134
    3rd time progrm execution-327,046
    4th time progrm execution336,774
    5th time progrm execution359,100
    6t  time progrm execution-328,027
    *before creation of seconday index with mandtiI1st time execution-367,623
    2nd time progrm execution365,139
    3rd-352,328
    4th-369,122
    5th-352,236
    6th380,590
    7th466,810
    Thanks In Advance,
    Kandula.
    Edited by: Thomas Zloch on Nov 18, 2011 1:08 PM

    Vishnu Tallapragada wrote:
    So if you are maintaining multiple client data on the same database, then not adding MANDT to index will have undesirable effects as any select based on secondary index may return records that are not belonging to this client and deletes and additions on the index from multiple clients will lead to data integrity issues.
    Wrong!
    WHERE clause decides about data being selected, deleted or what-ever.
    Index decides only about HOW data is accessed (if used), not WHAT data is accessed.
    If your database returns a different result depending on the indexdefinition,
    you should log a call at your DB vendor immediately, because this is a bug.
    In general, as the client has usually only a small number of distinct values, it is not a good field,
    to convince the database, that this index is a good idea. But on high volume tables it can be very selective
    as far as the number of result records is concerned (might cut down 50% when 2 clients!).
    In addition it is a very short field, so it should not cost much storage (esp. when compressable).
    Szenario:
    MANDT+IDX-Field with two clients and lets say 5000 record per client (so that idx access will be interesting),
    assuming a given IDX value will return 50 records (25 in each client).
    So the select will be
    ... WHERE MANDT=sy-mandt AND IDX=value
    Accesing the index with only IDX will result in stepping down the index-tree (say 3 blocks) and then reading leafblocks
    to get the 50 hits for IDX-value (assuming 30 records per leafblock -> 2 leafblocks required to gret the 50 records)
    Right now you have accessed 5 blocks to get the address of 50 records that still need to be checked against MANDT.
    So there is need to get 50 blocks (may be less, depending on clustering) to do a filter on MANDT
    and get the final 25 records for the result.
    If you put the MANDT field into the index it might require more space, so that we assume 20 records per leaf block now.
    But since you can now filter MANDT already on the index blocks, you will again only need to get 5 blocks and
    have the adress of the required 25 target records.
    So getting the result is 55 blockinspections without MANDT in index and 30 blockinspections with MANDT in index in this case.
    Now you can start pushing around values and statistics an calculate at what amount of data and average
    size of resultsets it becomes right or wrong to include MANDT. It may turn out both ways, allthough I think
    with MANDT being small, it is usually loss of brain cycles to calculate around for this.
    You simply include it, it will cost only little space and it will never be wrong.
    You leave it out, you will gain little space, but might end up with performance loss.
    If you have only one client in the system, you can safely go with the saving space strategie, as long as you do not need
    a UNIQUE secondary index.
    Volker

Maybe you are looking for