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

Similar Messages

  • 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

  • DELETE Statement takes long time running

    Hi,
    DELETE statements take a very long time to complete.
    Can you advice me how can I diagnostic the slow performance
    Thanks

    Deleting rows can be an expensive operation.
    Oracle stores entire row as the 'before image' of deleted information (table and index data) in
    rollback segments, generates redo (keeps archiver busy), updates free lists for blocks that are
    falling below PCTUSED setting etc..
    Select count(*) runs longer because oracle scans all blocks (upto the High Water Mark) whether
    there are or are not any rows in the blocks.
    These operations will take more and more time, if the tables are loaded with APPEND hint or
    SQL*Loader using direct mode.
    A long time ago, I ran into a similar situation. Data was "deleted" selectively, SQL*Loader was
    used (in DIRECT mode) to add new rows to the table. I had a few tables using more number of blocks
    than the number of rows in the table!
    Needless to say, the process was changed to truncate tables after exporting/extracting required
    data first, and then loading the data back. Worked much better.

  • 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 Statement takes more time after immediate insert statement..

    Hello,
    I found below scenario
    1. I have table TABLE1 which has index on COL1 field. It has around 40 columns and 100000 rows.
    2. whenever i insert 100000 rows in bulk with changing indexed key column and executing SELECT statement in same session then it takes around 3 mins to complete.
    3. However, if i open new session and execute same select statement then it returns in 2-3 seconds.
    I didnt get anything in XPLAN.. :(
    I felt Buffer Clean is cause to take time. please let me know your opinion.
    Thanks in Advance
    Sach

    sach09 wrote:
    Hello,
    I found below scenario
    1. I have table TABLE1 which has index on COL1 field. It has around 40 columns and 100000 rows.
    2. whenever i insert 100000 rows in bulk with changing indexed key column and executing SELECT statement in same session then it takes around 3 mins to complete.
    3. However, if i open new session and execute same select statement then it returns in 2-3 seconds.
    I didnt get anything in XPLAN.. :(
    I felt Buffer Clean is cause to take time. please let me know your opinion.Are you running the query in the other session after running it from the first?
    Aman....

  • 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

  • Replication update statement takes long time

    Hi Replication experts,
    I have a issue and please suggest if my understanding and solution is correct.
    We have a transactional replication setup for data warehouse, from today morning replication got huge latency so when I looked into it I saw the "sp_MSupd_< tablename >" was running for very long time and by this time it was running for 9 hours
    still no data was updated, Latency went very high. What we feel is that the index maintenance was not done in subscriber also it was not replicated too. So due to high fragmentation the update statement could take very long.
    As there was no error message or blocks found all we see is the update taking very long. So to avoid this we are planning to remove the index, as this is just data warehouse index maintenance is not required by removing we can gain some space too. Is this a
    good Idea to implement?
    When we ran profiler nothing was found, no error or alert logged.
    Please let me know your suggestions
    Thanks
    Best Regards Moug

    Hi All,
    The Issue we found to be is that a day before, new column was added to the table and 9000 rows were updated ... This caused the distributor to slow down the update operation as the index in subscriber(15 million rows) was updating every time  a row
    is updated.. So we suspect that adding a new column and updating it at the same time is the culprit..
    But still am not convinced as per my understanding the distributor operates by comparing the primary key of publisher that was changed with the primary key of the subscriber and apply those change.. If that is the case why should it worry about the new column
    added or the number of updates..
    Also one strange thing is another table was also lagging behind in its operation ,though that table was updated with just 18 rows.. So in a nutshell the update operation was totally down by distributor operation on that day..
    Can someone please shed some light on this, Replication is my favorite topic but now I got fear of it.. after failing to know what could be issue... 
    Best Regards Moug

  • 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

  • Update statement takes long time - Why so ?

    Dear DBAs;
    Daily update statement takes 20 mins. But today update takes more time.
    What is the reason how to resolve ?
    Thanks in advance ..

    8f953842-815b-4d8c-833d-f2a3dd51e602 wrote:
    Dear DBAs;
    Daily update statement takes 20 mins. But today update takes more time.
    What is the reason how to resolve ?
    Thanks in advance ..
    More time? How much more?

  • 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.

  • What could be the reason for Crawl process to take long time or get in to a hung state.

    Hi All,
    What could be the reason for Crawl process to take long time or get in to a hung state? Is it something also related to the DB Server resources crunch? Does this lead to Index file corruption?
    What should be the process to be followed when index file is corrupted? How do we come to know about that?
    Thanks in Advance.

    "The crawl time depends on what you are crawling -- the number of items, the size of the items, the location of the items. If you have a lot of content that needs to be crawled, it will take much time".
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/f4cad578-f3bc-4822-b660-47ad27ce094a/sharepoint-2007-crawl-taking-long-time-to-complete?forum=sharepointgeneralprevious
    "The only clean and recommended way to recover from an index corruption is to completely rebuild the index on all the servers in the farm."
    http://blogs.technet.com/b/victorbutuza/archive/2008/11/11/event-id-4138-an-index-corruption-was-detected-in-component-shadowmerge-in-catalog-portal-content.aspx
    Whenever search index file got corrupted it will got the details to Event logs
    http://technet.microsoft.com/en-us/library/ff468695%28v=office.14%29.aspx
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • 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).

Maybe you are looking for

  • WBS assignment in Network

    Hi All, We have developed new report with copy of std report-KALR and the output is coming as excepted in business requirement but the report execution performance is very slow. So i have discussed with technical team about this performance issue and

  • In Billing doc Base price should not change where as in SO system allow

    Hi I have one requirenment the Base price (ZPR0) should pick automatically from condition records and system should allow to change ZPR0 in Sales Order item level , where as it should be Grey mode in billing document item level. 1. In the condition t

  • Customer Dunning printout - missing columns

    Hi, I have tried using F150 to run customer dunning. The sapscript attached F150_BE_DUNN_01 for printing of dunning form. However, 3 columns are missing from form - Doc no, currency and amount. I'm using the standard form given. Pl advised.

  • No Action Until Image Loads, Please

    Hi; For some reason the squares of color that are supposed to load behind the image that acts as a mask load first, momentarily showing while the image loads, which looks bad. Hre is the code: package     import flash.display.Sprite;     import flash

  • Camcorder/iMac communication

    I posted this question on the iMovie forum a few days ago with no responses so I thought I would give this forum a try. I own a Sony camcorder Model DCR-DVD203 which I purchased in August of 2005. I have never attempted to connect it to my iMac (Inte