<?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: coding indexes in select in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890637#M53359</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For using indexes in the select statement, include the following code after the where clause in the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%_HINTS ORACLE&lt;/P&gt;&lt;P&gt;'INDEX("&amp;amp;TABLE&amp;amp;" "XYZ~ABC")'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where, &lt;/P&gt;&lt;P&gt;XYZ = database table&lt;/P&gt;&lt;P&gt;ABC = index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the index has to be created for a field used in the where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kumod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Apr 2005 07:49:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-04-11T07:49:32Z</dc:date>
    <item>
      <title>coding indexes in select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890633#M53355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai all,&lt;/P&gt;&lt;P&gt;   can any body suggest me how to use the table index in     the select statement. any possible suggestion is welcome.&lt;/P&gt;&lt;P&gt;thanx a lot in advance.&lt;/P&gt;&lt;P&gt;kittu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2005 07:07:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890633#M53355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-08T07:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: coding indexes in select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890634#M53356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using Open SQL (SAP's SQL abstraction layer) there is no real way to explicitly specify which indexes are used by the select (and other SQL) statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to rely on the database for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prior to Oracle version 8 (if you are running Oracle) you had rules based query optimisation.  This means that you could encourage the database to use indexes by using all the fields of the index in the same order as in the index in the WHERE clause.  For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Custom secondary index on VBAP: MANDT, MATNR, NETWR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your select statement to use this index could look like (the client field MANDT is implied):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;  FROM VBAP&lt;/P&gt;&lt;P&gt; WHERE MATNR = 'XXXXX'&lt;/P&gt;&lt;P&gt;   AND NETWR = '1000'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Oracle version 8 and beyond, it has changed to statistical based optimisation, which means that the database chooses which indexes to use (if any) based on statistical information it has for each database object (importantly, these statistics must be kept up to date for it to work effectively).  So the database is likely to choose the same index for vbap even if you change your query to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;  FROM VBAP&lt;/P&gt;&lt;P&gt; WHERE NETWR = '1000'&lt;/P&gt;&lt;P&gt;   AND MATNR = 'XXXXX'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really feel then need to force an index to be used (and the database is not does not want to choose the one you wish), then you may have to resort to the EXEC SQL, ENDEXEC statements to allow you to code native database SQL.  With Oracle you can use database 'HINTS' in your queries, but I am not sure of their syntax. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are not using Oracle then you may want to look at the documentation for your database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2005 08:10:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890634#M53356</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-08T08:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: coding indexes in select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890635#M53357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Praveen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inspect &lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="322747"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2005 08:45:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890635#M53357</guid>
      <dc:creator>ssimsekler</dc:creator>
      <dc:date>2005-04-08T08:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: coding indexes in select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890636#M53358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've used the hints command successfully, though as the included thread says, it is database specific in the sense that the hint would not be applied in another database. The SQL would still work though I suspect just the hint would be ignored. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was in a very specific case where we knew the value to be selected for was always going to be in a very specific range but the database optimizer would not know that (in fact it was the cpu date on bkpf). It made an absolutely massive improvement to performance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2005 23:02:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890636#M53358</guid>
      <dc:creator>former_member328972</dc:creator>
      <dc:date>2005-04-08T23:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: coding indexes in select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890637#M53359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For using indexes in the select statement, include the following code after the where clause in the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%_HINTS ORACLE&lt;/P&gt;&lt;P&gt;'INDEX("&amp;amp;TABLE&amp;amp;" "XYZ~ABC")'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where, &lt;/P&gt;&lt;P&gt;XYZ = database table&lt;/P&gt;&lt;P&gt;ABC = index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the index has to be created for a field used in the where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kumod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2005 07:49:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/coding-indexes-in-select/m-p/890637#M53359</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-11T07:49:32Z</dc:date>
    </item>
  </channel>
</rss>

