<?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: Efficient Select in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564913#M1564780</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;Try FROM bkpf  INTO CORRESPONDING FIELDS OF TABLE tl_bkpf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case this is mutch faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Success,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Dec 2010 13:56:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-12-29T13:56:56Z</dc:date>
    <item>
      <title>Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564905#M1564772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I ' ve tried everything that I know and read in this forum but I stiil have the same problem . I have the follow select : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select  bukrs  belnr  gjahr
            blart  cpudt  bvorg
            tcode  waers
          from bkpf  into table  ti_bkpf
          where bukrs in p_bukrs and
                bstat = space    and
                blart in p_blart .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im trying to use this index (is active of course) :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MANDT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BUKRS&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BSTAT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BLART&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;which is a secondary index , but checking in the sm50 I can see that the reading of bkpf is still sequential , what I'm doing wrong? .&lt;/P&gt;&lt;P&gt;thank you for your advices.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 11:52:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564905#M1564772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T11:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564906#M1564773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello Just have a SQL trace on ( ST05 ) and check out is the select hitting the index or not...! OR Which index its hitting .&lt;/P&gt;&lt;P&gt;Hope this would clear out a few thing to you .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 11:56:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564906#M1564773</guid>
      <dc:creator>anup_deshmukh4</dc:creator>
      <dc:date>2010-12-29T11:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564907#M1564774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are your values in p_bukrs and  p_blart?&lt;/P&gt;&lt;P&gt;Not all conditions will lead to index usage.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:01:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564907#M1564774</guid>
      <dc:creator>former_member182670</dc:creator>
      <dc:date>2010-12-29T13:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564908#M1564775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select-options: p_bukrs for bseg-bukrs,
                p_vbund for lfa1-vbund,
                p_valut for bseg-valut,
                p_blart for bkpf-blart.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the user to choose what he/she wants to see.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:24:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564908#M1564775</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T13:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564909#M1564776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand. But what are the values you are using to test the statement?&lt;/P&gt;&lt;P&gt;Depending on the number of select-options records and operators (=,&amp;lt;&amp;gt;, ...) you might get different execution plans for the SQL statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:28:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564909#M1564776</guid>
      <dc:creator>former_member182670</dc:creator>
      <dc:date>2010-12-29T13:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564910#M1564777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What might have happened is that one of the 2 select-options is empty in which case the where-clause for that select-option is ignored.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:34:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564910#M1564777</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T13:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564911#M1564778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well , &lt;/P&gt;&lt;P&gt;for BLART =  'PE' must of the times and for BUKRS  is only one company , however , you know things are you always need to consider some other scenarios.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:38:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564911#M1564778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T13:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564912#M1564779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try giving a hint to the query. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

select a~matnr a~werks a~charg sum( a~clabs )  b~cuobj_bm b~ersda c~matnr
       c~matkl c~mtart c~spart c~wrkst c~extwg f~ewbez c~groes c~volum
       c~meins d~wgbez
  from mchb as a
  join mch1 as b
  on   b~matnr = a~matnr and
       b~charg = a~charg
  join mara as c
  on   c~matnr = a~matnr
  join t023t as d
  on   d~matkl = c~matkl
  join twewt as f
  on   c~extwg = f~extwg and
       f~spras = 'E'
  into table i_mchb
  where a~matnr in s_matnr and
        a~werks in s_werks and
        a~lgort in s_lgort and
        a~lvorm eq ' '     and
        b~lvorm eq ' '     and
        c~matkl in s_matkl and
        c~mtart in s_mtart and
        c~spart in s_spart and
        c~wrkst in s_wrkst and
        c~extwg in s_extwg and
        c~lvorm eq ' '     and
        c~groes in p_size  and
        d~spras eq 'E'
  group by a~matnr a~werks a~charg b~cuobj_bm b~ersda c~matnr c~matkl
           c~mtart c~spart c~wrkst c~extwg    f~ewbez c~groes c~volum
           c~meins d~wgbez
  order by a~matnr a~werks
  %_HINTS MSSQLNT 'TABLE MARA INDEX([MARA~ZI1])'
          MSSQLNT 'TABLE MCHB INDEX([MCHB~ZI2])'
          MSSQLNT 'TABLE MCH1 INDEX([MCH1~ZT3])'.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abdullah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:44:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564912#M1564779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T13:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564913#M1564780</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;Try FROM bkpf  INTO CORRESPONDING FIELDS OF TABLE tl_bkpf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case this is mutch faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Success,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 13:56:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564913#M1564780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T13:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564914#M1564781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  See if this blog help you. [http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/7692] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Alok&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 14:00:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564914#M1564781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T14:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564915#M1564782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; hello Just have a SQL trace on ( ST05 ) and check out is the select hitting the index or not...! OR Which index its hitting .&lt;/P&gt;&lt;P&gt;&amp;gt; Hope this would clear out a few thing to you .&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It'sfunny i did exactly what did you recommend me , ( ran St05)  and I see this result :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT
  "BUKRS" , "BELNR" , "GJAHR" , "BLART" , "CPUDT" , "BVORG" , "TCODE" , "WAERS"
FROM
  "BKPF"
WHERE
  "MANDT" = :A0 AND "BUKRS" = :A1 AND "BSTAT" = :A2 AND "BLART" = :A3&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Execution Plan


 SELECT STATEMENT ( Estimated Costs = 5.321 , Estimated #Rows = 162.593 )

        2 TABLE ACCESS BY INDEX ROWID BKPF
          ( Estim. Costs = 5.321 , Estim. #Rows = 162.593 )
          Estim. CPU-Costs = 96.360.436 Estim. IO-Costs = 5.310

            1 INDEX RANGE SCAN BKPF~5
              ( Estim. Costs = 1.174 , Estim. #Rows = 162.593 )
              Search Columns: 3
              Estim. CPU-Costs = 47.452.066 Estim. IO-Costs = 1.168&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it means that he using index 5 instead of 3 , if so ,why?,  I dont have  the fields of index 5 in my query : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MANDT&lt;/P&gt;&lt;P&gt;BUKRS&lt;/P&gt;&lt;P&gt;CPUDT&lt;/P&gt;&lt;P&gt;BSTAT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 15:48:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564915#M1564782</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-29T15:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564916#M1564783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi José,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the use of the index is determined at runtime. It is most important what your selection-table look like the moment the statement is executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Unique Index BKPF~0 
MANDT 
BUKRS 
BELNR 
GJAHR 

Index BKPF~1 
MANDT 
BUKRS 
BSTAT 
XBLNR 

Index BKPF~2 
MANDT 
BUKRS 
BSTAT 
BUDAT 

Index BKPF~3 
MANDT 
BUKRS 
BSTAT 
BLART 

Index BKPF~4 
MANDT 
AWTYP 
AWKEY 
AWSYS 

Index BKPF~5 
MANDT 
BUKRS 
CPUDT 
BSTAT&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;What did you enter in the selections. If you gave, i.e. an exclusion (NE ' ') for BSTAT, but not one distinct value, this can not be used for this index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Possibly index 5 still has the best distribution in your system, I don't know. Still 180.000 records are not really so many that we have to worry about index use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 16:40:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-select/m-p/7564916#M1564783</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-12-29T16:40:20Z</dc:date>
    </item>
  </channel>
</rss>

