Performance Issue in select statements

In the following statements, it is taking too much time for execution,Is there any best way to change these selection statements...int_report_data is my final internal table....
select fsplant fvplant frplant fl1_sto pl1_delivery pl1_gr pl2_sto           pl2_delivery perr_msg into (dochdr-swerks,dochdr-vwerks,dochdr-rwerks,dochdr-l1sto,docitem-l1xblnr, docitem-l1gr,docitem-l2sto,  docitem-l2xblnr,docitem-err_msg) from zdochdr as f inner join zdocitem as p on fl1_sto  =  pl1_sto where fsplant in s_werks and
fvplant in v_werks and frplant  in r_werks and pl1_delivery in l1_xblnr and pl1_gr in l1_gr and p~l2_delivery in l2_xblnr.
move : dochdr-swerks    to  int_report_data-i_swerks,
        dochdr-vwerks    to  int_report_data-i_vwerks,
        dochdr-rwerks    to  int_report_data-i_rwerks,
        dochdr-l1sto     to  int_report_data-i_l1sto,
        docitem-l1xblnr  to  int_report_data-i_l1xblnr,
        docitem-l1gr     to  int_report_data-i_l1gr,
        docitem-l2sto    to  int_report_data-i_l2sto,
        docitem-l2xblnr  to  int_report_data-i_l2xblnr,
        docitem-err_msg  to  int_report_data-i_errmsg.
        append int_report_data.
    endselect.
Goods receipt
loop at int_report_data.
select single ebeln from ekbe into l2gr where ebeln = int_report_data-i_l2sto and bwart = '101' and bewtp = 'E' and vgabe = '1'.
if sy-subrc eq 0.
       move l2gr to int_report_data-i_l2gr.
       modify int_report_data.
   endif.
endloop.
first Billing document (I have to check fkart = ZRTY for second billing *document..how can i write the statement)
select vbeln from vbfa into (tabvbfa-vbeln) where vbelv = int_report_data-i_l2xblnr or vbelv = int_report_data-i_l1xblnr.
select single vbeln from vbrk into tabvbrk-vbeln where vbeln = tabvbfa-vbeln and fkart = 'IV'.
  if sy-subrc eq 0.
         move tabvbrk-vbeln to int_report_data-i_l2vbeln.
         modify int_report_data.
   endif.
   endselect.
Thanks in advance,
Yad

Hi!
Which of your selects is slow? Make a SQL-trace, check which select(s) is(are) slow.
For EKBE and VBFA you are selecting first key field - in general that is fast. If your z-tables are the problem, maybe an index might help.
Instead of looping and making a lot of select singles, one select 'for all entries' can help, too.
Please analyze further and give feedback.
Regards,
Christian

Similar Messages

  • Performance Issue in Select Statement (For All Entries)

    Hello,
    I have a report where i have two select statement
    First Select Statement:
    Select A B C P Q R
         from T1 into Table it_t1
              where ....
    Internal Table it_t1 is populated with 359801 entries through this select statement.
    Second Select Statement:
    Select A B C X Y Z
         from T2 in it_t2 For All Entries in it_t1
              where A eq it_t1-A
                 and B eq it_t1-B
                 and C eq it_t1-C
    Now Table T2 contains more than 10 lac records and at the end of select statement it_t2 is populated with 844003 but it takes a lot of time (15 -20 min) to execute second select statement.
    Can this code be optimized?
    Also i have created respective indexes on table T1 and T2 for the fields in Where Condition.
    Regards,

    If you have completed all the steps mentioned by others, in the above thread, and still you are facing issues then,.....
    Use a Select within Select.
    First Select Statement:
    Select A B C P Q R package size 5000
         from T1 into Table it_t1
              where ....
    Second Select Statement:
    Select A B C X Y Z
         from T2 in it_t2 For All Entries in it_t1
              where A eq it_t1-A
                 and B eq it_t1-B
                 and C eq it_t1-C
    do processing........
    endselect
    This way, while using for all entries on T2, your it_t1, will have limited number of entries and thus the 2nd select will be faster.
    Thanks,
    Juwin

  • Performance Issue on Select Condition on KNA1 table

    Hi,
    I am facing problem when i am selecting from the table KNA1 for given account group and attribute9 it is taking lot of time .
    Please suggest the select query or any other feasible soln to solve this problem
    select
    kunnr
    kotkd
    from kna1
    where kunnr eq parameter value and
    kotkd eq 'ZPY' and katr9 = 'L' or 'T'.
    Firstly i am using in in katr9 then i removed dur to performance issue using read further please suggest further performanace soln

    Hi,
    The select should be like:
    select
    kunnr
    kotkd
    from kna1
    where kunnr eq parameter value
        and kotkd eq 'ZPY'
         and katr9 in r_katr9. "  'L' or 'T'.
    create a range for katr9 like r_katr9 with L or T.
    Because while selecting the entries from KNA1, it will check for KATR9 = L and then KATR9 = T.
    Hope the above statement is useful for you.
    Regards,
    Shiva.

  • Performance issue in Loop statement.

    Hi experts,
    I got an issue regarding performance in the loop statement. (IT_OUT_FINAL has huge amount of data.)
    LOOP AT it_out_final INTO wa_out_final.
    READ TABLE it_prdline_txt
    WITH KEY ydprodln = wa_out_final-prdline.
    IF sy-subrc = 0.
    wa_out_final-prdline = it_prdline_txt-ydvtext.
    MODIFY it_out_final FROM wa_out_final TRANSPORTING prdline.
    CLEAR: wa_out_final.
    ENDIF.
    read table i_sokna with key kunnr = wa_out_final-kunnr.
    if sy-subrc eq 0.
    wa_out_final-soreg = i_sokna-regio.
    MODIFY it_out_final FROM wa_out_final TRANSPORTING soreg.
    endif.
    read table i_sokna with key kunnr = wa_out_final-kunwe.
    if sy-subrc eq 0.
    wa_out_final-shreg = i_sokna-regio.
    MODIFY it_out_final FROM wa_out_final TRANSPORTING shreg.
    endif.
    clear : i_sokna,wa_out_final.
    ENDLOOP.
    Can you please help me , how to improve the performance in the above loop statement.
    Thanks,
    Revanth Kumar
    Moderator message: duplicate post locked.
    Edited by: Thomas Zloch on Jun 20, 2011 1:22 PM

    Hi,
    This one helped me in understanding the basics clearly. But I would like to further give you one example by which my question will be more clear to you and hence your further answer to it will help me in getting the idea about WHERE clause clarified.
    I was required to develop a report of all held docs by the SAP USER that were created through transaction FB60, the input obtained from user should be SAP USERNAME(obligatory).
    So the straight approach by me was that writing a SELECT-OPTIONS asking SAP USERNAME, and such username obtained from USER executing a report will be compared with the USERNAME stored in the column of table RFDT which stores all such held docs by a SAP USER that used transaction FB60 to temporarily hold it.
    So the approach used by me was using the select statement fetch all records from the column storing the SAP USERNAMES that have held docs using FB60 transaction and where clause is used to filter out only values matching the values obtained from user i.e. using SELECT-OPTIONS.
    So I was under the impression that WHERE clause can only be used in SELECT STATEMENT and not in LOOP AT...ENDLOOP.
    Now I hope my question is more clear to you. If I am not wrong, there can be two approaches,
    1) Using a SELECT statement containing the WHERE clause, fetch a resultset and then using LOOP...ENDLOOP. statement, display the output of the report using WRITE statement.
    i.e. SELECT...WHERE...ENDSELECT and then LOOP AT...ENDLOOP.
    2) Using SELECT statement, fetch all possible records and using LOOP...ENDLOOP. statement filter out the records using WHERE to match the resultset and display values in that resultset using WRITE statement
    i.e. SELECT...ENDSELECT and then LOOP AT...WHERE...ENDLOOP.
    Hope you will now be able to guide me better.
    Regards
    Ameet

  • Performance issue in select when subselect is used

    We have a select statement that is using a where clause that has dates in. I've simplified the SQL below to demonstrate roughly what it does:
    select * from user_activity
    where starttime >= trunc(sysdate - 1) + 18/24
    and starttime < trunc(sysdate) + 18/24
    (this selects records from a table where a starttime field has values beween 6pm today and 6pm yesterday).
    We are using this statement to create a materialized view which we refresh daily. Occasionally we have the need to refresh the data for a historic day, which means that we need to go in and change the where lines, e.g. to get data from 3 days ago instead of yesterday, the where clause becomes:
    select * from user_activity
    where starttime >= trunc(sysdate - 3) + 18/24
    and starttime < trunc(sysdate - 2) + 18/24
    Having to recreate the views like this is a nuisance, so we decided to be 'smart' and create a table with a setting in that we could use to control the number of days the view looks back. So if our table is called days_ago and field called days (with a single record, set to 1), we now have
    select * from user_activity
    where starttime >= trunc(sysdate - (select days from days_ago) + 18/24
    and starttime < trunc(sysdate - ((select days from days_ago) + 1) + 18/24
    The original SQL takes a few seconds to run. However the 'improved' version takes 25 minutes.
    The days table only has 1 record in, selecting directly from it is instantaneous. Running the select on its own.
    Does anything jump out as being daft in this approach? We cannot explain why the performance has suddenly dropped off for such a simple change.

    Hi,
    Do you really need a view to do this?
    Can't you define a bind varibale, and use it in your query:
    VARIABLE  days_ago   NUMBER
    EXEC     :days_ago := 3;
    SELECT      ...
    WHERE     starttime >= TRUNC (SYSDATE - :days_ago') + (18 / 24)
    AND     starttime <  TRUNC (SYSDATE - :days_ago') + (42 / 24)     -- 42 = 24 + 18If you really must have a view, then it might be faster if you got the parameter from a SYS_CONTEXT variable, rather than from a table.
    Unfortunately, SYS_CONTEXT always returns a string, so you have to be carefule encoding the number as a string when you set the variable, and decoding it when you use the variable:
    WHERE     starttime >= TRUNC (SYSDATE - TO_NUMBER ( SYS_CONTEXT ('MY_VIEW_NAMESPACE', 'DAYS_AGO'))) + (18 / 24)
    AND     starttime <  TRUNC (SYSDATE - TO_NUMBER ( SYS_CONTEXT ('MY_VIEW_NAMESPACE', 'DAYS_AGO'))) + (42 / 24)     -- 42 = 24 + 18For more about SYS_CONTEXT, look it up in the SQL language m,anual, and follow the links there:
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions172.htm#sthref2268
    If performance is important enough, consider storing the "fiscal day" as a separate (indexed) column. Starting in Oracle 11.1, you can use a virtual column for this. In earleir versions, you'd have to use a trigger. By "fiscal day", I mean:
    TRUNC (starttime + (6/24))If starttime is between 18:00:00 on December 28 and 17:59:59 on December 29, this will return 00:00:00 on December 29. You could use it in a query (or view) like this:
    WHERE     fiscal_day   = TRUNC (SYSDATE) - 2

  • Performance issue while selecting material documents MKPF & MSEG

    Hello,
    I'm facing performance issues in production while selecting Material documents for Sales order and item based on the Sales order Stock.
    Here is the query :
    I'm first selecting data from ebew table which is the Sales order Stock table then this query.
        IF ibew[] IS NOT INITIAL AND ignore_material_documents IS INITIAL.
    *     Select the Material documents created for the the sales orders.
          SELECT mkpf~mblnr mkpf~budat
                 mseg~matnr mseg~mat_kdauf mseg~mat_kdpos mseg~shkzg
                 mseg~dmbtr mseg~menge
           INTO  CORRESPONDING FIELDS OF TABLE i_mseg
           FROM  mkpf INNER JOIN mseg
           ON    mkpf~mandt = mseg~mandt
           AND   mkpf~mblnr = mseg~mblnr
           AND   mkpf~mjahr = mseg~mjahr
           FOR   ALL entries IN ibew
           WHERE mseg~matnr      = ibew-matnr
           AND   mseg~werks         = ibew-bwkey
           AND   mseg~mat_kdauf   = ibew-vbeln
           AND   mseg~mat_kdpos  = ibew-posnr.
          SORT i_mseg BY mat_kdauf ASCENDING
                         mat_kdpos ASCENDING
                         budat     DESCENDING.
        ENDIF.
    I need to select the material documents because the end users want to see the stock as on certain date for the sales orders and only material document lines can give this information. Also EBEW table gives Stock only for current date.
    For Example :
    If the report was run for Stock date 30th Sept 2008, but  on the 5th Oct 2008, then I need to consider the goods movements after 30th Sept and add if stock was issued or subtract if stock was added.
    I know there is an Index MSEG~M in database system on mseg, however I don't know the Storage location LGORT and Movement types BWART that should be considered, so I tried to use all the Storage locations and Movement types available in the system, but this caused the query to run even slower than before.
    I could create an index for the fields mentioned in where clause , but it would be an overhead anyways.
    Your help will be appreciated. Thanks in advance
    regards,
    Advait

    Hi Thomas,
    Thanks for your reply. the performance of the query has significantly improved than before after switching the join from mseg join mkpf.
    Actually, I even tried without join and looped using field symbols ,this is working slightly faster than the switched join.
    Here are the result ,  tried with 371 records as our sandbox doesn't have too many entries unfortunately ,
    Results before switching the join  146036 microseconds
    Results after swithing the join        38029 microseconds
    Results w/o join                           28068 microseconds for selection and 5725 microseconds for looping
    Thanks again.
    regards,
    Advait

  • Performance Issue with Selection Screen Values

    Hi,
    I am facing a performance issue(seems like a performance issue ) in my project.
    I have a query with some RKFs and sales area in filters (single value variable which is optional).
    Query is by default  restricted by current month.
    The Cube on which the query operates has around 400,000 records for a month.
    The Cube gets loaded every three hours
    When I run the query with no filters I get the output within 10~15 secs.
    The issue I am facing is that,  when I enter a sales area in my selection screen the query gets stuck in the data selection step. In fact we are facing the same problem if we use one or two other characteristics in our selection screen
    We have aggregates/indexes etc on our cube.
    Has any one faced a similar situation?
    Does any one have any comments on this ?
    Your help will be appreciated. Thanks

    Hi A R,
    Goto RSRT--> Give ur query anme --> Execute =Debug
    --> No a pop up ill come with many check boxes select "Display Aggregates found" option --> now give ur
    selections in variable screen > first it will give the already existing aggregate names> continue> now after displaying all the aggregates it will display the list of objects realted to cube wise> try to copy these objects into notepad> again go with ur drill downs now u'll get the already existing aggregates for this drill down-> it will display the list of objects> copy them to notepad> now sort all the objects related to one cube by deleting duplicate objects in the note pad>goto that Infocube> context>maintain aggregates> create aggregate on the objects u copied into note pad.
    now try to execyte the report... it should work properly with out delays for those selections.
    I hope it helps you...
    Regards,
    Ramki.

  • Time issue of select statement

    Hi friends,
       I have a doubt about select single statement in this particular statement below.
    i have the code which goes this way.
    loop at itab.
    concatenate *year *materail no * item type into dummy variable.
    select single dmbtr from bsis into itab-dmbtr where xref3 = dummy variable and belnr = itab-migodoc and gjahr = itab-mjahr and hkont = '0000123'.
    clear dummy variable.
    modify itab.
    endloop.
    the bsis table has around 4,000,000 records.
    The report when executed goes smoothly till the point where the above select statement is encountered.
    my question is does it take time to execute because of so many records ?
    If not then why dies it take a lot of time to execute a single select statement ? 
    and how can i optimise the time consumed by this select query or report. ?
    Thank you.
    Moderator message: please understand the basic concept of using primary or secondary indexes in your queries, you will sure find the missing field in your where-clause, read the sticky threads of this forum.
    Edited by: Thomas Zloch on Nov 20, 2010 5:31 PM

    Hi Vivek,
    Data volume definitely gives impact on SQL.
    Don't use sql inside the loop, it will decrease the performance.
    Year material no. and item type may have duplicate entries. filter that. It may also gives impact on performance.
    Write a single Select query.
    Instead of fetching the data at once use packet size.
    http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP4TuningChecklist
    Regards,
    Sudha
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:42 PM
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:48 PM
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:51 PM

  • Performance in the select statement

    Hi All,
    (select a.siteid siteid,a.bpaadd_0 bpaadd_0,a.bpanum_0 bpanum_0,
    case when a.bpaaddlig_0 = '' then '-' else a.bpaaddlig_0 end
    address1,
    case when a.bpaaddlig_1 = '' then '-' else a.bpaaddlig_1 end
    address2,
    case when a.bpaaddlig_2 = '' then '-' else a.bpaaddlig_2 end
    address3,
    case when a.bpades_0 = '' then '-' else a.bpades_0 end place,
    case when a.cty_0 = '' then '-' else a.cty_0 end city,
    case when a.poscod_0 = '' then '-' else a.poscod_0 end
    pincode,
    case when b.cntnam_0 = '' then '-' else b.cntnam_0 end
    contactname,
    case when b.fax_0 = '' then '-' else b.fax_0 end fax,
    case when b.MOBTEL_0 = '' then '-' else b.MOBTEL_0 end mobile,
    case when b.TEL_0 = '' then '-' else b.TEL_0 end phone,
    case when b.web_0 = '' then '-' else b.web_0 end website,
    c.zinvcty_0 zcity,c.bpainv_0 bpainv_0,c.bpcnum_0 bpcnum_0
    from lbcreport.bpaddress@info a,lbcreport.contact@info b
    ,lbcreport.bpcustomer@info c
    where (a.bpanum_0=b.bpanum_0) and (a.cty_0 = c.zinvcty_0) and
    (a.siteid = c.siteid))
    In the above query Is there any performance degradation could i proceed with same query
    or any other solution is there to increase the speed of the query.
    in one select statement these many cases are allowed ah?
    Please could anybody help me in this?
    Thanks in advance
    bye
    Srikavi

    Change you query as follows...
    (select
         a.siteid siteid,
         a.bpaadd_0 bpaadd_0,
         a.bpanum_0 bpanum_0,
         nvl(a.bpaaddlig_0, '-') address1,
         nvl(a.bpaaddlig_1,'-' ) address2,
         nvl(a.bpaaddlig_2,'-' )  address3,
         nvl(a.bpades_0,'-' ) place,
         nvl(a.cty_0,'-' ) city,
         nvl(a.poscod_0,'-' ) pincode,
         nvl(b.cntnam_0,'-' ) end
         contactname,
         nvl(b.fax_0,'-' )  fax,
         nvl(b.MOBTEL_0,'-' )  mobile,
         nvl(b.TEL_0,'-' )  phone,
         nvl(b.web_0,'-' )  website,
         c.zinvcty_0 zcity,c.bpainv_0 bpainv_0,c.bpcnum_0 bpcnum_0
    from
         lbcreport.bpaddress@info a,
         lbcreport.contact@info b,
         lbcreport.bpcustomer@info c
    where
         (a.bpanum_0=b.bpanum_0) and
         (a.cty_0 = c.zinvcty_0) and
         (a.siteid = c.siteid))
    / For performace check the execution plan of the query.. also BluShadow's post
    Regards
    Singh

  • Performance wise, a select statement is faster on a view or on a table??

    Performance wise, a complex (with multi join) select statement is faster on a view or on a table??

    Hi,
    the purpose of a view is not to provide performance benefits, it's basically a way to better structure database code and data access. A view is nothing but a stored query. When the optimizer sees references to a view in a query, it tries to merge it (i.e. replace the view with its definition), but it some cases it may be unable to do so (in presence of analytic functions, rownum pseudocolumn etc.) -- in such cases views can lead to a performance degradation.
    If you are interested in performance, what you need is a materialized view, which is basically a table built from a query, but then you need to decide how you would refresh it. Please refer to the documentation for details.
    Best regards,
    Nikolay

  • Performance issue with select query

    Hi friends ,
    This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
    *- Get the Goods receipts  mainly selected per period (=> MKPF secondary
      SELECT msegebeln msegebelp mseg~werks
             ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
             ekkoinco1 ekkoexnum
             lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
             mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
             mseg~bwart
    *Start of changes for CIP 6203752 by PGOX02
             mseg~smbln
    *End of changes for CIP 6203752 by PGOX02
             ekpomatnr ekpotxz01 ekpomenge ekpomeins
             ekbemenge ekbedmbtr ekbewrbtr ekbewaers
             ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
             ekpoplifz ekpobstae
             INTO TABLE it_temp
        FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
                           AND msegmjahr EQ mkpfmjahr
                  JOIN ekbe ON ekbeebeln EQ msegebeln
                           AND ekbeebelp EQ msegebelp
                           AND ekbe~zekkn EQ '00'
                           AND ekbe~vgabe EQ '1'
                           AND ekbegjahr EQ msegmjahr
                           AND ekbebelnr EQ msegmblnr
                           AND ekbebuzei EQ msegzeile
                  JOIN ekpo ON ekpoebeln EQ ekbeebeln
                           AND ekpoebelp EQ ekbeebelp
                  JOIN ekko ON ekkoebeln EQ ekpoebeln
                  JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
        WHERE mkpf~budat IN so_budat
          AND mkpf~bldat IN so_bldat
          AND mkpf~vgart EQ 'WE'
          AND mseg~bwart IN so_bwart
          AND mseg~matnr IN so_matnr
          AND mseg~werks IN so_werks
          AND mseg~lifnr IN so_lifnr
          AND mseg~ebeln IN so_ebeln
          AND ekko~ekgrp IN so_ekgrp
          AND ekko~bukrs IN so_bukrs
          AND ekpo~matkl IN so_matkl
          AND ekko~bstyp IN so_bstyp
          AND ekpo~loekz EQ space
          AND ekpo~plifz IN so_plifz.
    Thanks & Regards,
    Manoj Kumar .Thatha
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
    Edited by: Rob Burbank on Feb 4, 2010 9:03 AM

    Hi friends ,
    This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
    *- Get the Goods receipts  mainly selected per period (=> MKPF secondary
      SELECT msegebeln msegebelp mseg~werks
             ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
             ekkoinco1 ekkoexnum
             lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
             mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
             mseg~bwart
    *Start of changes for CIP 6203752 by PGOX02
             mseg~smbln
    *End of changes for CIP 6203752 by PGOX02
             ekpomatnr ekpotxz01 ekpomenge ekpomeins
             ekbemenge ekbedmbtr ekbewrbtr ekbewaers
             ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
             ekpoplifz ekpobstae
             INTO TABLE it_temp
        FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
                           AND msegmjahr EQ mkpfmjahr
                  JOIN ekbe ON ekbeebeln EQ msegebeln
                           AND ekbeebelp EQ msegebelp
                           AND ekbe~zekkn EQ '00'
                           AND ekbe~vgabe EQ '1'
                           AND ekbegjahr EQ msegmjahr
                           AND ekbebelnr EQ msegmblnr
                           AND ekbebuzei EQ msegzeile
                  JOIN ekpo ON ekpoebeln EQ ekbeebeln
                           AND ekpoebelp EQ ekbeebelp
                  JOIN ekko ON ekkoebeln EQ ekpoebeln
                  JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
        WHERE mkpf~budat IN so_budat
          AND mkpf~bldat IN so_bldat
          AND mkpf~vgart EQ 'WE'
          AND mseg~bwart IN so_bwart
          AND mseg~matnr IN so_matnr
          AND mseg~werks IN so_werks
          AND mseg~lifnr IN so_lifnr
          AND mseg~ebeln IN so_ebeln
          AND ekko~ekgrp IN so_ekgrp
          AND ekko~bukrs IN so_bukrs
          AND ekpo~matkl IN so_matkl
          AND ekko~bstyp IN so_bstyp
          AND ekpo~loekz EQ space
          AND ekpo~plifz IN so_plifz.
    Thanks & Regards,
    Manoj Kumar .Thatha
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
    Edited by: Rob Burbank on Feb 4, 2010 9:03 AM

  • IF-ELSE issue in Select Statement

    Hello,
    I have following query in SQL Server which I am trying to convert to Oracle 11g.
    IF '[Param.1]' = 'S' OR '[Param.1]' = 'T' THEN
    select * from ULQUEUE
    END IF
    But when I write the same query in Oracle, it gives error stating Invalid SQL Statement. So how do I incorporate IF-ELSE in Select Statement in Oracle?
    Edited by: 967327 on Oct 31, 2012 2:01 PM

    Hi,
    First of all, remove asterisk sign from the end of line
    select * from ULQUEUE;* Second: where you try to put this code? This is not SQL, but PL\SQL so you have to have some variable where you want to put query result like this:
    declare
    x ULQUEUE%Rowtype;
    begin
    select *
    into    x
    from ULQUEUE
    end; This of course works when your query returns only one row. Otherwise process data in the loop or put result into array.

  • Performance issue when selection LIPS table into program.

    Hi expert,
    I have created Pending sales order report , in that i am facing performance problem for selection of LIPS table.
    i have tried to use VLPMA table but performance has not been improved so, is their any need to create secondary index and
    if yes then which fields of lips table i have to includes in index.
    Please reply.
    Regards,
    Jyotsna

    >
    UmaDave wrote:
    > Hi ,
    > 1.Please make use of PACKAGE in your select query , it will definetly improve the performance.
    > 2.Please use the primary index by passing the fields in where clause in the order in which they appera in LIPS table.
    > 3.You can also create a secondary index with the fields which you are using in where clause of select query and maintain the fields in the same sequence (where clause and secondary index)
    > 4.If there is any inner joins (more than 3) then reduce them and have few mare select queries for them and make use of for all entries.   
    >
    > This will definitely improve the performance to great extend.
    >
    > Hope this is helpful.
    > Regards,
    > Uma
    Please do some more research before offering advice:
    PACKAGE SIZE is for memory management, not performance.
    Creating a secondary index is using a hammer to swat a fly and the order in the SELECT is not relevant.
    FAE does not improve performance over a JOIN.
    Rob

  • Performance issue in 'Selelect statement with for all entries'

    Hi,
      The following SELECT statement is taking too much time.
             SELECT * FROM /rb04/yc5_mver
             INTO TABLE g_it_mver
             FOR ALL ENTRIES IN l_it_inva
             WHERE matnr EQ l_it_inva-matnr  AND
                          werks EQ l_it_inva-werks  AND
                          indei EQ l_it_inva-indei  AND
                          gjahr IN g_r_gjahr.
         Internal table l_it_inva is having too many records.
        Is there any way to optimize it.
    Regards,
    Tintu

    Hi Tintu,
    check table  l_it_inva for initial.
    sort internal table  l_it_inva with key  matnr werks indei gjahr.
    delete adjacent duplicates from  l_it_inva comparing   matnr werks indei gjahr.
    Then use following select query.
    SELECT * FROM /rb04/yc5_mver
    INTO TABLE g_it_mver
    FOR ALL ENTRIES IN l_it_inva
    WHERE matnr EQ l_it_inva-matnr AND
    werks EQ l_it_inva-werks AND
    indei EQ l_it_inva-indei AND
    gjahr IN g_r_gjahr.
    Regards,
    Vijay

  • Performance required in select statement

    hi gurus,
    my select statement below is taking around 15 sec to execute, need your help in this regard.
    select single * from tablename where no = itab-no.
    Thanks,
    vj

    VIQMEL is not a table itself - it is a view of tables QMIH, QMEL and ILOA.
    the field you are searching on (EQFNR) is a non-key field on table ILOA which is not an index field either.
    This will be very slow depending on the size of the tables.
    Is there any other data you can use to search by?  perhaps it would be quicker to get extra key data for this view by reading some other tables first?
    If not, you may need to add an index to ILOA for this field - I would check with SAP as adding indexes to standard tables such as this which already appears to have several indexes may have unforseen impacts on standard processing.  Generally it is all right, but an extra index for the system to maintain can cause problems sometimes.

Maybe you are looking for

  • 110 vs 220 Power - Apple Display Connector

    I recently moved from a 220V power country to a 110V power country. My 2008 Quadcore MacPro switched over no problem, everything worked fine. My older 2.0Ghtz MacPro has two problems: 1. The fans run highspeed within minutes of turning it on. Very no

  • SAP PP AFS solution configuration

    Dear Friends Can i have any complete  PP configuration steps for SAP AFS solution? Thanks A N M Jamal

  • Can i use debit card on itunes store?

    I'm from Malaysia. According to the topic, i just got myself a BSN VISA debit card. Can i use it on apple store to purchase apps?

  • How to migrate the Objects from 3.1c to BI7

    Hi, We are in Functional Upgradation. How to Migrate the Objects( Infocubes,DSO,Datasources,Rules...etc...) from 3.1C to BI 7.0 Please help me to doing this.... regards, anil

  • Multipart mime in XI for attachments?

    Hi, I am not big on all the terminology, so please me nice But in a discussion for B2B with a marketplace, the subject of recieving attachments came up and he asked if we could accept our attachments in Multipart mime. Now I know Binary and text of t