<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: INDEX in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633983#M605893</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Indexes - Form and Use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Indexes help to speed up selection from the database. They consist of a sorted copy of certain database table fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The primary index is always created automatically in the SAP System. It consists of the primary key fields of the database table, and there is at most one record in the table matching each possible combination of these fields. This kind of index is called a UNIQUE index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you cannot use the primary index to determine a selection result (for example, WHERE condition may not contain any primary index fields), the system searches the whole table. To prevent this, and determine the selection result by searching through a restricted number of database records, you can create a secondary index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you should not define an index for all possible fields in the WHERE condition. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creating an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create an index in Transaction SE11 by choosing Change &amp;amp;#8594; Indexes... &amp;amp;#8594; Create. To make the index unique, select UNIQUE. To specify the fields that will comprise the index, choose "Choose fields". You then need to save and activate the index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When to create an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is worth creating an index when: &lt;/P&gt;&lt;P&gt;You want to select table entries based on fields that are not contained in an index, and the response times are very slow. &lt;/P&gt;&lt;P&gt;The EXPLAIN function in the SQL trace shows which index the system is using. You can generate a list of the database queries involved in an action by entering Transaction ST05 and choosing Trace on &amp;amp;#8594; Execute action &amp;amp;#8594; Trace off &amp;amp;#8594; List trace. If you execute the EXPLAIN SQL function on a EXEC, REEXEC, OPEN, REOPEN or PREPARE statement, the system returns a list containing the index used in the database query. &lt;/P&gt;&lt;P&gt;The field or fields of the new secondary index are so selective that each index entry corresponds to at most 5% of the total number of table entries. Otherwise, it is not worth creating the index. &lt;/P&gt;&lt;P&gt;The database table is accessed mainly for reading entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using an index consisting of several fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if an index consists of several fields, you can still use it when only a few of the fields actually appear in the WHERE clause. The sequence in which the fields are specified in the index is important. You can only use a field in the index if all of the preceding fields in the index definition are included in the WHERE condition. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An index can only support search criteria which describe the search value positively, such as EQ or LIKE. The response time of conditions including NEQ is not improved by an index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Optimal number of fields for an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An index should only consist of a few fields; as a rule, no more than four. This is because the index has to be updated each time you change its fields in a database operation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fields to include in an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Include fields that are often selected and have a high selectivity. In other words, you need to check the proportion of the table entries that can be selected with this field. The smaller the proportion, the more selective the field. You should place the most selective fields at the beginning of the index. &lt;/P&gt;&lt;P&gt;If all of the fields in a SELECT statement are contained in the index, the system does not access the data a second time following the index access. If there are only a few fields in the SELECT statmeent, you can improve performance significantly by including all of these fields in the index. &lt;/P&gt;&lt;P&gt;You should not include a field in an index if its value is initial for most of the table entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Optimal number of indexes for a table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should not create more than five indexes for any one table because: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever you change table fields that occur in the index, the index itself is also updated. &lt;/P&gt;&lt;P&gt;The amount of data increases. &lt;/P&gt;&lt;P&gt;The optimizer has too many chances to make mistakes by using the 'wrong' index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using more than one index for a database table, ensure that they do not overlap. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avoiding OR conditions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The optimizer generally stops if the WHERE condition contains an OR expression. In other words, it does not evaluate the fields in the OR expression with reference to the index. &lt;/P&gt;&lt;P&gt;An exception to this are OR statements standing on their own. Try to reformulate conditions containing an OR expression for one of the indexed fields. For example, replace: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SPFLI &lt;/P&gt;&lt;P&gt;WHERE CARRID = 'LH' &lt;/P&gt;&lt;P&gt;AND (CITYFROM = 'FRANKFURT' OR CITYFROM = 'NEW YORK'). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SPFLI &lt;/P&gt;&lt;P&gt;WHERE (CARRID = 'LH' AND CITYFROM = 'FRANKFURT') &lt;/P&gt;&lt;P&gt;OR (CARRID = 'LH' AND CITYFROM = 'NEW YORK'). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problems with IS NULL &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The value NULL is not stored in the index structure of some database systems. The consequence of this is that the index is not used for that field. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if it helps..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Omkar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Jul 2007 15:53:35 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-24T15:53:35Z</dc:date>
    <item>
      <title>INDEX</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633982#M605892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;plz can some one post links or info regarding handling INDEXEs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2007 15:38:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633982#M605892</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-24T15:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633983#M605893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Indexes - Form and Use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Indexes help to speed up selection from the database. They consist of a sorted copy of certain database table fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The primary index is always created automatically in the SAP System. It consists of the primary key fields of the database table, and there is at most one record in the table matching each possible combination of these fields. This kind of index is called a UNIQUE index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you cannot use the primary index to determine a selection result (for example, WHERE condition may not contain any primary index fields), the system searches the whole table. To prevent this, and determine the selection result by searching through a restricted number of database records, you can create a secondary index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you should not define an index for all possible fields in the WHERE condition. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creating an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create an index in Transaction SE11 by choosing Change &amp;amp;#8594; Indexes... &amp;amp;#8594; Create. To make the index unique, select UNIQUE. To specify the fields that will comprise the index, choose "Choose fields". You then need to save and activate the index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When to create an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is worth creating an index when: &lt;/P&gt;&lt;P&gt;You want to select table entries based on fields that are not contained in an index, and the response times are very slow. &lt;/P&gt;&lt;P&gt;The EXPLAIN function in the SQL trace shows which index the system is using. You can generate a list of the database queries involved in an action by entering Transaction ST05 and choosing Trace on &amp;amp;#8594; Execute action &amp;amp;#8594; Trace off &amp;amp;#8594; List trace. If you execute the EXPLAIN SQL function on a EXEC, REEXEC, OPEN, REOPEN or PREPARE statement, the system returns a list containing the index used in the database query. &lt;/P&gt;&lt;P&gt;The field or fields of the new secondary index are so selective that each index entry corresponds to at most 5% of the total number of table entries. Otherwise, it is not worth creating the index. &lt;/P&gt;&lt;P&gt;The database table is accessed mainly for reading entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using an index consisting of several fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if an index consists of several fields, you can still use it when only a few of the fields actually appear in the WHERE clause. The sequence in which the fields are specified in the index is important. You can only use a field in the index if all of the preceding fields in the index definition are included in the WHERE condition. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An index can only support search criteria which describe the search value positively, such as EQ or LIKE. The response time of conditions including NEQ is not improved by an index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Optimal number of fields for an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An index should only consist of a few fields; as a rule, no more than four. This is because the index has to be updated each time you change its fields in a database operation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fields to include in an index &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Include fields that are often selected and have a high selectivity. In other words, you need to check the proportion of the table entries that can be selected with this field. The smaller the proportion, the more selective the field. You should place the most selective fields at the beginning of the index. &lt;/P&gt;&lt;P&gt;If all of the fields in a SELECT statement are contained in the index, the system does not access the data a second time following the index access. If there are only a few fields in the SELECT statmeent, you can improve performance significantly by including all of these fields in the index. &lt;/P&gt;&lt;P&gt;You should not include a field in an index if its value is initial for most of the table entries. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Optimal number of indexes for a table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should not create more than five indexes for any one table because: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever you change table fields that occur in the index, the index itself is also updated. &lt;/P&gt;&lt;P&gt;The amount of data increases. &lt;/P&gt;&lt;P&gt;The optimizer has too many chances to make mistakes by using the 'wrong' index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using more than one index for a database table, ensure that they do not overlap. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avoiding OR conditions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The optimizer generally stops if the WHERE condition contains an OR expression. In other words, it does not evaluate the fields in the OR expression with reference to the index. &lt;/P&gt;&lt;P&gt;An exception to this are OR statements standing on their own. Try to reformulate conditions containing an OR expression for one of the indexed fields. For example, replace: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SPFLI &lt;/P&gt;&lt;P&gt;WHERE CARRID = 'LH' &lt;/P&gt;&lt;P&gt;AND (CITYFROM = 'FRANKFURT' OR CITYFROM = 'NEW YORK'). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SPFLI &lt;/P&gt;&lt;P&gt;WHERE (CARRID = 'LH' AND CITYFROM = 'FRANKFURT') &lt;/P&gt;&lt;P&gt;OR (CARRID = 'LH' AND CITYFROM = 'NEW YORK'). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problems with IS NULL &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The value NULL is not stored in the index structure of some database systems. The consequence of this is that the index is not used for that field. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if it helps..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Omkar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2007 15:53:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633983#M605893</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-24T15:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633984#M605894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indexes  &lt;/P&gt;&lt;P&gt;You can search a table for data records that satisfy certain search criteria faster using an index.&lt;/P&gt;&lt;P&gt;An index can be considered a copy of a database table that has been reduced to certain fields. This copy is always in sorted form. Sorting provides faster access to the data records of the table, for example using a binary search. The index also contains a pointer to the corresponding record of the actual table so that the fields not contained in the index can also be read.&lt;/P&gt;&lt;P&gt;The primary index is distinguished from the secondary indexes of a table. 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.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Table SCOUNTER in the  flight model contains the assignment of the carrier counters to airports. The primary index on this table therefore consists of the key fields of the table and a pointer to the original data records.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;You can also create further indexes on a table in the ABAP Dictionary. These are called secondary indexes. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access. Different indexes on the same table are distinguished with a three-place index identifier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;LINK :  &lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/cf/21eb61446011d189700000e8322d00/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/cf/21eb61446011d189700000e8322d00/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Prax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2007 21:06:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633984#M605894</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-24T21:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633985#M605895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write your select query like the following to use the index of any database table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the fields in the WHERE condition of any select query inthe same order as they exist in any of the secondary index of that table.&lt;/P&gt;&lt;P&gt;eg.&lt;/P&gt;&lt;P&gt;for table1 secondary index sc1 have fields -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt; f2,f3 f5,f1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then your where clause shound be where f2 = &amp;lt;condition&amp;gt; and f3 = &amp;lt;condition&amp;gt; and f5 = &amp;lt;condition&amp;gt; and f1 = &amp;lt;condition&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;regards&lt;/P&gt;&lt;P&gt;Debjani &lt;/P&gt;&lt;P&gt;Rewards point for all helpful answer&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2007 06:47:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/index/m-p/2633985#M605895</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-25T06:47:15Z</dc:date>
    </item>
  </channel>
</rss>

