<?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: QUESTION ON OPEN SQL STATEMENT. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651722#M289499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ramesh!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe your SAP runs on a database with a cost based optimizer. This analysis expected execution times based on different ways using the indices. To be able to work correct, statistics of the field contents are necessary. When you create a new index, no statistic information was gather up to know -&amp;gt; the cost based optimizer can't work correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go to DB20, enter your table and check, when the last statistics where created. You might need to trigger a new creation manually (STRG+F2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way. the order of the fields in the where-clause don't influence the decision, which index will be used. It's only a question, if in other programs the same order will be found and a SQL-statement-buffer will have a hit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Nov 2006 14:43:25 GMT</pubDate>
    <dc:creator>christian_wohlfahrt</dc:creator>
    <dc:date>2006-11-27T14:43:25Z</dc:date>
    <item>
      <title>QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651719#M289496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;whenever we access data  from the data base using SELECT STATEMENT then it will be processed by primary index but if i want to use secondary (i have created secondary index field) what will be my syntax in the programming 4 secondary index field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 07:19:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651719#M289496</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-27T07:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651720#M289497</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;U have to use all fields of the secondary index in WHERE condition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if your index use FIELD1, FIELD2 and FIELD3:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM &amp;lt;TABLE&amp;gt; WHERE FIELD1 =&lt;/P&gt;&lt;P&gt;                        AND FIELD2 =&lt;/P&gt;&lt;P&gt;                        AND FIELD3 =&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sequence of the fields in where condition has to be the same of the index, so here it's not using the index:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM &amp;lt;TABLE&amp;gt; WHERE FIELD2 =&lt;/P&gt;&lt;P&gt;                        AND FIELD1 =&lt;/P&gt;&lt;P&gt;                        AND FIELD3 =&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It can partially use the index using only some fields (but in the same sequence):&lt;/P&gt;&lt;P&gt;SELECT * FROM &amp;lt;TABLE&amp;gt; WHERE FIELD1 =&lt;/P&gt;&lt;P&gt;                        AND FIELD2 =&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 07:20:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651720#M289497</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-27T07:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651721#M289498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can force the sql statement to use a particular index by using %_HINTS parameter. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For eg:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT carrid connid cityfrom
FROM spfli INTO (xcarrid, xconnid, xcityfrom)
WHERE carrid = 'LH ' AND cityfrom = 'FRANKFURT'
%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'.
WRITE: / xcarrid, xconnid, xcityfrom.
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 07:22:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651721#M289498</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-27T07:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651722#M289499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ramesh!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe your SAP runs on a database with a cost based optimizer. This analysis expected execution times based on different ways using the indices. To be able to work correct, statistics of the field contents are necessary. When you create a new index, no statistic information was gather up to know -&amp;gt; the cost based optimizer can't work correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go to DB20, enter your table and check, when the last statistics where created. You might need to trigger a new creation manually (STRG+F2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way. the order of the fields in the where-clause don't influence the decision, which index will be used. It's only a question, if in other programs the same order will be found and a SQL-statement-buffer will have a hit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 14:43:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651722#M289499</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2006-11-27T14:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651723#M289500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I use the hint command in a select like this: &lt;/P&gt;&lt;P&gt;  SELECT mblnr mjahr budat&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE t_mov&lt;/P&gt;&lt;P&gt;          FROM mkpf&lt;/P&gt;&lt;P&gt;          WHERE  mjahr IN s_mjahr&lt;/P&gt;&lt;P&gt;          AND   budat IN s_budat&lt;/P&gt;&lt;P&gt;%_HINTS oracle 'INDEX("MKPF" "MKPF~Z02")'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But How can i use the %_HINTS oracle command in a join select like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT s&lt;SUB&gt;mblnr s&lt;/SUB&gt;mjahr s~zeile&lt;/P&gt;&lt;P&gt;         s&lt;SUB&gt;bwart s&lt;/SUB&gt;sobkz&lt;/P&gt;&lt;P&gt;         s&lt;SUB&gt;matnr s&lt;/SUB&gt;werks&lt;/P&gt;&lt;P&gt;         s&lt;SUB&gt;menge s&lt;/SUB&gt;meins s~shkzg&lt;/P&gt;&lt;P&gt;         s&lt;SUB&gt;bustm s&lt;/SUB&gt;zustd s~xauto&lt;/P&gt;&lt;P&gt;        INTO CORRESPONDING FIELDS OF TABLE t_mov&lt;/P&gt;&lt;P&gt;        FROM mkpf AS k JOIN mseg AS s&lt;/P&gt;&lt;P&gt;          ON k&lt;SUB&gt;mblnr EQ s&lt;/SUB&gt;mblnr&lt;/P&gt;&lt;P&gt;         AND k&lt;SUB&gt;mjahr EQ s&lt;/SUB&gt;mjahr&lt;/P&gt;&lt;P&gt;       WHERE  k~mjahr IN s_mjahr&lt;/P&gt;&lt;P&gt;        AND   k~budat IN s_budat&lt;/P&gt;&lt;P&gt;        AND   s~matnr IN so_matnr&lt;/P&gt;&lt;P&gt;        AND   s~werks EQ p_werks&lt;/P&gt;&lt;P&gt;        AND   s~lgort IN s_lgort&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        riccardo di mario&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Feb 2007 18:22:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651723#M289500</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-08T18:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651724#M289501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ramesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only issue with the %HINT command is it will run only on an ORACLE DB, not on a IBM database server (DB6) .... &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;Aditya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Feb 2007 20:12:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651724#M289501</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-08T20:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651725#M289502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if the statistical update is performed no need to go with forceful read of secondary index using the %hint.. &lt;/P&gt;&lt;P&gt;First make sure that a secondary index exists.&lt;/P&gt;&lt;P&gt;check the fields in the index&lt;/P&gt;&lt;P&gt;just use the fields in the secondary index in the where clause.&lt;/P&gt;&lt;P&gt;in sql trace analyse you can check whether the seconday index is picked or not..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 08:39:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651725#M289502</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-05T08:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: QUESTION ON OPEN SQL STATEMENT.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651726#M289503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ramesh,&lt;/P&gt;&lt;P&gt;After creating secondary index, if it is unique use as like as primary index.&lt;/P&gt;&lt;P&gt;1.If, for all fields in a unique index (primary index or unique secondary index), WHERE conditions are specified with '=' in the WHERE clause, the database optimizer selects the access strategy index unique scan.&lt;/P&gt;&lt;P&gt;2.For the index unique scan access strategy, the database usually needs to read a maximum of four data blocks (three index blocks and one table block) to access the table record.&lt;/P&gt;&lt;P&gt;3.In the SELECT statement shown above, the table DB is accessed. The fields MANDT and Field form the primary key, and are specified with '=' in the WHERE clause. The database optimizer therefore selects the index unique scan access strategy, and only needs to read four data blocks to find the table record requested.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ameer Baba.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 11:05:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-open-sql-statement/m-p/1651726#M289503</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-05T11:05:12Z</dc:date>
    </item>
  </channel>
</rss>

