Select statemnet takes long time

Hello Experts,
My select query takes a long time to give its output when I select and order type say PM15.
It gives me the return message but takes a long time.
Is there any other possibility to get output much faster.
SELECT a~aufnr
       a~auart
       a~objnr
       a~werks
       b~stat INTO CORRESPONDING FIELDS OF TABLE itab1
              FROM aufk AS A JOIN jest AS B
              ON a~objnr EQ b~objnr
              WHERE a~aufnr IN  s_aufnr
              AND  a~auart in s_auart
              AND A~werks IN S_IWERK
              AND b~inact EQ  ' '.                     "can set incat = space(Active) OR incat = 'X'(Not Active)
SELECT a~aufnr
       a~auart
       a~objnr
       a~werks
       b~stat INTO CORRESPONDING FIELDS OF TABLE itab
              FROM aufk AS A JOIN jest AS B
              ON a~objnr EQ b~objnr
              WHERE a~aufnr IN  s_aufnr
              AND  a~auart in s_auart
              AND A~werks IN S_IWERK
              AND b~stat  IN  ('I0002','I0340').
READ TABLE ITAB INDEX 1.
refresh: T_METH.
  clear: T_METH.
  clear :wa_meth.
sort itab.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING AUFNR.
LOOP AT ITAB.
  wa_meth-refnumber     = 1.
  wa_meth-objecttype    = 'HEADER'.
  wa_meth-method        = 'ATPCHECK'.
  wa_meth-objectkey(12) = ITAB-AUFNR.
*  wa_meth-objectkey(12) = ITAB-OBJNR.
  append  wa_meth to t_meth.
  clear  wa_meth.
   wa_meth-refnumber     = 1.
   wa_meth-method        = 'SAVE'.
   wa_meth-objectkey(12) = ITAB-AUFNR.
*   wa_meth-objectkey(12) = ITAB-OBJNR.
  append  wa_meth to t_meth.
  call function 'BAPI_ALM_ORDER_MAINTAIN'
      tables
      it_methods   = T_METH
      return       = T_RET.
  call function 'BAPI_TRANSACTION_COMMIT'.
LOOP AT T_RET.
write:/ T_RET-MESSAGE.
EXIT.
ENDLOOP.
ENDLOOP.
Thanks and Regrds,
Nikhil.

You can neglect the second query by pulling the values in first query itself
  SELECT a~aufnr
       a~auart
       a~objnr
       a~werks
       b~stat
       b~inact "New Addition
              INTO CORRESPONDING FIELDS OF TABLE itab1
              FROM aufk AS A JOIN jest AS B
              ON a~objnr EQ b~objnr
              WHERE a~aufnr IN  s_aufnr
              AND  a~auart  in s_auart
              AND A~werks  IN S_IWERK.
              "AND b~inact EQ  ' '.  removed.
  now the itab1 will consists of inact EQ  ' ' and b~stat  IN  ('I0002','I0340').
  try to process the internal table.
  Dont know how far it will help you

Similar Messages

  • SELECT statement takes long time

    Hi All,
    In the following code, if the T_QMIH-EQUNR contains blank or space values ,SELECT statement takes longer time to acess the data from OBJK table. If it T_QMIH-EQUNR contains values other than blank, performance is good and it fetches data very fast.
    Already we have indexes for EQUNR in OBJK table.
    Only for blank entries , it takes much time.Can anybody tell why it behaves for balnk entries?
    if not T_QMIH[] IS INITIAL.
            SORT T_QMIH BY EQUNR.
            REFRESH T_OBJK.
            SELECT EQUNR OBKNR
              FROM OBJK INTO TABLE T_OBJK
              FOR ALL ENTRIES IN T_QMIH
              WHERE OBJK~TASER = 'SER01' AND
             OBJK~EQUNR = T_QMIH-EQUNR.
    Thanks
    Ajay

    Hi
    You can use the field QMIH-QMNUM with OBJK-IHNUM
    in QMIH table, EQUNR is not primary key, it will have multiple entries
    so to improve the performance use one dummy internal table for QMIH  and sort it on EQUNR
    delete adjacent duplicates from d_qmih and use the same in for all entries
    this will improve the performance.
    Also use the fields in sequence of the index and primary keys also in select
    if not T_QMIH[] IS INITIAL.
    SORT T_QMIH BY EQUNR.
    REFRESH T_OBJK.
    SELECT EQUNR OBKNR
    FROM OBJK INTO TABLE T_OBJK
    FOR ALL ENTRIES IN T_QMIH
    WHERE  IHNUM =  T_QMIH-QMNUM
    OBJK~TASER = 'SER01' AND
    OBJK~EQUNR = T_QMIH-EQUNR.
    try this and let me know
    regards
    Shiva

  • BEx query selection screen takes long time to popup

    Hi,
    I have a query which is taking long time to popup the selection screen. I have tried in RSRT the generate report option, the generating report takes 45 to 60 mins. After the report is generated the query selection screen comes up in couple of seconds. The first time I run the query everything its fine but then for the second time the problem comes back again.
    The selection screen takes +/- 40 mins to comes up in RSRT and in the portal it times out.
    I have run the statistics of the query and according to the statistics report the query takes a  lot of time for the following component :
    OLAP: Query Gen.     2681,312682
    I have removed the query from the cache monitor and after that regenerate the report. But these steps didnu2019t solve my problem.
    I made two test queries, in one query I have made the CKFu2019s and RKFu2019s directly at the infoprovider, and dragged and dropped in the KF structure. In the other query I made the CKFu2019s and RKFu2019s in the query KF structure itself. The query where I have the CKFu2019s and RKFu2019s at the infoprovider that query times out, the other query where I put the CKFu2019s and RKFu2019s in the query KF structure doesn't has this performance problem.
    What I donu2019t know is why the query is failing when I use RKFu2019s and CKFu2019s from the infoprovider, the other query donu2019t have this problem.
    Please advise how to proceed.
    Thanks in advance,
    Arash

    Hi,
    Please check the following notes which should be useful.
    1387593 - Performance optimization for query change/generation
    1416737 - Performance optimization for query change/generation(2)
    1396485 - Performance optimization for query check/save
    Then please execute the SE38 report ANALYZE_RSZ_TABLES (see notes
    1472915, 1506560) and repair/correct the different tables to optmize
    the query definition tables.
    Regards,
    Amit

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

  • Select query takes long time....

    Hi Experts,
    I am using a select query in which inspection lot is in another table and order no. is in another table. this select query taking very long time, what is the problem in this query ? Pl. guide us.
    select bPRUEFLOS bMBLNR bCPUDT aAUFNR amatnr aLGORT a~bwart
    amenge aummat asgtxt axauto
    into corresponding fields of table itab
    *into table itab
    from mseg as a inner join qamb as b
    on amblnr = bmblnr
    and azeile = bzeile
    where b~PRUEFLOS in insp
    and  b~cpudt in date1
    and b~typ = '3'
    and a~bwart = '321'
    and a~aufnr in aufnr1.
    Yusuf

    hi
    instead of using 'move to corresponding of itab'  fields use  'into table itab'.....
    coz......if u use move to corresponding it will search for all the appropriate fields then it will place u r data........instead of that declare apprpiate internal table and use 'into table itab'.
    and one more thing dont use joins ......coz joins will decrease u r performance .....so instead of that use 'for all entries' ....and mention all the key fields in where condition ........
    ok
    reward points for helpful answers

  • Select query take long time

    Hi All.
    When i execute select query from View it takes about 00:00:45:12 sec to pull the data , but when i execute same query in some other system(different database with same table structure) it takes about 00:00:02:05 sec.
    1)I have tried by dropped and recreated the index then i tried by exec dbms_stats.gather_table_stats procedure still no luck.
    Please help me to understand the reason difference in response time
    Thanks
    sankar

    did you run the EXPLAIN PLAN?

  • Drop Down List in Query Selection Screen Takes Long Time.

    I open a report, refresh the query and get a selection screen. But when clicked on the drop down list it takes 4- 5 mins for displaying the drop down options.
    How can I speed up the displaying of drop down list in selection screen?
    Could any one please help regarding the setting to enable this?
    Thanks.

    Hi,
    I guess there is a setting to look up the master data tables or use the dimension,which would speed up the time that it takes to display the drop down selections
    Do you have any idea about the setting?
    Thanks.

  • INSERT INTO TABLE using SELECT takes long time

    Hello Friends,
    --- Oracle version 10.2.0.4.0
    --- I am trying to insert around 2.5 lakhs records in a table using INSERT ..SELECT. The insert takes long time and seems to be hung.
    --- When i try to SELECT the query fetches the rows in 10 seconds.
    --- Any clue why it is taking so much time

    vishalrs wrote:
    Hello Friends,hello
    >
    >
    --- Oracle version 10.2.0.4.0
    alright
    --- I am trying to insert around 2.5 lakhs records in a table using INSERT ..SELECT. The insert takes long time and seems to be hung.
    I don't know how a lakh is, but it sounds like a lot...
    --- When i try to SELECT the query fetches the rows in 10 seconds.
    how did you test this? and did you fetch the last record, or just the first couple of hundred.
    --- Any clue why it is taking so much timeWithout seeing anything, it's impossible to tell the reason.
    Search the forum for "When your query takes too long"

  • CV04N takes long time to process select query on DRAT table

    Hello Team,
    While using CV04N to display DIR's, it takes long time to process select query on DRAT table. This query includes all the key fields. Any idea as to how to analyse this?
    Thanks and best regards,
    Bobby
    Moderator message: please read the sticky threads of this forum, there is a lot of information on what you can do.
    Edited by: Thomas Zloch on Feb 24, 2012

    Be aware that XP takes approx 1gb of your RAM leaving you with 1gb for whatever else is running. MS Outlook is also a memory hog.
    To check Virtual Memory Settings:
    Control Panel -> System
    System Properties -> Advanced Tab -> Performance Settings
    Performance Options -> Adavanced Tab - Virtual Memory section
    Virtual Memory -
    what are
    * Initial Size
    * Maximum Size
    In a presentation at one of the Hyperion conferences years ago, Mark Ostroff suggested that the initial be set to the same as Max. (Max is typically 2x physical RAM)
    These changes may provide some improvement.

  • MVIEW refresh takes long time

    Materialized view takes long time to refresh but when i tried select & insert into table it's very fast.
    i executed SQL and it takes ust 1min ( total rows is 447 )
    but while i refresh the MVIEW it takes 1.5 hrs ( total rows is 447 )
    MVIEW configration :-
    CREATE MATERIALIZED VIEW EVAL.EVALSEARCH_PRV_LWC
    TABLESPACE EVAL_T_S_01
    NOCACHE
    NOLOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD DEFERRED
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY
    Not sure why so much diffrence

    infant_raj wrote:
    Materialized view takes long time to refresh but when i tried select & insert into table it's very fast.
    i executed SQL and it takes ust 1min ( total rows is 447 )
    but while i refresh the MVIEW it takes 1.5 hrs ( total rows is 447 )A SELECT does a consistent read.
    A MV refresh does that and also writes database data.
    These are not the same thing and cannot be directly compared.
    So instead of pointing at the SELECT execution time and asking why the MV refresh is not as fast, look instead WHAT the refresh is doing and HOW it is doing that.
    Is the execution plan sane? What events are the top ones for the MV refresh? What are the wait states that contributes most to the processing time of the refresh?
    You cannot use the SELECT statement's execution time as a direct comparison metric. The work done by the refresh is more than the work done by the SELECT. You need to determine exactly what work is done by the refresh and whether that work is done in a reasonable time, and how other sessions are impacting the refresh (it could very well be blocked by another session).

  • Takes Long time for Data Loading.

    Hi All,
    Good Morning.. I am new to SDN.
    Currently i am using the datasource 0CRM_SRV_PROCESS_H and it contains 225 fields. Currently i am using around 40 fields in my report.
    Can i hide the remaining fields in the datasource level itself (TCODE : RSA6)
    Currently data loading takes more time to load the data from PSA to ODS (ODS 1).
    And also right now i am pulling some data from another ODS(ODS 2)(LookUP). It takes long time to update the data in Active data table of the ODS.
    Can you please suggest how to improve the performance of dataloading on this Case.
    Thanks & Regards,
    Siva.

    Hi....
    Yes...u can hide..........just Check the hide box for those fields.......R u in BI 7.0 or BW...........whatever ........is the no of records is huge?
    If so u can split the records and execute............I mean use the same IP...........just execute it with different selections.........
    Check in ST04............is there are any locks or lockwaits..........if so...........Go to SM37 >> Check whether any Long running job is there or not.........then check whether that job is progressing or not............double click on the Job >> From the Job details copy the PID..............go to ST04 .....expand the node............and check whether u r able to find that PID there or not.........
    Also check System log in SM21............and shortdumps in ST04........
    Now to improve performance...........u can try to increase the virtual memory or servers.........if possiblr........it will increase the number of work process..........since if many jobs run at a time .then there will be no free Work prrocesses to proceed........
    Regards,
    Debjani......

  • The 0co_om_opa_6 ip in the process chains takes long time to run

    Hi experts,
    The 0co_om_opa_6 ip in the process chains takes long time to run around 5 hours in production
    I have checked the note 382329,
    -> where the indexes 1 and 4 are active
    -> index 4 was not "Index does not exist in database system ORACLE"- i have assgined to " Indexes on all database systems and ran the delta load in development system, but guess there are not much data in dev it took 2-1/2 hrs to run as it was taking earlier. so didnt find much differnce in performance.
    As per the note Note 549552 - CO line item extractors: performance, i have checked in the table BWOM_SETTINGS these are the settings that are there in the ECC system.
    -> OLTPSOURCE -  is blank
       PARAM_NAME - OBJSELSIZE
       PARAM_VALUE- is blank
    -> OLTPSOURCE - is blank
       PARAM_NAME - NOTSSELECT
       PARAM_VALUE- is blank
    -> OLTPSOURCE- 0CO_OM_OPA_6
       PARAM_NAME - NOBLOCKING
       PARAM_VALUE- is blank.
    Could you please check if any other settings needs to be done .
    Also for the IP there is selction criteris for FISCALYEAR/PERIOD from 2004-2099, also an inti is done for the same period as a result it becoming difficult for me to load for a single year.
    Please suggest.

    The problem was the index 4 was not active in the database level..it was recommended by the SAP team to activate it in se14..however while doing so we face few issues se14 is a very sensitive transaction should be handled carefully ... it should be activate not created.
    The OBJSELSIZE in the table BWOM_SETTINGS has to be Marked 'X' to improve the quality as well as the indexe 4 should be activate at the abap level i.e in the table COEP -> INDEXES-> INDEX 4 -> Select the  u201Cindex on all database systemu201D in place of u201CNo database indexu201D, once it is activated in the table abap level you can activate the same indexes in the database level.
    Be very carefull while you execute it in se14 best is to use db02 to do the same , basis tend to make less mistake there.
    Thanks Hope this helps ..

  • Database Connectivity takes long time if one of the Node is down .. ??

    Hello All,
    Env: 10.2.0.4 on Solaris 10
    I have 2 nodes.
    When Node1 server is down, it takes long time to connec to the database.
    tnsping would give "OK(2050ms)". Below is the tnsalias.
    RAC_test  =
      (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST=20.268.169.123)(PORT= 1521))
         (ADDRESS = (PROTOCOL = TCP)(HOST=20.268.169.127)(PORT= 1521))
         (LOAD_BALANCE = yes)
              (CONNECT_DATA =
            (SERVICE_NAME = DK.com)
          (FAILOVER_MODE =
            (TYPE = SELECT)
            (METHOD = BASIC)
            (RETRIES = 180)
            (DELAY = 5)
    )I put the trace on sqlnet.ora and found that first it pings to the "20.268.169.123",
    since the Server is down there will not be any reply and this consumes the delay and
    later it would ping "20.268.169.127" and connect to it.
    If i keep "20.268.169.127" above "20.268.169.123" in tnsalias, and keep "LOAD_BALANCE=no",
    it gets connected very fast, as its directly connecting to Node2. In tnsping i get Ok(40ms).
    How do i reduce the connect timing if i use the first step. Why does it take long time for
    Oracle Client to understand that the Node1 Server is down ?
    TIA,
    J J

    I hope the IP's you are using in the TNS are Virtual IP's.
    You must use Virtual IP's / hostnames for the failover to be quick. If Node 1 is not available then then it's (Node 1's) virtual IP would also get assigned to Node 2 hence all client connections are still able to get a response from the Node Virtual IP address without needing to wait for TCP/IP timeouts. This helps clients to get notified immediately that node 1 is unavailable and the connection tries the 2nd ip/host in the connect descriptor.
    Hope this helps.
    - Siba

  • SSRS 2012. ReportServer takes long time to be up.

    SSRS 2012 Sp1
    Hi guys,
    I am using SSRS as my reporting platform, but I have always got the following issue.
    SSRS ReportServer takes time to load.
    The first time takes long, then less time but only if the ReprotServer web page is continuosly retrived.
    HERE the problem:
    If the ReprotServer page is not used after a short time (let me say 10 min), the page takes long time to be up again.
    I have checked the configuration that is set as for default 12 hours.
    Is there a way to speed up the ReportServer opening page time?
    Thanks for your help 

    Hi Fasttrack2,
    According to your description, you want to optimize the performance of your report. Right?
    In this scenario, when your report page is not active for a short time, it will take long time to render again. This is because the you have the report timeout. You can select "Do not timeout report" in Processing. Please refer to the link below:
    SQL Server Reporting Services – Timeout Settings
    For the performance issue, it can be many reason cause the report running slowly. Please refer to the articles below to optimize the report:
    More tips to improve performance of SSRS reports.
    Reporting Services Performance and Optimization
    Troubleshooting Reports: Report Performance
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Why update query takes  long time ?

    Hello everyone;
    My update query takes long time.  In  emp  ( self testing) just  having 2 records.
    when i issue update query , it takes long time;
    SQL> select  *  from  emp;
      EID  ENAME     EQUAL     ESALARY     ECITY    EPERK       ECONTACT_NO
          2   rose              mca                  22000   calacutta                   9999999999
          1   sona             msc                  17280    pune                          9999999999
    Elapsed: 00:00:00.05
    SQL> update emp set esalary=12000 where eid='1';
    update emp set esalary=12000 where eid='1'
    * ERROR at line 1:
    ORA-01013: user requested cancel of current operation
    Elapsed: 00:01:11.72
    SQL> update emp set esalary=15000;
    update emp set esalary=15000
      * ERROR at line 1:
    ORA-01013: user requested cancel of current operation
    Elapsed: 00:02:22.27

    Hi  BCV;
    Thanks for your reply but it doesn't provide output,  please  see   this.
    SQL> update emp set esalary=15000;
    ........... Lock already occured.
    >> trying to trace  >>
    SQL> select HOLDING_SESSION from dba_blockers;
    HOLDING_SESSION
                144
    SQL> select sid , username, event from v$session where username='HR';
    SID USERNAME     EVENT
       144   HR    SQL*Net message from client
       151   HR    enq: TX - row lock contention
       159   HR    SQL*Net message from client
    >> It  does n 't  provide  clear output about  transaction lock >>
    SQL> SELECT username, v$lock.SID, TRUNC (id1 / POWER (2, 16)) rbs,
      2  BITAND (id1, TO_NUMBER ('ffff', 'xxxx')) + 0 slot, id2 seq, lmode,
      3  request
      4  FROM v$lock, v$session
      5  WHERE v$lock.TYPE = 'TX'
      6  AND v$lock.SID = v$session.SID
      7  AND v$session.username = USER;
      no rows selected
    SQL> select MACHINE from v$session where sid = :sid;
    SP2-0552: Bind variable "SID" not declared.

Maybe you are looking for

  • How can I remove items from the open a recent file menue.

    How can I remove items from the "Open a Recent File" menue. Many other applications allow the clearing of that file . Is this possible in Adobe Reader 10.1.2 ? If so how?

  • How can we  prevent the PO while creating the sales order

    Hi All, How can we prevent the PO number while creating sales order with existing PO. I have checked the box in sales document type as A but still im able to create sales order with same PO. Thanks in advance. Naveen

  • J2ME Help required (URGENT !!!)

    Hello everyone, Well I'm a newbie to this J2ME thing, I am working on a project right now which requires me to develop an application for my mobile phone Sony Ericsson W810i. This application accesses the on board camera and take images after every 1

  • Problem while exporting internal table to memory id using EXPORT

    Hi friends, Iam facing a following problem. I have 4 line items in my va01 tcode. now when i give material number and quantity and hit enter the processing for that line item starts. iam moving that current line item to a internal table lt_vbap in us

  • Adobe Reader Add-in Crashing IE 9 CRM Dynamics 2013

    All, So basically we are upgrading to CRM 2013 for Microsoft Dynamics. Some users who have IE 9, company default, when they try to get to the CRM dynamics server in IE 9, it crashes. Microsoft determined that the Adobe Reader Add - In was causing it