Query takes time to execute. Review this query and give me a possible quere

SELECT DISTINCT A.REFERENCE_NUMBER
FROM A,B,C
WHERE DF_N_GET_CONTRACT_STATUS (A.REFERENCE_NUMBER, TRUNC (SYSDATE)) = 1
AND ( B.CHQ_RTN_INDICATOR IS NULL AND B.CHALLAN_NUMBER IS NULL
AND C.INSTRUMENT_TYPE IN (1, 2) AND C.MODULE_CODE = 5 )
AND ( A.HEADER_KEY = B.HEADER_KEY AND C.HEADER_KEY = B.HEADER_KEY);
This query takes 3 minutes to execute. I want to improve the performance so that it can execute with in seconds.
Table A has 10 lakhs record.
Table B has 3.7 lakhs record.
Table C has 5.3 lakhs record. Consider DF_N_GET_CONTRACT_STATUS as function. REFERENCE_NUMBER is the type of Varchar2(20).
Plz give me a correct logical and fastest execution query for the same.
Thanks in advance.

I would agree with the post from Santosh above that you should review the guidelines for posting a tuning request. This is VERY important. It is impossile to come up with any useful suggestions without the proper information.
In the case of your query, I would probably focus my attention on the function that you have defined. What happens if the condition using the DF_N_GET_CONTRACT_STATUS function is removed? Does it still take 3 minutes?
SELECT reference_number
from (
  SELECT DISTINCT A.REFERENCE_NUMBER
  FROM A,B,C
  WHERE ( B.CHQ_RTN_INDICATOR IS NULL AND B.CHALLAN_NUMBER IS NULL
  AND C.INSTRUMENT_TYPE IN (1, 2) AND C.MODULE_CODE = 5 )
  AND ( A.HEADER_KEY = B.HEADER_KEY AND C.HEADER_KEY = B.HEADER_KEY)
where DF_N_GET_CONTRACT_STATUS(reference_number, trunc(sysdate)) = 1;Of course, the query above really depends on the cardinality of the returned data..... which is impossible to know without following the posting guidelines. This query could return anywhere between 0 rows and 2x10^17 rows. And in the latter case evaluating the function at the end wouldn't make any difference.
Also, do you really need the distinct? Does it make any difference? Most of the time that I see distinct, to me it either means the query is wrong or the data model is wrong.

Similar Messages

  • Query takes time to execute

    I am creating a jsp application . . . .I am retreiving some values from my database oracle 10g..my query taking time to execute even in isql plus..am uisng tomcat5 and oracle 10gR2..can anyone pls tell me why it happens...my query fetches data from four tables...i dont know exactly why its taking so muc time say 50seconds...when i run the application in my local host it retrievs fast when i do that in server it creates a problem..
    Actually it works fine when i deployed in my client server it takes time sometimes it takes atmost one minute
    1.pls tell me how can i test my query about the performance
    2.is der any command in oracle to test
    3.how much bytes it takes

    Look at this thread...
    When your query takes too long ...

  • I have a mid2009 MacBook Pro for which I have been using a USB WD HD for Time Machine.  I'd like to get a wireless HD  and start a new Time Machine backup for this Mac and retire the 5  year old WD drive.  Can I start over?

    I have a mid2009 MacBook Pro running Mavericks for which I have been using a USB WD HD for Time Machine.  I'd like to get a wireless HD  and start a new Time Machine backup for this Mac and retire the 5  year old WD drive.  Can I start over?

    no archive/ backup is perfect, HD clones can be set to make incremental additions, same as time machine however, though they are more time involved in doing so.
    See the + and - of all data backup/ archives below and "spread it around".... or the "dont put your eggs all in one basket" philosophy.
    Peace
    Data Storage Platforms; their Drawbacks & Advantages
    #1. Time Machine / Time Capsule
    Drawbacks:
    1. Time Machine is not bootable, if your internal drive fails, you cannot access files or boot from TM directly from the dead computer.
    2. Time machine is controlled by complex software, and while you can delve into the TM backup database for specific file(s) extraction, this is not ideal or desirable.
    3. Time machine can and does have the potential for many error codes in which data corruption can occur and your important backup files may not be saved correctly, at all, or even damaged. This extra link of failure in placing software between your data and its recovery is a point of risk and failure. A HD clone is not subject to these errors.
    4. Time machine mirrors your internal HD, in which cases of data corruption, this corruption can immediately spread to the backup as the two are linked. TM is perpetually connected (or often) to your computer, and corruption spread to corruption, without isolation, which TM lacks (usually), migrating errors or corruption is either automatic or extremely easy to unwittingly do.
    5. Time Machine does not keep endless copies of changed or deleted data, and you are often not notified when it deletes them; likewise you may accidently delete files off your computer and this accident is mirrored on TM.
    6. Restoring from TM is quite time intensive.
    7. TM is a backup and not a data archive, and therefore by definition a low-level security of vital/important data.
    8. TM working premise is a “black box” backup of OS, APPS, settings, and vital data that nearly 100% of users never verify until an emergency hits or their computers internal SSD or HD that is corrupt or dead and this is an extremely bad working premise on vital data.
    9. Given that data created and stored is growing exponentially, the fact that TM operates as a “store-it-all” backup nexus makes TM inherently incapable to easily backup massive amounts of data, nor is doing so a good idea.
    10. TM working premise is a backup of a users system and active working data, and NOT massive amounts of static data, yet most users never take this into consideration, making TM a high-risk locus of data “bloat”.
    11. In the case of Time Capsule, wifi data storage is a less than ideal premise given possible wireless data corruption.
    12. TM like all HD-based data is subject to ferromagnetic and mechanical failure.
    13. *Level-1 security of your vital data.
    Advantages:
    1. TM is very easy to use either in automatic mode or in 1-click backups.
    2. TM is a perfect novice level simplex backup single-layer security save against internal HD failure or corruption.
    3. TM can easily provide a seamless no-gap policy of active data that is often not easily capable in HD clones or HD archives (only if the user is lazy is making data saves).
    #2. HD archives
    Drawbacks:
    1. Like all HD-based data is subject to ferromagnetic and mechanical failure.
    2. Unless the user ritually copies working active data to HD external archives, then there is a time-gap of potential missing data; as such users must be proactive in archiving data that is being worked on or recently saved or created.
    Advantages:
    1. Fills the gap left in a week or 2-week-old HD clone, as an example.
    2. Simplex no-software data storage that is isolated and autonomous from the computer (in most cases).
    3. HD archives are the best idealized storage source for storing huge and multi-terabytes of data.
    4. Best-idealized 1st platform redundancy for data protection.
    5. *Perfect primary tier and level-2 security of your vital data.
    #3. HD clones (see below for full advantages / drawbacks)
    Drawbacks:
    1. HD clones can be incrementally updated to hourly or daily, however this is time consuming and HD clones are, often, a week or more old, in which case data between today and the most fresh HD clone can and would be lost (however this gap is filled by use of HD archives listed above or by a TM backup).
    2. Like all HD-based data is subject to ferromagnetic and mechanical failure.
    Advantages:
    1. HD clones are the best, quickest way to get back to 100% full operation in mere seconds.
    2. Once a HD clone is created, the creation software (Carbon Copy Cloner or SuperDuper) is no longer needed whatsoever, and unlike TM, which requires complex software for its operational transference of data, a HD clone is its own bootable entity.
    3. HD clones are unconnected and isolated from recent corruption.
    4. HD clones allow a “portable copy” of your computer that you can likewise connect to another same Mac and have all your APPS and data at hand, which is extremely useful.
    5. Rather than, as many users do, thinking of a HD clone as a “complimentary backup” to the use of TM, a HD clone is superior to TM both in ease of returning to 100% quickly, and its autonomous nature; while each has its place, TM can and does fill the gap in, say, a 2 week old clone. As an analogy, the HD clone itself is the brick wall of protection, whereas TM can be thought of as the mortar, which will fill any cracks in data on a week, 2-week, or 1-month old HD clone.
    6. Best-idealized 2nd platform redundancy for data protection, and 1st level for system restore of your computers internal HD. (Time machine being 2nd level for system restore of the computer’s internal HD).
    7. *Level-2 security of your vital data.
    HD cloning software options:
    1. SuperDuper HD cloning software APP (free)
    2. Carbon Copy Cloner APP (will copy the recovery partition as well)
    3. Disk utility HD bootable clone.
    #4. Online archives
    Drawbacks:
    1. Subject to server failure or due to non-payment of your hosting account, it can be suspended.
    2. Subject, due to lack of security on your part, to being attacked and hacked/erased.
    Advantages:
    1. In case of house fire, etc. your data is safe.
    2. In travels, and propagating files to friends and likewise, a mere link by email is all that is needed and no large media needs to be sent across the net.
    3. Online archives are the perfect and best-idealized 3rd platform redundancy for data protection.
    4. Supremely useful in data isolation from backups and local archives in being online and offsite for long-distance security in isolation.
    5. *Level-1.5 security of your vital data.
    #5. DVD professional archival media
    Drawbacks:
    1. DVD single-layer disks are limited to 4.7Gigabytes of data.
    2. DVD media are, given rough handling, prone to scratches and light-degradation if not stored correctly.
    Advantages:
    1. Archival DVD professional blank media is rated for in excess of 100+ years.
    2. DVD is not subject to mechanical breakdown.
    3. DVD archival media is not subject to ferromagnetic degradation.
    4. DVD archival media correctly sleeved and stored is currently a supreme storage method of archiving vital data.
    5. DVD media is once written and therefore free of data corruption if the write is correct.
    6. DVD media is the perfect ideal for “freezing” and isolating old copies of data for reference in case newer generations of data become corrupted and an older copy is needed to revert to.
    7. Best-idealized 4th platform redundancy for data protection.
    8. *Level-3 (highest) security of your vital data. 
    [*Level-4 data security under development as once-written metallic plates and synthetic sapphire and likewise ultra-long-term data storage]
    #6. Cloud based storage
    Drawbacks:
    1. Cloud storage can only be quasi-possessed.
    2. No genuine true security and privacy of data.
    3. Should never be considered for vital data storage or especially long-term.
    4. *Level-0 security of your vital data. 
    Advantages:
    1. Quick, easy and cheap storage location for simplex files for transfer to keep on hand and yet off the computer.
    2. Easy source for small-file data sharing.

  • I just upgrade from the 4 to 5s.  Are my apps supposed to transfer over and perhaps it just takes time to load like my email and pitures. I tried to install apps and it showed that they are already downloaded.  What do I do to get them to show up?

    I just upgrade from the 4 to 5s.  Are my apps supposed to transfer over and perhaps it just takes time to load like my email and pitures are? I tried to install apps and it showed that they are already installed.  What do I do to get them to show up?

    Hi, Twilavegas3. 
    Thank you for visiting Apple Support Communities.
    If your restored from a backup and the apps that are missing on the device show "Open" in the App Store, then they are located on other pages on your iPhone or are in folders.  Also, with the iOS 7 update most developers have changed icon badging.  This can cause some applications to be difficult to find.
    iPhone User Guide
    Cheers,
    Jason H.

  • On a few websites for my online courses, my macbook keyboard types two letters at a time. Why is this happening and how can I fix it?

    I'm trying to take some online courses but the keyboard types double letters the entire time. Why is this happening and What can I do to fix it?
    example: "wwhhaattss  wwrroonngg  wwiitthh  tthhiiss"

    Not Charge
    - See:      
    iPod touch: Hardware troubleshooting
    iPhone and iPod touch: Charging the battery
    - Try another cable. Some 5G iPods were shipped with Lightning cable that were either initially defective or failed after short use.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar                          

  • HT201250 My Time Machine is not backing up and gives me this error report, 'The backup disk image "/Volumes/Data/Valarie'siMac.sparsbundle" is already in use.  Time machine could not complete backup.    Can anyone help me?

    My Time Machine is not backing up and gives me this error report:
    The backup disk image "/Volumes/Data/Valarie'siMac.sparsbundle" is already in use
    Time Machine could not complete backup
    Can anyone help me?

    Look at the discussion on the following forum:
    https://discussions.apple.com/thread/3882138?start=0&tstart=0
    The responses given there may help.

  • TS4268 Hello, it's been 5 days now since my imessage has not working..and i have chatted to the costumer for two times. I took thier advice and instructions just to enable to send and receive on it but unfortunately until now its still NOT working. Pls.he

    Hello, it's been 5 days now since my imessage has not working..and i have chatted to the costumer for two times. I took thier advice and instructions just to enable to send and receive on it but unfortunately until now its still NOT working. Is there anybody who could help me please?

    Try this even if you have already.  Just make sure to follow the steps specifically.
    Go to settings > Facetime > send and recieve > tap on your apple id and sign out.  If your not signed in then that will work as well.
    Go to settings > Messages > sent and recieve > tap on your apple id and sign out.
    Restart the iPad by doing the slide to power off setup.  Just hold the power button on the top right till it turns off.
    After the iPad has been restarted:
    Go to settings > Facetime > and sign in
    Go to settings > Messages > and sign in
    Wait about 3 min then restart the iPad again.  Same instructions as above.
    When you restart you should be able to use messages again.  If not then call support again and talk to someone higher than the first level support they have.

  • In ios6, youtube cannot be played in the background unlike in the ios5. Is there a way round this ? And also is it possible to downgrade back to ios 5.1??

    in ios6, youtube cannot be played in the background unlike in the ios5. Is there a way round this ? And also is it possible to downgrade back to ios 5.1??

    You cannot downgrade your software. The only way you can downgrade your software is by jailbreaking your device (which can be risky if you dont know what your doing). Remember if you are downgrading by jailbreaking it will void your warranty with Apple - and you could run the risk of disabling your device.
    However, im not too sure about the YouTube problem, my only guess is that since it is not an original app that comes with the iOS software.

  • Query takes forever to execute

    This query executes forever:
    select count(*)
    from VIEW_DOCUMENT
    where exists
    select VIEW_DOCUMENT_ITEM.documentID
    from VIEW_DOCUMENT_ITEM
    where VIEW_DOCUMENT_ITEM.documentID=VIEW_DOCUMENT.documentID
    Here's what's inside VIEW_DOCUMENT_ITEM:
    select *
    from DOCUMENT_ITEM
    join VIEW_USER
    If I replace "join VIEW_USER" with "join USER" the query executes normally in few seconds!
    This makes no sense because here's what's in VIEW_USER:
    select * from USER
    Does anybody know what are possible causes for this strange behaviour?

    Actually my query is much more complex, this is simplified version.
    In original query it's 100% not cartesian join.
    Result of my query is 2710 and result of Sven's query is 2711.
    My question is only why does joining a table work normally and why does joining a view "select * from table" take forever.
    I can't see execution plan because my query never ends. I have to kill the Linux process.
    Here is TKPROF output, I don't know what this stuff means:
    TKPROF: Release 10.2.0.1.0 - Production on Tue Mar 4 14:21:57 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Trace file: orcl_ora_29715.trc
    Sort options: prsela  exeela  fchela 
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    alter session set sql_trace true
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 64 
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       58      0.00       0.01          0          0          0           0
    Execute    308      0.05       0.06          0          0          0           0
    Fetch      758      0.03       0.16         38       1188          0        2086
    total     1124      0.10       0.24         38       1188          0        2086
    Misses in library cache during parse: 13
    Misses in library cache during execute: 13
        1  user  SQL statements in session.
      308  internal SQL statements in session.
      309  SQL statements in session.
    Trace file: orcl_ora_29715.trc
    Trace file compatibility: 10.01.00
    Sort options: prsela  exeela  fchela 
           1  session in tracefile.
           1  user  SQL statements in trace file.
         308  internal SQL statements in trace file.
         309  SQL statements in trace file.
          14  unique SQL statements in trace file.
        3007  lines in trace file.
           0  elapsed seconds in trace file.

  • Query takes time

    Hi All
    one of my query is taking too much time and really appreciate that if you people guide me how to get it fast. I'm using Oracle 11g Enterprise Release 11.2.0.2.0 64 bit version. My query is below and this query extract around 1 million records.
    Query
    Select distinct group_number grp_nbr, ltrim(group_number,'0') trimed_grp_nbr,section_code sct, enrolment_groups.group_id,
    enrolment_groups.segment_code,market_sgmt_attr_ascns.role_type_code,market_sgmt_attr_ascns.part_attr_type_code,
    nvl((select 'Y' from info where ltrim(info.grp_nbr,'0')=group_number
    and ltrim(rtrim(info.sct))=section_code
    and subscriber_id_type='S'),'N') Mandatory_flag,
    min(to_date(coverage_period.enr.group_eff_date)) over (partition by enrolment_groups.group_id) Min_Effective_date,
    nvl((select 'Y' from info where ltrim(info.grp_nbr,'0')=group_number
    and ltrim(rtrim(info.sct))=section_code
    and subscriber_id_type='S' and id_code='1'),'N') identification_flag
    from coverage_period,
    enrolment_groups,
    market_sgmt_attr_ascns
    Where ltrim(coverage_period.grp_nbr,'0')=enrolment_groups.group_number
    and ltrim(rtrim(coverage_period.sct))=enrolment_groups.section_code
    and enrolment_groups.segment_code=market_sgmt_attr_ascns.segment_code
    and market_sgmt_attr_ascns='GRP'
    and market_sgmt_attr_ascns.part_attr_type_code='ABR-PART'
    and group_number||'/'section_code in
    Select ltrim(info.grp_nbr,'0')||'/'||ltrim(rtrim(info.sct)) g_s
    from info
    where 1=1
    and info.subscriber_id_type='S')
    I have to get million of records and this query will take too much time. I really appreciate if you could help me out. Thanks
    Regards
    Shumail

    I'm working as an ETL Developer and I created a package in SQL Developer and my select query returned around 1 million rows and then these rows inserted into one of my table by using insert into table statement.
    I don't understand what do you mean by this statement
    it must do a SORT to get the distinct rows.
    I did one mistake, my whole package insert around 1 million records and if I'm talking about this specific query then it return only 88 rows and it will take like 5 minutes and I use the same select logic means IN clause and other clauses through out my my package by using Union but my package will take too much time. My concern is that is there any way to change this query logic to get result faster.
    For example
    I use in clause to compare group_number and section_code as well as some other stuff like I use 'Select 'Y' .........' in some places. Please help me out that is there any other way to query these statement to get result faster. Thanks
    Edited by: 976593 on Apr 10, 2013 7:17 PM
    Edited by: 976593 on Apr 10, 2013 7:22 PM

  • Query taking time to execute

    Hello,
    i have created one query based on inventory cube 0IC_C03. when i am executing the infocube based on a particular date i am able to see the output but when i am executing the query on the basis of that particular date given while executing the cube the query is taking long time to execute and throwing a message of time limit exceed.
    could anyone suggest me why the query is showing such nessage along with resolution.
    Thanks,
    Kumkum
    Edited by: kumkum basu on Nov 29, 2010 2:33 PM

    Hi,
    There can be number of reason.
    What you can do is:-
    put the unwanted characteristics in Free Characteristics
    Remove unwanted cell reference
    Try using partitions in cubes
    Use aggregates for summarised data.
    f the above options doesnt work, then try pre-caching.This will definitely help!
    Use proper selections to get small subset of data.
    Goto RSRT>> type your query name>> Query properties>> select cache mode=4
    In addition to RSRT, ST05 (sql trace), SE30 (runtime analysis) and system statistics (ST03) may help you in identifying performance issues with a report.
    Thanks,.
    Saveen Kumar

  • How to display time took executed on a query.

    hi,
    i have a long running query, and don't have dba access.
    how to show the time it took from the query to display after executing a query?

    user1035690 wrote:
    great, how come the set timing off has no effect on my SQL developer?
    i can't set timing off (or on).
    thanks.Because SQLDeveloper is not SQLPLUS?
    That's like asking why does my motorbike have 2 wheels when my car has 4 ... they're different products :)

  • I recently updated my iPad and backed it up, then deleted photos to make space for more now when I try to take photos it says "time elapsed" what does this mean and how do I fix it?

    I Have an issue with taking photos my iPad mini 2 keeps saying "time elapsed" what's does this mean and how do I fix?

    You are using PPPoE but there is no server to authenticate against.. or the modem is already connected and nothing else can join.
    Is this ADSL?
    Do you have the modem in bridge?
    How does it work with the modem working as router? ie what type of connection does your ISP supply.. eg PPPoE is only one.. PPPoA is another.. IPoA or ETHoA.. and sever other more specialised.. PPPoE can only work where it is supported.

  • Simple query takes time to run

    Hi,
    I have a simple query whcih takes about 20 mins to run.. here is the TKPROF forit:
      SELECT
        SY2.QBAC0,
        sum(decode(SALES_ORDER.SDCRCD,'USD', SALES_ORDER.SDAEXP,'CAD', SALES_ORDER.SDAEXP /1.0452))
      FROM
        JDE.F5542SY2  SY2,
        JDE.F42119  SALES_ORDER,
        JDE.F0116  SHIP_TO,
        JDE.F5542SY1  SY1,
       JDE.F4101  PRODUCT_INFO
    WHERE
        ( SHIP_TO.ALAN8=SALES_ORDER.SDSHAN  )
        AND  ( SY1.QANRAC=SY2.QBNRAC and SY1.QAOTCD=SY2.QBOTCD  )
        AND  ( PRODUCT_INFO.IMITM=SALES_ORDER.SDITM  )
        AND  ( SY2.QBSHAN=SALES_ORDER.SDSHAN  )
        AND  ( SALES_ORDER.SDLNTY NOT IN ('H ','HC','I ')  )
        AND  ( PRODUCT_INFO.IMSRP1 Not In ('   ','000','689')  )
        AND  ( SALES_ORDER.SDDCTO IN  ('CO','CR','SA','SF','SG','SP','SM','SO','SL','SR')  )
        AND  (
        ( SY1.QACTR=SHIP_TO.ALCTR  )
        AND  ( PRODUCT_INFO.IMSRP1=SY1.QASRP1  )
      GROUP BY
      SY2.QBAC0
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.07       0.07          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch       10     92.40     929.16     798689     838484          0         131
    total       12     92.48     929.24     798689     838484          0         131
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 62 
    Rows     Row Source Operation
        131  SORT GROUP BY
    3535506   HASH JOIN 
    4026100    HASH JOIN 
        922     TABLE ACCESS FULL OBJ#(187309)
    3454198     HASH JOIN 
      80065      INDEX FAST FULL SCAN OBJ#(30492) (object id 30492)
    3489670      HASH JOIN 
      65192       INDEX FAST FULL SCAN OBJ#(30457) (object id 30457)
    3489936       PARTITION RANGE ALL PARTITION: 1 9
    3489936        TABLE ACCESS FULL OBJ#(30530) PARTITION: 1 9
      97152    TABLE ACCESS FULL OBJ#(187308)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.07       0.07          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch       10     92.40     929.16     798689     838484          0         131
    total       13     92.48     929.24     798689     838484          0         131
    Misses in library cache during parse: 1kindly suggest how to resolve this...
    OS is windows and its 9i DB...
    Thanks

    > ... you want to get rid of the IN statements.
    They prevent Oracle from usering the index.
    SQL> create table mytable (id,num,description)
      2  as
      3   select level
      4        , case level
      5          when 0 then 0
      6          when 1 then 1
      7          else 2
      8          end
      9        , 'description ' || to_char(level)
    10     from dual
    11  connect by level <= 10000
    12  /
    Table created.
    SQL> create index i1 on mytable(num)
      2  /
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user,'mytable')
    PL/SQL procedure successfully completed.
    SQL> set autotrace on explain
    SQL> select id
      2       , num
      3       , description
      4    from mytable
      5   where num in (0,1)
      6  /
                                        ID                                    NUM DESCRIPTION
                                         1                                      1 description 1
    1 row selected.
    Execution Plan
    Plan hash value: 2172953059
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |         |  5001 |   112K|     2   (0)| 00:00:01 |
    |   1 |  INLIST ITERATOR             |         |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| MYTABLE |  5001 |   112K|     2   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN | I1      |  5001 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("NUM"=0 OR "NUM"=1)Regards,
    Rob.

  • Report is taking time to execute the following query

    Hi All,
    I have one query using in reports6i,which i am describing down,its taking half an hour to execute.
    I need to tune the query,if any one could help or any suggestions...........highly appreciable.
    SELECT +ALL_ROWS
    DISTINCT sm.orgn_code,
    sm.sample_no,
    -- DECODE (sm.batch_id, NULL, 'Item/Locn', 'Production') AS sample_type,
    NVL2(sm.batch_id, 'Production', 'Item/Locn') AS sample_type,
    sm.date_drawn,
    su.user_name AS drawn_by,
    im.item_no,
    lm.lot_no,
    im.inv_type,
    qt.test_code,
    rm.user_name AS result_by,
    rm.result_date,
    qt.test_type,
    qv.min_value_num,
    qv.max_value_num,
    DECODE(qt.test_type, 'N', TO_CHAR(qv.min_value_num) || ' - ' || TO_CHAR(qv.max_value_num), NULL) AS the_range,
    DECODE(qt.test_type, 'N', TO_CHAR(qv.target_value_num), qv.target_value_char) AS the_spec,
    DECODE(qt.test_type, 'N', TO_CHAR(rm.result_value_num), rm.result_value_char) AS the_result,
    DECODE(qt.test_unit, 'N/A', NULL, qt.test_unit) AS qc_uom,
    DECODE(sm.sample_disposition,
    '0RT',
    'RETAIN',
    '1P',
    'PENDING',
    '2I',
    'IN PROGRESS',
    '3C',
    'COMPLETE',
    '4A',
    'ACCEPT',
    '5AV',
    'ACCEPT WITH VARIANCE',
    '6RJ',
    'REJECT',
    '7CN',
    'CANCEL',
    NULL) AS disposition
    FROM gmd.gmd_samples sm,
    -- gmd.gmd_results rm,
    gmd.gmd_qc_tests_b qt,
    gmd.gmd_specifications_b sp,
    gmd.gmd_spec_tests_b qv,
    gmi.ic_lots_mst lm,
    apps.ic_item_mst im,
    applsys.fnd_user su,
    (SELECT gr.result_date,
    gr.sample_id,
    gr.test_id,
    gr.result_value_num,
    gr.result_value_char,
    ru.user_name
    FROM gmd_results gr,
    applsys.fnd_user ru
    WHERE (to_date(to_char(gr.result_date,'mm/dd/yyyy'),'mm/dd/yyyy') BETWEEN
    to_date(to_char(:p_2_start_date,'mm/dd/yyyy'),'mm/dd/yyyy') AND
    to_date(to_char(:p_3_end_date,'mm/dd/yyyy'),'mm/dd/yyyy'))
    AND gr.result_date IS NOT NULL
    AND ru.user_id = gr.last_updated_by) rm
    WHERE 1 = 1 --rm.result_date IS NOT NULL
    -- AND TO_DATE (TO_CHAR (rm.result_date, 'mm/dd/yyyy'), 'mm/dd/yyyy') >=TO_DATE (TO_CHAR (:p_2_start_date, 'mm/dd/yyyy'), 'mm/dd/yyyy')
    -- AND TO_DATE (TO_CHAR (rm.result_date, 'mm/dd/yyyy'), 'mm/dd/yyyy') <=TO_DATE (TO_CHAR (:p_3_end_date, 'mm/dd/yyyy'), 'mm/dd/yyyy')
    AND im.inv_type = NVL (UPPER (:p_inv_type), im.inv_type)
    AND sm.orgn_code = UPPER (:p_1_orgn)
    AND sm.item_id = lm.item_id --double
    AND sm.lot_id = lm.lot_id
    AND sm.item_id = lm.item_id --double
    AND sm.item_id = im.item_id
    AND sp.item_id = im.item_id
    AND rm.sample_id = sm.sample_id
    AND su.user_id = sm.sampler_id
    -- AND ru.user_id = rm.last_updated_by
    AND rm.test_id = qt.test_id
    AND qt.test_id = qv.test_id
    AND qv.spec_id = sp.spec_id
    AND sp.spec_status = 700
    AND qt.test_code LIKE NVL(:p_test, '%')
    AND ( ( qt.test_type = 'N'
    AND ( rm.result_value_num < qv.min_value_num
    OR rm.result_value_num > qv.max_value_num))
    OR ( qt.test_type <> 'N'
    AND rm.result_value_char <> 'OK'
    AND rm.result_value_char <> qv.target_value_char)
    Thanks in Advance

    You may want to consider demoralization views/tables or create indexes etc. to improve performance. Post it to
    PL/SQL
    to get more and quicker responses.

Maybe you are looking for

  • IBooks not displaying since updating to OS 6

    Since updating to OS6, I have had a few issues with my phone. This one involves my iBooks.  Severa of my books are displaying the following error message in a red box when I try to open them: "This page contains the following erors: error on line 1 a

  • Runtime engine files 8.2

    Hi, Since most users of my written program are users with "restricted right" acounts under Windows XP I copied the Runtime engine files of LV7.11 manualy by copying the "Program Files\National Instruments\LabVIEW 7.1\Shared\LabVIEW Run-Time\7.1" file

  • Iphone 4s ios 7.1.2 not vibration

    Good afternoon! I have a problem with the phone not working vibrations ip

  • Rebook Hard Disc after installing SL

    Hi All, I just wanted to upgrade to SL..but something seems to have gone wrong (no idea what). Anyway, it takes now about 8 minutes to start up my MacBook Pro with an additional "teething vs teething" noise coming from the hard disc. Used Disk Utilit

  • Cannot find a community forum for Email

    Is the 'other BB quesries' the right place to open a question on email configuration and setup in Outlook? thanks