Query running slow in one node

Hi All,
We are running 4-node Oracle 10g RAC (linux 64-bit). The query is running fast in one node, but the same query is running very slow in the other node. And sometimes, we see pin S wait on X wait event in top 5 events.
Has anyone faced this kind of situation before ?
Thanks,
Kumar

Hi,
Execute your query on node where query is running very slow. Get SID and execute query above to see what is event of waiting.
exec dbms_application_info.set_client_info('@sw2')
-- file sw2.sql
col event  format     a25  heading "Wait Event" trunc
col state  format     a15  heading "Wait State" trunc
col siw    format   99999  heading "Waited So|Far (ms)"
col wt     format 9999999  heading "Time Waited|(ms)"
select event,
       state,
       seconds_in_wait siw,
       wait_time wt
from   v$session_wait
where  sid = &sid
order by event;
exec dbms_application_info.set_client_info('@sw1');
-- file  sw1.sql
set linesize 30000
set pagesize 200
col sid      format    9999  heading "SID"
col username format     a10  heading "USERNAME"
col osuser   format     a20  heading "OSUSER"
col event    format     a25  heading "Wait Event" trunc
col state    format     a15  heading "Wait State" trunc
col siw      format   99999  heading "Waited So|Far (ms)"
col wt       format 9999999  heading "Time Waited|(ms)"
col sw1      format 9999999  heading "File"
col sw2      format 9999999  heading "Block"
col Objeto   format a50
select sw.event,
       sw.p1,
       sw.p2,
       sw.p3,
       sw.state,
       s.sid,
       S.osuser,
       s.username,
       nvl(s.program, s.module),
       sw.seconds_in_wait siw,
       sw.wait_time wt
  from gv$session_wait sw,
       gv$session s
WHERE sw.sid = s.sid
   and sw.EVENT NOT LIKE 'SQL%'
   and username is not NULL
   and s.inst_id = sw.inst_id
   and sw.event not like 'PX%'
order by 1, 6, 7;Regards,
Levi Pereira

Similar Messages

  • Query of query - running slower on 64 bit CF than 32 bit CF

    Greetings...
    I am seeing behavior where pages that use query-of-query run slower on 64-bit Coldfusion 9.01 than on 32-bit Coldfusion 9.01.
    My server specs are : dual processer virtual machine, 4 GIG ram, Windows 2008 Datacenter Server r2 64-bit, Coldfusion 9.01. Note that the coldfusion is literally "straight out of the box", and is using all default settings - the only thing I configured in CF is a single datasource.
    The script I am using to benchmark this runs a query that returns 20,000 rows with fields id, firstname, lastname, email, city, datecreated. I then loop through all 20,000 records, and for each record, I do a query-of-query (on the same master query) to find any other record where the lastname matches that of the record I'm currently on. Note that I'm only interested in using this process for comparative benchmarking purposes, and I know that the process could be written more efficiently.
    Here are my observed execution times for both 64-bit and 32-bit Coldfusion (in seconds) on the same machine.
    64 bit CF 9.01: 63,49,52,52,52,48,50,49,54 (avg=52 seconds)
    32 bit CF 9.01: 47,45,43,43,45,41,44,42,46 (avg=44 seconds)
    It appears from this that 64-bit CF performs worse than 32-bit CF when doing query-of-query operations. Has anyone made similar observations, and is there any way I can tune the environment to improve 64 bit performance?
    Thanks for any help you can provide!
    By the way, here's the code that is generating these results:
    <!--- Allrecs query returns 20000 rows --->
    <CFQUERY NAME="ALLRECS" DATASOURCE="MyDsn">
        SELECT * FROM MyTBL
    </CFQUERY>
    <CFLOOP QUERY="ALLRECS">
        <CFQUERY NAME="SAMELASTNAME" DBTYPE="QUERY">
            SELECT * FROM ALLRECS
            WHERE LN=<CFQUERYPARAM VALUE="#ALLRECS.LN#" CFSQLTYPE="CF_SQL_VARCHAR">
            AND ID<><CFQUERYPARAM VALUE="#AllRecs.ID#" CFSQLTYPE="CF_SQL_INTEGER">
        </CFQUERY>
        <CFIF SameLastName.RecordCount GT 20>
            #AllRecs.LN#, #AllRecs.FN# : #SameLastName.RecordCount# other records with same lastname<BR>
        </CFIF>
    </CFLOOP>

    BoBear2681 wrote:
    ..follow-up: ..Thanks for the follow-up. I'll be interested to hear the progress (or otherwise, as the case may be).
    As an aside. I got sick of trying to deal with Clip because it could only handle very small Clip sizes. AFAIR it was 1 second of 44.1 KHz stereo. From that point, I developed BigClip.
    Unfortunately BigClip as it stands is even less able to fulfil your functional requirement than Clip, in that only one BigClip can be playing at a time. Further, it can be blocked by other sound applications (e.g. VLC Media Player, Flash in a web page..) or vice-versa.

  • Query runs slower when using variables & faster when using hard coded value

    Hi,
    My query runs slower when i use variables but it runs faster when i use hard coded values. Why it is behaving like this ?
    My query is in cursor definition in a procedure. Procedure runs faster when using hard coded valus and slower when using variables.
    Can anybody help me out there?
    Thanks in advance.

    Hi,
    Thanks for ur reply.
    here is my code with Variables:
    Procedure populateCountryTrafficDetails(pWeekStartDate IN Date , pCountry IN d_geography.country_code%TYPE) is
    startdate date;
    AR_OrgId number(10);
    Cursor cTraffic is
    Select
              l.actual_date, nvl(o.city||o.zipcode,'Undefined') Site,
              g.country_code,d.customer_name, d.customer_number,t.contrno bcn,
              nvl(r.dest_level3,'Undefined'),
              Decode(p.Product_code,'820','821','821','821','801') Product_Code ,
              Decode(p.Product_code,'820','Colt Voice Connect','821','Colt Voice Connect','Colt Voice Line') DProduct,
              sum(f.duration),
              sum(f.debamount_eur)
              from d_calendar_date l,
              d_geography g,
              d_customer d, d_contract t, d_subscriber s,
              d_retail_dest r, d_product p,
              CPS_ORDER_DETAILS o,
              f_retail_revenue f
              where
              l.date_key = f.call_date_key and
              g.geography_key = f.geography_key and
              r.dest_key = f.dest_key and
              p.product_key = f.product_key and
              --c.customer_key = f.customer_key and
              d.customer_key = f.customer_key and
              t.contract_key = f.contract_key and
              s.SUBSCRIBER_KEY = f.SUBSCRIBER_KEY and
              o.org_id(+) = AR_OrgId and
              g.country_code = pCountry and
              l.actual_date >= startdate and
              l.actual_date <= (startdate + 90) and
              o.cli(+) = s.area_subno and
              p.product_code in ('800','801','802','804','820','821')
              group by
              l.actual_date,
              o.city||o.zipcode, g.country_code,d.customer_name, d.customer_number,t.contrno,r.dest_level3, p.product_code;
    Type CountryTabType is Table of country_traffic_details.Country%Type index by BINARY_INTEGER;
    Type CallDateTabType is Table of country_traffic_details.CALL_DATE%Type index by BINARY_INTEGER;
    Type CustomerNameTabType is Table of Country_traffic_details.Customer_name%Type index by BINARY_INTEGER;
    Type CustomerNumberTabType is Table of Country_traffic_details.Customer_number%Type index by BINARY_INTEGER;
    Type BcnTabType is Table of Country_traffic_details.Bcn%Type index by BINARY_INTEGER;
    Type DestinationTypeTabType is Table of Country_traffic_details.DESTINATION_TYPE%Type index by BINARY_INTEGER;
    Type ProductCodeTabType is Table of Country_traffic_details.Product_Code%Type index by BINARY_INTEGER;
    Type ProductTabType is Table of Country_traffic_details.Product%Type index by BINARY_INTEGER;
    Type DurationTabType is Table of Country_traffic_details.Duration%Type index by BINARY_INTEGER;
    Type DebamounteurTabType is Table of Country_traffic_details.DEBAMOUNTEUR%Type index by BINARY_INTEGER;
    Type SiteTabType is Table of Country_traffic_details.Site%Type index by BINARY_INTEGER;
    CountryArr CountryTabType;
    CallDateArr CallDateTabType;
    Customer_NameArr CustomerNameTabType;
    CustomerNumberArr CustomerNumberTabType;
    BCNArr BCNTabType;
    DESTINATION_TYPEArr DESTINATIONTYPETabType;
    PRODUCT_CODEArr PRODUCTCODETabType;
    PRODUCTArr PRODUCTTabType;
    DurationArr DurationTabType;
    DebamounteurArr DebamounteurTabType;
    SiteArr SiteTabType;
    Begin
         startdate := (trunc(pWeekStartDate) + 6) - 90;
         Exe_Pos := 1;
         Execute Immediate 'Truncate table country_traffic_details';
         dropIndexes('country_traffic_details');
         Exe_Pos := 2;
         /* Set org ID's as per AR */
         case (pCountry)
         when 'FR' then AR_OrgId := 81;
         when 'AT' then AR_OrgId := 125;
         when 'CH' then AR_OrgId := 126;
         when 'DE' then AR_OrgId := 127;
         when 'ES' then AR_OrgId := 123;
         when 'IT' then AR_OrgId := 122;
         when 'PT' then AR_OrgId := 124;
         when 'BE' then AR_OrgId := 132;
         when 'IE' then AR_OrgId := 128;
         when 'DK' then AR_OrgId := 133;
         when 'NL' then AR_OrgId := 129;
         when 'SE' then AR_OrgId := 130;
         when 'UK' then AR_OrgId := 131;
         else raise_application_error (-20003, 'No such Country Code Exists.');
         end case;
         Exe_Pos := 3;
    dbms_output.put_line('3: '||to_char(sysdate, 'HH24:MI:SS'));
         populateOrderDetails(AR_OrgId);
    dbms_output.put_line('4: '||to_char(sysdate, 'HH24:MI:SS'));
         Exe_Pos := 4;
         Open cTraffic;
         Loop
         Exe_Pos := 5;
         CallDateArr.delete;
    FETCH cTraffic BULK COLLECT
              INTO CallDateArr, SiteArr, CountryArr, Customer_NameArr,CustomerNumberArr,
              BCNArr,DESTINATION_TYPEArr,PRODUCT_CODEArr, PRODUCTArr, DurationArr, DebamounteurArr LIMIT arraySize;
              EXIT WHEN CallDateArr.first IS NULL;
                   Exe_pos := 6;
                        FORALL i IN 1..callDateArr.last
                        insert into country_traffic_details
                        values(CallDateArr(i), CountryArr(i), Customer_NameArr(i),CustomerNumberArr(i),
                        BCNArr(i),DESTINATION_TYPEArr(i),PRODUCT_CODEArr(i), PRODUCTArr(i), DurationArr(i),
                        DebamounteurArr(i), SiteArr(i));
                        Exe_pos := 7;
    dbms_output.put_line('7: '||to_char(sysdate, 'HH24:MI:SS'));
         EXIT WHEN ctraffic%NOTFOUND;
    END LOOP;
         commit;
    Exe_Pos := 8;
              commit;
    dbms_output.put_line('8: '||to_char(sysdate, 'HH24:MI:SS'));
              lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_CUSTNO ON country_traffic_details (CUSTOMER_NUMBER)';
              execDDl(lSql);
              lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_BCN ON country_traffic_details (BCN)';
              execDDl(lSql);
              lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_PRODCD ON country_traffic_details (PRODUCT_CODE)';
              execDDl(lSql);
              lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_SITE ON country_traffic_details (SITE)';
              execDDl(lSql);
              lSql := 'CREATE INDEX COUNTRY_TRAFFIC_DETAILS_DESTYP ON country_traffic_details (DESTINATION_TYPE)';
              execDDl(lSql);
              Exe_Pos:= 9;
    dbms_output.put_line('9: '||to_char(sysdate, 'HH24:MI:SS'));
    Exception
         When Others then
         raise_application_error(-20003, 'Error in populateCountryTrafficDetails at Position: '||Exe_Pos||' The Error is '||SQLERRM);
    End populateCountryTrafficDetails;
    In the above procedure if i substitute the values with hard coded values i.e. AR_orgid = 123 & pcountry = 'Austria' then it runs faster.
    Please let me know why it is so ?
    Thanks in advance.

  • Can I run more than one Node Manager per machine?

    Hia,
    We have a situation in our project where we need to run different domains on a Solaris machine in different java modes.
    Say Domain1 should be running in 32bit version of java where as Domain2 should be running in 64bit mode due to the nature of testing currently going on in different domains.
    We could successfully get the two domains running in different java modes in parallel by modifying the start scripts to decide which Sud data model to start the servers based on certain parms. However, the pain here is with the Node Manager.
    My understanding is that there should be one Node Manager running per machine for all the domains running on that machine. So when ever I have to run a domain in a java mode different to that of what Node Manager is running on, I had to kill the node manager and start it in the same version that I want to start the other servers in since Node Manager uses its starting parms internally to start the Managed Servers (Note: there is no issue in running the Admin Server regardless of the node manager mode as expected).
    Can somebody advise me if there is any way to get around this hassle?
    I want to know if we can run more than one node manager per machine.
    Below are the details of my env.
    Weblogic Server 10.3
    Solaris 10 SPARC 64 bit (SunOS 5.10 Generic_142900-14 sun4v sparc)
    java version "1.6.0_20"
    Hope all this makes sense...
    Cheers,
    Satish.
    Edited by: apsnaidu on Mar 15, 2013 3:29 PM

    You can run as many node manager as you want in a particular machine.
    At the time of starting the node manager you need to pass hostname & Port.
    This will start the nodemanager on different ports of a machine.
    sh startNodeManager.sh <hostname> <port>
    eg:- sh startNodeManager.sh dev_machine_01 5556
    sh startNodeManager.sh dev_machine_01 5557
    sh startNodeManager.sh dev_machine_01 5558
    After starting your node manager in different ports you need to change machine details from admin console.

  • Query performance slow in one instance in RAC

    Hi
    We have 3 node RAC. When we test onw query it slow by 40% in one instance and always physical reads are hapenning in that instance.
    Below are the details. All the parameters are same. Users compains some times the query is slow.
    Thanks in Advance.
    From Instance 1 - 9 Sec
    =============================================================
    Statistics
              0  recursive calls
              1  db block gets
          67209  consistent gets
              0  physical reads
              0  redo size
          23465  bytes sent via SQL*Net to client
          10356  bytes received via SQL*Net from client
             28  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             13  rows processed
    From Instance 2 - 13 Sec
    =============================================================
    Statistics
              0  recursive calls
              1  db block gets
          67215  consistent gets
          67193  physical reads    <<------------------------ Only in one instance
              0  redo size
          23465  bytes sent via SQL*Net to client
          10356  bytes received via SQL*Net from client
             28  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             13  rows processed
    From Instance 3 - 9 Sec
    =============================================================
    Statistics
              0  recursive calls
              1  db block gets
          67209  consistent gets
              0  physical reads
              0  redo size
          23465  bytes sent via SQL*Net to client
          10356  bytes received via SQL*Net from client
             28  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             13  rows processed

    You can also check global cache statistics. Run this before and after your query :
    select name, value from v$mystat s, v$statname n where s.statistic#=n.statistic# and name like '%blocks received';

  • Query running slow after 1000 rows in oracle

    Hi.
    I have one query which is fetching miln of rows.. the query runs very fast till 1000 to 1500 records after that it run very slow. Can you please help ,what could be the reason?
    Thanks

    831269 wrote:
    I have one query which is fetching miln of rows.. Why are you fetching that many rows? What is your client code going to do with a million rows? And why do you expect this to be fast? A million rows worth of I/O has to be done by Oracle (that will likely be mostly from disk and not buffer cache). That million rows has to be copied from the Oracle's SGA to client memory. If your client is PL/SQL code, that will be copied into the PGA. If your client is external, then that copy has to happen across platform boundaries and the network too.
    Then your code churns away on processing a million rows... doing what exactly? That "+what+" will need to be done once per row, for a million times. If it takes 10ms per row, that means almost 3h of client processing time.
    Fetching that many rows..? Often a design and coding mistake. Always an exception to the rule. Will never be "fast".
    And scalability and performance need to be addressed by re-examining the requirements, optimising the design that necessitates fetching that many rows, and using techniques such as parallel processing and thread safe code design.

  • Query Running Slow due to nvl.

    I have a Cursor Based query written as a Procedure.when i invoke that procedure,I found that two condition statements are the ones which is making my query run very slow.
    Since this has been handled with NVL statements query is running very slow.Currently query takes more than one hour to execute.if i comment these two statements and run the query,it takes ony 20 secs to complete.
    Those two statements are
    'and rbsa.batch_source_id = nvl(p_source_type_id, rbsa.batch_source_id)'
    'and rsa.salesrep_id between nvl(p_from_salesrep_id, rsa.salesrep_id) and nvl(p_to_salesrep_id, rsa.salesrep_id)'
    Is there any other alternative to replace these two statements by other means.
    Thanks in Advance...

    Dear Friend,
    Please try to replace nvl(p_source_type_id, rbsa.batch_source_id) with decode(p_source_type_id,NULL,rbsa.batch_source_id,p_source_type_id)
    It will speedup your query.
    Regards
    Ahamed Rafeeque Cherkala

  • SCAN LISTENER runs from only one node at a time from /etc/hosts !

    Dear all ,
    Recently I have to configure RAC in oracle 11g(r2) in AIX 6.1 . Since in this moment it is not possible to configure DNS, so I dont use SCAN ip into the DNS/GNS, I just add the SCAN ip into the host file like :
    cat /etc/hosts
    SCAN 172.17.0.22
    Got the info from : http://www.freeoraclehelp.com/2011/12/scan-setup-for-oracle-11g-release211gr2.html#ORACLE11GR2RACINS
    After configuring all the steps of RAC , Every services are ok except SCAN_LISTENER . This listener is up only one node at a time . First time when I chek it from node1 , it shows :
    srvctl status scan_listener
    SCAN listener LISTENER_SCAN1 is enabled
    SCAN listener LISTENER_SCAN1 is running on node dcdbsvr1
    now when I relocate it from node 2 using
    "srvctl relocate scan -i 1-n DCDBSVR2" , then the output shows :
    srvctl status scan_listener
    SCAN listener LISTENER_SCAN1 is enabled
    SCAN listener LISTENER_SCAN1 is running on node dcdbsvr2
    Baring these , we have to try to relocate it from the node2 by the following way, then it shows the error :
    srvctl relocate scan -i 2 -n DCDBSVR2
    resource ora.scan2.vip does not exists
    Now my question , How can I run the SCAN and SCAN_LISTENER both of the NODES ?
    Here is my listener file (which is in the GRID home location) configuration :
    Listener File OF NODE1 AND NODE 2:
    ==================================
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON
    LISTENER_SCAN1 =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC) (KEY = LISTENER_SCAN1)
    ADR_BASE_LISTENER_SCAN1 = /U01/APP/ORACLE
    2)
    Another issue , when I give the command : " ifconfig -a " , then it shows the SCAN ip either node1 or node2 . suppose if the SCAN ip is in the node1 , and then if I run the "relocate" command from node2 , the ip goes to the Node 2 . is it a correct situation ? advice plz ... ...
    thx in advance .. ...
    Edited by: shipon_97 on Jan 10, 2012 7:22 AM
    Edited by: shipon_97 on Jan 10, 2012 7:31 AM

    After configuring all the steps of RAC , Every services are ok except SCAN_LISTENER . This listener is up only one node at a time . First time when I chek it from node1 , it shows :If I am not wrong and after looking at the document you sent, you will be able to use only once scan in case you use /etc/host file and this will be up on only one node where you added this scan entry in /etc/hosts file.
    Now my question , How can I run the SCAN and SCAN_LISTENER both of the NODES ?Probably you can't in your case, you might run only one i think and on one node only
    srvctl status scan_listener
    SCAN listener LISTENER_SCAN1 is enabled
    SCAN listener LISTENER_SCAN1 is running on node dcdbsvr1
    now when I relocate it from node 2 using
    "srvctl relocate scan -i 1 -n DCDBSVR2" , then the output shows :
    srvctl status scan_listener
    SCAN listener LISTENER_SCAN1 is enabled
    SCAN listener LISTENER_SCAN1 is running on node dcdbsvr2You moved scan listener from node 1 to node 2, OK
    Baring these , we have to try to relocate it from the node2 by the following way, then it shows the error :
    srvctl relocate scan -i 2 -n DCDBSVR2
    resource ora.scan2.vip does not exists
    --------------------------------------------------------------------------------Since you have only one scan, you can't relocate "2". So ise "1" instead here also
    FYI
    http://www.oracle.com/technetwork/database/clustering/overview/scan-129069.pdf
    Salman

  • Query running slow

    Below query is running slow is there any other way to write the query which will enhance the performance.
    select ld.cst_fle_seq,
         tf.date_pro,
         lj.case_num ,
         ca.reference,
         rr.rej_txt
    from
         load_judg lj,
         rej_rea rr ,
         pl_case ca,
         tp_files tf ,
         tp tp
    where rr.rej_code(+) = ld.rej_code
    and ca.case_num (+)=lj.case_num
    and tp.seq =tf.seq
    and lj.cred_code(+) =tp.cst_code
    and tp.format =9
    and valid=''Y''
    and tf.fle_name like ''%F%''
    and lj.rej_code is not null
    and trunc(date_pro)=trunc(sysdate)
    Thanks in advance
    Jha

    Here is the explan plan of the query
    - SELECT STATEMENT Optimizer=CHOOSE (Cost=16 Card=1 Bytes=225)
    -NESTED LOOPS (Cost=16 Card=1 Bytes=225)
    -NESTED LOOPS (OUTER) (Cost=15 Card=1 Bytes=192)
    - HASH JOIN (Cost=14 Card=1 Bytes=147)
    - MERGE JOIN (CARTESIAN) (Cost=9 Card=4 Bytes=432)
    -TABLE ACCESS (FULL) OF LOAD_JUDGMENTS (Cost=1 Card=1 Bytes=69)
    - SORT (JOIN)
    -TABLE ACCESS (FULL) OF TAPE_FILES
    -TABLE ACCESS (FULL) OF TAPES (Cost=4 Card=418 Bytes=16302)
    -TABLE ACCESS (BY ROWID) OF REJECT_REASONS
    -INDEX (UNIQUE SCAN) OF REJ_PK (UNIQUE)
    -TABLE ACCESS (BY ROWID) OF CASES
    -INDEX (UNIQUE SCAN) OF CASE_PK (UNIQUE)
    sorry, as I have checked the tables and its not a cartesian.
    Thanks
    Jha

  • Query Runs Slow in Forms

    I have a search query that uses the substr function to fetch some records.The query runs fine when executing SQL*PLUS or any other client like PL/SQL Developer. The same query is dead slow in Forms interface.
    Can anyone suggest?

    Both the query use the substr function. Here is the query. only highlighted IF condition evaluates to true.
         V_SEARCH VARCHAR2(255);
    BEGIN
         --- SET MOBILENO
         IF :CONTROL.MOBILENO IS NOT NULL AND LENGTH(:CONTROL.MOBILENO) <= 7 THEN
              IF :CONTROL.QRY_MOBILENO = 'P' THEN
                   V_SEARCH := V_SEARCH||' AND substr(MOBILENO,5,7) = '||''''||:CONTROL.MOBILENO||'''';
              ELSIF :CONTROL.QRY_MOBILENO = 'S' THEN
                   V_SEARCH := V_SEARCH||' AND substr(MOBILENO,5,7) LIKE '||''''||:CONTROL.MOBILENO||'%''';     
              ELSIF :CONTROL.QRY_MOBILENO = 'E' THEN
                   V_SEARCH := V_SEARCH||' AND substr(MOBILENO,5,7) LIKE '||'''%'||:CONTROL.MOBILENO||'''';     
              ELSIF :CONTROL.QRY_MOBILENO = 'C' THEN
                   V_SEARCH := V_SEARCH||' AND substr(MOBILENO,5,7) LIKE '||'''%'||:CONTROL.MOBILENO||'%''';     
              END IF;     
         ELSIF :CONTROL.MOBILENO IS NOT NULL AND LENGTH(:CONTROL.MOBILENO) <= 11 THEN
              IF :CONTROL.QRY_MOBILENO = 'P' THEN
                   V_SEARCH := V_SEARCH||' AND MOBILENO = '||''''||:CONTROL.MOBILENO||'''';
              ELSIF :CONTROL.QRY_MOBILENO = 'S' THEN
                   V_SEARCH := V_SEARCH||' AND MOBILENO LIKE '||''''||:CONTROL.MOBILENO||'%''';     
              ELSIF :CONTROL.QRY_MOBILENO = 'E' THEN
                   V_SEARCH := V_SEARCH||' AND MOBILENO LIKE '||'''%'||:CONTROL.MOBILENO||'''';     
              ELSIF :CONTROL.QRY_MOBILENO = 'C' THEN
                   V_SEARCH := V_SEARCH||' AND MOBILENO LIKE '||'''%'||:CONTROL.MOBILENO||'%''';     
              END IF;     
         END IF;     
         --NDC
         IF :CONTROL.NDC IS NOT NULL THEN
                   V_SEARCH := V_SEARCH||' AND SUBSTR(MOBILENO,1,4) = '||''''||:CONTROL.NDC||'''';
         END IF;
         --Number Type
         IF :CONTROL.number_type IS NOT NULL THEN
                   V_SEARCH := V_SEARCH||' AND number_type = '||''''||:CONTROL.number_type||'''';
         END IF;     
         --Status
         IF :CONTROL.status IS NOT NULL THEN
                   V_SEARCH := V_SEARCH||' AND status = '||''''||substr(:CONTROL.status,1,1)||'''';
         END IF;     
         --CITY
         IF :CONTROL.CITY IS NOT NULL THEN
                   V_SEARCH := V_SEARCH||' AND LOC_NAME = '||''''||:CONTROL.CITY||'''';
         END IF;     
         --REGION
         IF :CONTROL.REGION IS NOT NULL THEN
                   V_SEARCH := V_SEARCH||' AND COMM_REGION = '||''''||:CONTROL.REGION||'''';
         END IF;     
         --RECYCLE FLAG
         IF :CONTROL.RECYCLE_FLAG <> 'A' THEN
              V_SEARCH := V_SEARCH||' AND RECYCLE_FLAG = '||''''||:CONTROL.RECYCLE_FLAG||'''';
         END IF;
         --EXECUTE QUERY
         V_SEARCH := SUBSTR(V_SEARCH,5);     
    GO_BLOCK('NO_INVENTORY');
         SET_BLOCK_PROPERTY('NO_INVENTORY',ONETIME_WHERE,V_SEARCH);
         EXECUTE_QUERY;
    END;

  • Query running fine in one environment but failing in other environment

    Hi,
    I have a query which i am trying to execute in two different environments.
    Test :- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Prod:- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Now query executes finely in one environment and fails in other environment.
    It gives following error.
    ORA-01861: literal does not match format string
    01861. 00000 - "literal does not match format string"
    The query is too long and contains CHAR-DATE and DATE-CHAR conversions.
    The same query works fine on TEST environment and and fails on PROD environment.
    Any help related to it would be appreciated.
    Thanks,
    Mahesh

    MaheshGx wrote:
    Hi,
    I have a query which i am trying to execute in two different environments.
    Test :- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Prod:- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Now query executes finely in one environment and fails in other environment.
    It gives following error.
    ORA-01861: literal does not match format string
    01861. 00000 - "literal does not match format string"
    The query is too long and contains CHAR-DATE and DATE-CHAR conversions.
    The same query works fine on TEST environment and and fails on PROD environment.
    Any help related to it would be appreciated.
    Thanks,
    MaheshThat's called a bug. One caused by the person who developed the code. They relied on implicit conversion between strings and dates when
    production quality code will always use to_char and to_date functions with a format mask.

  • Query running slow after upgrading

    Hi,
    We have one query that is running very slow in the 10.2.0.4 database after upgrading from 9.2.0.8 HP-UX B11.31. In 9.2.0.8 database it used to take 5 mins. But in the new 10.2.0.4 database it takes around 36 mins.The query is given below.
    SELECT a.transaction_date,
                    a.ORD_PROD_BE_ID,
                    a.SLS_POSTD_DT_BE_ID,
                     a.net_trd_amt,
                    a.trd_actl_un_qty,
                    t.FISC_MO_CD, 
                    t.FY_CD
    FROM fact_net_trd_sls a,
                dim_tm_mv t,
                dim_prod b,
                (SELECT DISTINCT kit_prod_cd FROM kal_kit_bom) c
    WHERE b.be_id = a.ORD_PROD_BE_ID
    AND b.end_date >SYSDATE
    AND t.be_id = a.SLS_POSTD_DT_BE_ID
    AND t.end_date > SYSDATE
    AND c.kit_prod_cd (+)= b.base_prod_cd
    AND t.FY_CD IN (SELECT DISTINCT FY_CD FROM DIM_tm_MV T WHERe T.DAY_STRT_PRD_OF_TM=TRUNC(SYSDATE))
    and nvl2(c.kit_prod_cd,'K','FG') = 'FG'
    ORDER BY  a.ORD_PROD_BE_ID,a.TRANSACTION_DATE;The plan in 9i is below,
    PLAN_TABLE_OUTPUT
    | Id  | Operation                           |  Name                  | Rows  | Bytes |TempSpc| Cost  |
    |   0 | SELECT STATEMENT                    |                        |  2861K|  1585M|       |   170K|
    |   1 |  VIEW                               |                        |  2861K|  1585M|       |   170K|
    |   2 |   SORT UNIQUE                       |                        |  2861K|   654M|  1397M|   170K|
    |*  3 |    FILTER                           |                        |       |       |       |       |
    |*  4 |     HASH JOIN OUTER                 |                        |       |       |       |       |
    |*  5 |      HASH JOIN                      |                        |  1998K|   445M|  4056K| 63419 |
    |*  6 |       TABLE ACCESS BY INDEX ROWID   | DIM_PROD               | 53189 |  3428K|       |   283 |
    |   7 |        BITMAP CONVERSION TO ROWIDS  |                        |       |       |       |       |
    |   8 |         BITMAP INDEX FULL SCAN      | XN3_DIM_PROD           |       |       |       |       |
    |   9 |       TABLE ACCESS BY INDEX ROWID   | FACT_NET_TRD_SLS       |  4081 |   203K|       |   118 |
    |  10 |        NESTED LOOPS                 |                        |  1998K|   320M|       | 57607 |
    |* 11 |         HASH JOIN SEMI              |                        |   490 | 57330 |       |   208 |
    |* 12 |          TABLE ACCESS FULL          | DIM_TM_MV              | 15180 |  1260K|       |   195 |
    |  13 |          TABLE ACCESS BY INDEX ROWID| DIM_TM_MV              |     1 |    32 |       |     1 |
    |* 14 |           INDEX RANGE SCAN          | XN4_DIM_TM_MV          |     1 |       |       |     1 |
    |* 15 |         INDEX RANGE SCAN            | FACT_NET_TRD_SLS_IDX3  |  4081 |       |       |    54 |
    |  16 |      TABLE ACCESS FULL              | KAL_KIT_BOM            | 14175 | 85050 |       |    24 |
    Predicate Information (identified by operation id):
       3 - filter(NVL2("KAL_KIT_BOM"."KIT_PROD_CD",'K','FG')='FG')
       4 - access("B"."BASE_PROD_CD"=("KAL_KIT_BOM"."KIT_PROD_CD"(+)))
       5 - access("B"."BE_ID"="A"."ORD_PROD_BE_ID")
       6 - filter("B"."END_DATE">SYSDATE@!)
      11 - access("SYS_ALIAS_0000"."FY_CD"="T"."FY_CD")
      12 - filter("SYS_ALIAS_0000"."END_DATE">SYSDATE@!)
      14 - access("T"."DAY_STRT_PRD_OF_TM"=TRUNC(SYSDATE@!))
      15 - access("SYS_ALIAS_0000"."BE_ID"="A"."SLS_POSTD_DT_BE_ID")
    Note: cpu costing is off
    36 rows selected.The plan in 10g is below.
    Operation           Object Name     Rows     Bytes     Cost       Object Node      In/Out  PStart    PStop
    SELECT STATEMENT Optimizer Mode=ALL_ROWS                             34                           1382                                                       
      VIEW                   34           19 K        1382                                                       
        SORT UNIQUE                               34           7 K          1382                                                       
          FILTER                                                                                                                             
            HASH JOIN OUTER                   34           7 K          1375                                                       
              MAT_VIEW ACCESS BY INDEX ROWID           WHSUSR.DIM_TM_MV 1              81           1                                                              
                NESTED LOOPS                      24           5 K          1350                                                       
                  NESTED LOOPS                    740         105 K     1336                                                       
                    MERGE JOIN CARTESIAN                              1              95           1332                                                       
                      TABLE ACCESS BY INDEX ROWID              WHSUSR.DIM_PROD      52 K        3 M        279                                                         
                        BITMAP CONVERSION TO ROWIDS                                                                                                                      
                          BITMAP INDEX FULL SCAN     WHSUSR.XN3_DIM_PROD                                                                                                           
                      BUFFER SORT                   1              30           9223372036 G                                                   
                        SORT UNIQUE                               1              30           1                                                              
                          MAT_VIEW ACCESS BY INDEX ROWID               WHSUSR.DIM_TM_MV 1              30           1                                                                           
                            INDEX RANGE SCAN               WHSUSR.XN4_DIM_TM_MV      1                              1                                                              
                    TABLE ACCESS BY INDEX ROWID                TRANSDATA.FACT_NET_TRD_SLS             740         36 K        4                                                                    
                      INDEX RANGE SCAN     TRANSDATA.FACT_NET_TRD_SLS_IDX2 2 K                         1                                                              
                  INDEX RANGE SCAN         WHSUSR.XN1_DIM_TM_MV      1                              1                                                              
              TABLE ACCESS FULL               EDW_DBA.KAL_KIT_BOM            14 K        83 K        24                                                            We have checked that the statistics are uptodate. Please help with suggestions.
    Thanks in advane.

    Most likely, the index stats are not up-to-date, please double check.
    h5. In 9i, FACT_NET_TRD_SLS_IDX3 is used to scan the fact.
    Time dimension is used to filter out most records in fact table first, then join to Product dimension.
    h5. In 10g, FACT_NET_TRD_SLS_IDX2 is used to scan the fact.
    Time dimension "MERGE JOIN CARTESIAN" to Product dimension first to form a data set, and then use it to filter the fact table.
    If the stats for FACT_NET_TRD_SLS_IDX2 let ORACLE believe that much less records will remain/survive after the join, 10g will use it.
    It seems to me that cartesian join Time x Product is going to generate a much bigger data set than estimated, then the nested loop after that will take a long time to iterate through.
    Why don't you partition your fact table BY RANGE(SLS_POSTD_DT_BE_ID) to make it simpler?

  • Spatial query runs slow on view

    Hello,
    I have two tables and one of them has geometry column. I created view to join those two tables based on id column which has been indexed for both tables.
    t1(
    id number(9),
    name varchar2(20)
    t2(
    id number(9),
    geom MDSYS.SDO_GEOMETRY
    CREATE VIEW v1 (
    id,
    name,
    geom
    ) AS
    SELECT /*+ FIRST_ROWS */ t1.id, t1.name, t2.geom
    FROM t1,t2
    WHERE t1.id = t2.id
    When I query the view with following statement it runs very slow (there are more then 1 million rows in t2 table)
    SELECT * FROM v1
    WHERE mdsys.sdo_filter(geom, [a rectangle],'querytype=window') = 'TRUE';
    but
    SELECT /*+ FIRST_ROWS */ t1.id, t1.name,t2.geom
    FROM t1,t2
    WHERE t1.id=t2.id
    and mdsys.sdo_filter(geom, [a rectangle],'querytype=window') = 'TRUE';
    returns almost instantly. Can some one tell me what is wrong with the "create view" statement?
    Thanks

    Thank you for your reply. Here are the plans. The view looks for the spatial index first.
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 21 | 756 | 10 (60)|
    | 1 | NESTED LOOPS | | 21 | 756 | 10 (60)|
    | 2 | TABLE ACCESS BY INDEX ROWID| T2 | 5269 | 123K| 3 (0)|
    | 3 | DOMAIN INDEX | T2_SDX | | | |
    | 4 | TABLE ACCESS BY INDEX ROWID| T1 | | | |
    | 5 | INDEX RANGE SCAN | T1_ID_IDX | 1 | | 0 (0)|
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 21 | 756 | 99 (3)|
    | 1 | TABLE ACCESS BY INDEX ROWID | T2 | 1 | 24 | 99 (3)|
    | 2 | NESTED LOOPS | | 21 | 756 | 99 (3)|
    | 3 | TABLE ACCESS FULL | T1 | 21 | 252 | 2 (0)|
    | 4 | BITMAP CONVERSION TO ROWIDS | | | | |
    | 5 | BITMAP AND | | | | |
    | 6 | BITMAP CONVERSION FROM ROWIDS| | | | |
    | 7 | INDEX RANGE SCAN | T2_ID_IDX | 1 | | 2 (0)|
    | 8 | BITMAP CONVERSION FROM ROWIDS| | | | |
    | 9 | SORT ORDER BY | | | | |
    | 10 | DOMAIN INDEX | T2_SDX | 1 | | |
    -----------------------------------------------------------------------------------------------------

  • SQL query running slow

    Hi
    i have a query when i run it for the first time it returs result in 30 mins after few mins (say 2 m ins) if i run the same query it fetches result in 3 mins) can any one hel me to tune the issu
    when i saw AWR report i showed too many disk I/o and sql messege to client wait events
    DB: Oracle 10g
    O/S: Unix
    DB cahce size :1GB
    help Pleae

    PLAN_TABLE_OUTPUT
    Plan hash value: 3961783764
    | Id  | Operation                            | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                     |                            |     2 |   390 |   361   (2)| 00:00:05 |
    |   1 |  SORT GROUP BY                       |                            |     2 |   390 |   361   (2)| 00:00:05 |
    |   2 |   VIEW                               |                            |     2 |   390 |   360   (1)| 00:00:05 |
    |   3 |    UNION-ALL                         |                            |       |       |            |          |
    |   4 |     NESTED LOOPS                     |                            |     1 |   297 |   344   (1)| 00:00:05 |
    |*  5 |      HASH JOIN                       |                            |     1 |   231 |   343   (1)| 00:00:05 |
    |   6 |       TABLE ACCESS FULL              | TRAN_VH_INV_SS_PART        |  3634 | 72680 |   213   (0)| 00:00:03 |
    |*  7 |       HASH JOIN                      |                            |  1799 |   370K|   129   (2)| 00:00:02 |
    |   8 |        TABLE ACCESS FULL             | MAST_MF_NAME               |     4 |    84 |     5   (0)| 00:00:01 |
    |*  9 |        HASH JOIN                     |                            |  1799 |   333K|   123   (1)| 00:00:02 |
    |* 10 |         HASH JOIN                    |                            |  1552 |   209K|   120   (1)| 00:00:02 |
    |* 11 |          TABLE ACCESS FULL           | HIST_VH_INV_SS_PART        |  1188 | 62964 |   115   (0)| 00:00:02 |
    |  12 |          NESTED LOOPS                |                            | 24566 |  2039K|     4   (0)| 00:00:01 |
    |  13 |           TABLE ACCESS BY INDEX ROWID| MAST_YM_YARD               |     1 |    29 |     1   (0)| 00:00:01 |
    |* 14 |            INDEX UNIQUE SCAN         | MAST_YM_YARD_01            |     1 |       |     0   (0)| 00:00:01 |
    |  15 |           TABLE ACCESS BY INDEX ROWID| TRAN_VH_INV_SUB_SERVICE    | 24566 |  1343K|     3   (0)| 00:00:01 |
    |* 16 |            INDEX RANGE SCAN          | TRAN_VH_INV_SUB_SERVICE_02 |     1 |       |     2   (0)| 00:00:01 |
    |  17 |         TABLE ACCESS BY INDEX ROWID  | TRAN_VH_INV                |  3863 |   196K|     3   (0)| 00:00:01 |
    |* 18 |          INDEX RANGE SCAN            | TRAN_VH_INV_02             |     1 |       |     2   (0)| 00:00:01 |
    |* 19 |      TABLE ACCESS BY INDEX ROWID     | TRAN_VH_INV_WORKSHEET      |     1 |    66 |     1   (0)| 00:00:01 |
    |* 20 |       INDEX UNIQUE SCAN              | TRAN_VH_INV_WORKSHEET_01   |     1 |       |     0   (0)| 00:00:01 |
    |  21 |     NESTED LOOPS                     |                            |     1 |   297 |    16   (0)| 00:00:01 |
    |  22 |      NESTED LOOPS                    |                            |     1 |   277 |    14   (0)| 00:00:01 |
    |  23 |       NESTED LOOPS                   |                            |     1 |   224 |    10   (0)| 00:00:01 |
    |  24 |        NESTED LOOPS                  |                            |     1 |   203 |     9   (0)| 00:00:01 |
    |  25 |         NESTED LOOPS                 |                            |     1 |   151 |     7   (0)| 00:00:01 |
    |  26 |          NESTED LOOPS                |                            |     1 |    85 |     5   (0)| 00:00:01 |
    |  27 |           TABLE ACCESS BY INDEX ROWID| MAST_YM_YARD               |     1 |    29 |     1   (0)| 00:00:01 |
    |* 28 |            INDEX UNIQUE SCAN         | MAST_YM_YARD_01            |     1 |       |     0   (0)| 00:00:01 |
    |  29 |           TABLE ACCESS BY INDEX ROWID| TRAN_VH_SHP_SUB_SERVICE    |     1 |    56 |     4   (0)| 00:00:01 |
    |* 30 |            INDEX RANGE SCAN          | TRAN_VH_SHP_SUB_SERVICE_02 |     1 |       |     3   (0)| 00:00:01 |
    |* 31 |          TABLE ACCESS BY INDEX ROWID | TRAN_VH_SHP_WORKSHEET      |     1 |    66 |     2   (0)| 00:00:01 |
    |* 32 |           INDEX UNIQUE SCAN          | TRAN_VH_SHP_WORKSHEET_01   |     1 |       |     1   (0)| 00:00:01 |
    |* 33 |         TABLE ACCESS BY INDEX ROWID  | TRAN_VH_SHP                |     1 |    52 |     2   (0)| 00:00:01 |
    |* 34 |          INDEX UNIQUE SCAN           | TRAN_VH_SHP_01             |     1 |       |     1   (0)| 00:00:01 |
    |  35 |        TABLE ACCESS BY INDEX ROWID   | MAST_MF_NAME               |     1 |    21 |     1   (0)| 00:00:01 |
    |* 36 |         INDEX UNIQUE SCAN            | MAST_MF_NAME_01            |     1 |       |     0   (0)| 00:00:01 |
    |* 37 |       TABLE ACCESS BY INDEX ROWID    | HIST_VH_SHP_SS_PART        |     1 |    53 |     4   (0)| 00:00:01 |
    |* 38 |        INDEX RANGE SCAN              | HIST_VH_SHP_SS_PART_01     |     5 |       |     2   (0)| 00:00:01 |
    |* 39 |      TABLE ACCESS BY INDEX ROWID     | TRAN_VH_SHP_SS_PART        |     1 |    20 |     2   (0)| 00:00:01 |
    |* 40 |       INDEX UNIQUE SCAN              | TRAN_VH_SHP_SS_PART_01     |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       5 - access("C"."SUB_SERVICE_SEQ_NUM"="H"."SUB_SERVICE_SEQ_NUM" AND
                  "C"."PDI_PART_ORDER_NUM"="H"."PDI_PART_ORDER_NUM" AND
                  "C"."SUB_SERVICE_PART_SEQ_NUM"="H"."SUB_SERVICE_PART_SEQ_NUM")
       7 - access("D"."MFG_CODE"="E"."MFG_CODE")
       9 - access("D"."YARD_CODE"="A"."YARD_CODE" AND "D"."VIN_NUM"="B"."VIN_NUM" AND
                  "B"."TERMINAL_SEQ_NO"="D"."TERMINAL_SEQ_NO" AND "B"."YARD_CODE"="D"."YARD_CODE")
      10 - access("B"."SUB_SERVICE_SEQ_NUM"="C"."SUB_SERVICE_SEQ_NUM")
      11 - filter("C"."PART_FRANCHISE">=U' ' AND TRUNC(INTERNAL_FUNCTION("C"."ACTUAL_ISSUE_DATE_TIME"))<>TO_DAT
                  E(' 0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  TRUNC(INTERNAL_FUNCTION("C"."ISSUE_DATE_TIME"))<=TO_DATE(' 2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
                  AND "C"."PART_FRANCHISE"<=U'~')
      14 - access("A"."TERMINAL_SEQ_NO"=1 AND "A"."YARD_CODE"=U'1')
      16 - access("B"."TERMINAL_SEQ_NO"=1 AND "B"."YARD_CODE"=U'1')
      18 - access("D"."TERMINAL_SEQ_NO"=1 AND "D"."YARD_CODE"=U'1')
      19 - filter("G"."YARD_CODE"=U'1' AND TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))<>TO_DATE('
                  0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "G"."TERMINAL_SEQ_NO"=1 AND
                  (TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))>=TO_DATE(' 2010-06-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))<=TO_DATE(' 2010-06-30 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss') OR TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))<TO_DATE(' 2010-06-01
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND (TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))>=TO_DATE('
                  2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss') OR TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))>=TO_DATE(
                   2010-06-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))<=TO_DAT
    E
                  (' 2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss') OR
                  TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))=TO_DATE(' 0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
                  OR TRUNC(INTERNAL_FUNCTION("C"."ISSUE_DATE_TIME"))>=TO_DATE(' 2010-06-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND TRUNC(INTERNAL_FUNCTION("C"."ISSUE_DATE_TIME"))<=TO_DATE(' 2010-06-30 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) AND "G"."VIN_NUM"="D"."VIN_NUM")
      20 - access("G"."WORKSHEET_NUM"="B"."WORKSHEET_NUM")
      28 - access("A"."TERMINAL_SEQ_NO"=1 AND "A"."YARD_CODE"=U'1')
      30 - access("B"."TERMINAL_SEQ_NO"=1 AND "B"."YARD_CODE"=U'1')
      31 - filter("G"."YARD_CODE"=U'1' AND TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))<>TO_DATE('
                  0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "G"."TERMINAL_SEQ_NO"=1)
      32 - access("G"."WORKSHEET_NUM"="B"."WORKSHEET_NUM")
      33 - filter("D"."YARD_CODE"=U'1' AND "D"."TERMINAL_SEQ_NO"=1)
      34 - access("G"."VIN_NUM"="D"."VIN_NUM")
           filter("D"."VIN_NUM"="B"."VIN_NUM")
      36 - access("D"."MFG_CODE"="E"."MFG_CODE")
      37 - filter("C"."PART_FRANCHISE">=U' ' AND TRUNC(INTERNAL_FUNCTION("C"."ACTUAL_ISSUE_DATE_TIME"))<>TO_DAT
                  E(' 0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  TRUNC(INTERNAL_FUNCTION("C"."ISSUE_DATE_TIME"))<=TO_DATE(' 2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
                  AND "C"."PART_FRANCHISE"<=U'~' AND (TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))>=TO_DATE(' 2010-06-01
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))<=TO_DATE('
                  2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss') OR TRUNC(INTERNAL_FUNCTION("G"."START_DATE_TIME"))<TO_DATE
                  ' 2010-06-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  (TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))>=TO_DATE(' 2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss')
                  OR TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))>=TO_DATE(' 2010-06-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))<=TO_DATE(' 2010-06-30 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss') OR TRUNC(INTERNAL_FUNCTION("G"."END_DATE_TIME"))=TO_DATE(' 0001-01-01 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) OR TRUNC(INTERNAL_FUNCTION("C"."ISSUE_DATE_TIME"))>=TO_DATE(' 2010-06-01
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND TRUNC(INTERNAL_FUNCTION("C"."ISSUE_DATE_TIME"))<=TO_DATE('
                  2010-06-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss')))
      38 - access("B"."SUB_SERVICE_SEQ_NUM"="C"."SUB_SERVICE_SEQ_NUM")
      39 - filter("C"."PDI_PART_ORDER_NUM"="H"."PDI_PART_ORDER_NUM")
      40 - access("C"."SUB_SERVICE_SEQ_NUM"="H"."SUB_SERVICE_SEQ_NUM" AND
    PLAN_TABLE_OUTPUT
                  "C"."SUB_SERVICE_PART_SEQ_NUM"="H"."SUB_SERVICE_PART_SEQ_NUM")
    Note
       - SQL profile "SYS_SQLPROF_014aab7522964001" used for this statementEdited by: user629451 on Sep 22, 2010 12:23 AM
    Edited by: user629451 on Sep 22, 2010 12:25 AM

  • Delete query is slow in one schema.

    Hi All,
    I have two schemas in a database PRDPUB and TOOLSERVER . In both the schemas i have a table BP_USER_PROFILE containg same amount of data , indexes and constrains. I am using one delete query to delete 26000 records from both the table , but in PRDPUB schema it is hanging but in TOOLSERVER schema it is running fine.When i tried to delete 100 records using the same query in PRDPUB schema it is taking 44 second nad 13 milisecond in TOOLSERVER.
    when i generated the exution plan it is very much same .But when i see the trace file i see in PRDPUB schema it is accessing the disk and doing parsing and execution 2 times , while in TOOLSERVER schema it is deleting in memory and parsing and executing once.
    For your reference i am attching the expalin plan and trace file output. Please help me out to resolve the issue.
    explain plan for delete from bp_user_profile where id_user in (select id_user from (SELECT * FROM bp_user_profile WHERE
    id_home_category=5005 AND DT_USER_LAST_UPDATED <'01-DEC-09' AND ID_USER_STATUS_ACTIVE ='DELETED_BY_ADMIN'
    OR ID_USER_STATUS_ACTIVE ='DELETED_BY_USER') where rownum<=100);
    PLAN_TABLE_OUTPUT in PRDPUB schema
    Plan hash value: 288284804
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | DELETE STATEMENT | | 100 | 7600 | 1906 (1)| 00:00:23 |
    | 1 | DELETE | BP_USER_PROFILE | | | | |
    | 2 | NESTED LOOPS | | 100 | 7600 | 1906 (1)| 00:00:23 |
    | 3 | VIEW | VW_NSO_1 | 100 | 1300 | 1885 (1)| 00:00:23 |
    | 4 | SORT UNIQUE | | 100 | 2100 | | |
    |* 5 | COUNT STOPKEY | | | | | |
    |* 6 | TABLE ACCESS BY INDEX ROWID | BP_USER_PROFILE | 86428 | 1772K| 1885 (1)| 00:00:23 |
    | 7 | BITMAP CONVERSION TO ROWIDS | | | | | |
    | 8 | BITMAP OR | | | | | |
    | 9 | BITMAP CONVERSION FROM ROWIDS | | | | | |
    |* 10 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 12 (0)| 00:00:01 |
    | 11 | BITMAP AND | | | | | |
    | 12 | BITMAP CONVERSION FROM ROWIDS| | | | | |
    |* 13 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 2 (0)| 00:00:01 |
    | 14 | BITMAP CONVERSION FROM ROWIDS| | | | | |
    |* 15 | INDEX RANGE SCAN | BP_USR_PROF_IDCATG | | | 79 (2)| 00:00:01 |
    |* 16 | INDEX UNIQUE SCAN | BP_USR_PROF_PK_ID_USER | 1 | 63 | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    5 - filter(ROWNUM<=100)
    6 - filter("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER' OR "ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN' AND
    "ID_HOME_CATEGORY"=5005 AND "DT_USER_LAST_UPDATED"<'01-DEC-09')
    10 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER')
    13 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN')
    15 - access("ID_HOME_CATEGORY"=5005)
    PLAN_TABLE_OUTPUT
    16 - access("ID_USER"="$nso_col_1")
    PLAN_TABLE_OUTPUT
    Plan hash value: 288284804
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | DELETE STATEMENT | | 102 | 7752 | 2892 (2)| 00:00:35 |
    | 1 | DELETE | BP_USER_PROFILE | | | | |
    | 2 | NESTED LOOPS | | 102 | 7752 | 2892 (2)| 00:00:35 |
    | 3 | VIEW | VW_NSO_1 | 100 | 1300 | 2871 (1)| 00:00:35 |
    | 4 | SORT UNIQUE | | 100 | 2100 | | |
    |* 5 | COUNT STOPKEY | | | | | |
    |* 6 | TABLE ACCESS BY INDEX ROWID | BP_USER_PROFILE | 170K| 3500K| 2871 (1)| 00:00:35 |
    | 7 | BITMAP CONVERSION TO ROWIDS | | | | | |
    | 8 | BITMAP OR | | | | | |
    | 9 | BITMAP CONVERSION FROM ROWIDS | | | | | |
    |* 10 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 22 (0)| 00:00:01 |
    | 11 | BITMAP AND | | | | | |
    | 12 | BITMAP CONVERSION FROM ROWIDS| | | | | |
    |* 13 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 22 (0)| 00:00:01 |
    | 14 | BITMAP CONVERSION FROM ROWIDS| | | | | |
    |* 15 | INDEX RANGE SCAN | BP_USR_PROF_IDCATG | | | 78 (2)| 00:00:01 |
    |* 16 | INDEX UNIQUE SCAN | BP_USR_PROF_PK_ID_USER | 1 | 63 | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    5 - filter(ROWNUM<=100)
    6 - filter("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER' OR "ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN' AND
    "ID_HOME_CATEGORY"=5005 AND "DT_USER_LAST_UPDATED"<'01-DEC-09')
    10 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER')
    13 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN')
    15 - access("ID_HOME_CATEGORY"=5005)
    PLAN_TABLE_OUTPUT
    16 - access("ID_USER"="$nso_col_1")
    34 rows selected.
    =====================================
    trace file out put:
    delete from prdpub.bp_user_profile where id_user in (select id_user from (SELECT * FROM prdpub.bp_user_profile WHERE
    id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1" AND ID_USER_STATUS_ACTIVE =:"SYS_B_2"
    OR ID_USER_STATUS_ACTIVE =:"SYS_B_3") where rownum<=:"SYS_B_4")
    call count cpu elapsed disk query current rows
    Parse 2 0.00 0.00 0 0 0 0
    Execute 2 0.61 0.61 1027 1574 8292 200
    Fetch 0 0.00 0.00 0 0 0 0
    total 4 0.61 0.61 1027 1574 8292 200
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: SYS
    Rows Row Source Operation
    0 DELETE BP_USER_PROFILE (cr=1542994 pr=527 pw=0 time=43954914 us)
    100 NESTED LOOPS (cr=794 pr=13 pw=0 time=125348 us)
    100 VIEW VW_NSO_1 (cr=558 pr=0 pw=0 time=95818 us)
    100 SORT UNIQUE (cr=558 pr=0 pw=0 time=95618 us)
    100 COUNT STOPKEY (cr=558 pr=0 pw=0 time=94328 us)
    100 TABLE ACCESS BY INDEX ROWID BP_USER_PROFILE (cr=558 pr=0 pw=0 time=94325 us)
    103 BITMAP CONVERSION TO ROWIDS (cr=481 pr=0 pw=0 time=93891 us)
    1 BITMAP OR (cr=481 pr=0 pw=0 time=93879 us)
    1 BITMAP CONVERSION FROM ROWIDS (cr=88 pr=0 pw=0 time=11643 us)
    22224 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=88 pr=0 pw=0 time=77 us)(object id 89712)
    1 BITMAP AND (cr=393 pr=0 pw=0 time=80750 us)
    1 BITMAP CONVERSION FROM ROWIDS (cr=10 pr=0 pw=0 time=1150 us)
    1911 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=10 pr=0 pw=0 time=21 us)(object id 89712)
    3 BITMAP CONVERSION FROM ROWIDS (cr=383 pr=0 pw=0 time=105831 us)
    181506 INDEX RANGE SCAN BP_USR_PROF_IDCATG (cr=383 pr=0 pw=0 time=26 us)(object id 88278)
    100 INDEX UNIQUE SCAN BP_USR_PROF_PK_ID_USER (cr=236 pr=13 pw=0 time=8945 us)(object id 88279)
    delete from toolserver.bp_user_profile where id_user in (select id_user from (SELECT * FROM toolserver.bp_user_profile WHERE
    id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1" AND ID_USER_STATUS_ACTIVE =:"SYS_B_2"
    OR ID_USER_STATUS_ACTIVE =:"SYS_B_3") where rownum<=:"SYS_B_4")
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.13 0.12 0 741 3144 100
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.13 0.12 0 741 3144 100
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: SYS
    Rows Row Source Operation
    0 DELETE BP_USER_PROFILE (cr=741 pr=0 pw=0 time=123855 us)
    100 NESTED LOOPS (cr=741 pr=0 pw=0 time=95704 us)
    100 VIEW VW_NSO_1 (cr=528 pr=0 pw=0 time=94093 us)
    100 SORT UNIQUE (cr=528 pr=0 pw=0 time=94091 us)
    100 COUNT STOPKEY (cr=528 pr=0 pw=0 time=93729 us)
    100 TABLE ACCESS BY INDEX ROWID BP_USER_PROFILE (cr=528 pr=0 pw=0 time=93724 us)
    102 BITMAP CONVERSION TO ROWIDS (cr=490 pr=0 pw=0 time=93380 us)
    1 BITMAP OR (cr=490 pr=0 pw=0 time=93369 us)
    1 BITMAP CONVERSION FROM ROWIDS (cr=93 pr=0 pw=0 time=11663 us)
    22722 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=93 pr=0 pw=0 time=78 us)(object id 87755)
    1 BITMAP AND (cr=397 pr=0 pw=0 time=80340 us)
    1 BITMAP CONVERSION FROM ROWIDS (cr=11 pr=0 pw=0 time=1118 us)
    1911 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=11 pr=0 pw=0 time=15 us)(object id 87755)
    3 BITMAP CONVERSION FROM ROWIDS (cr=386 pr=0 pw=0 time=104382 us)
    181849 INDEX RANGE SCAN BP_USR_PROF_IDCATG (cr=386 pr=0 pw=0 time=24 us)(object id 87758)
    100 INDEX UNIQUE SCAN BP_USR_PROF_PK_ID_USER (cr=213 pr=0 pw=0 time=1194 us)(object id 87754)
    Edited by: user12956550 on Apr 8, 2010 11:03 AM

    Hi,
    is your delete correct?
    delete from toolserver.bp_user_profile where id_user in (select id_user from (SELECT * FROM toolserver.bp_user_profile WHERE
    id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1" AND ID_USER_STATUS_ACTIVE =:"SYS_B_2"
    OR ID_USER_STATUS_ACTIVE =:"SYS_B_3") where rownum<=:"SYS_B_4")There is a suspected OR in the where clause, I expect you have to check both statusses with the date and home category, so I think your query should be (add parenthesisses around the two statusses):
    delete from toolserver.bp_user_profile where id_user in (select id_user from (SELECT * FROM toolserver.bp_user_profile WHERE
    id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1"
    AND
    ( -- added
    ID_USER_STATUS_ACTIVE =:"SYS_B_2"
    OR ID_USER_STATUS_ACTIVE =:"SYS_B_3"
    ) -- added
    ) where rownum<=:"SYS_B_4")Further is the content the same, if these are different, you could also have differences in execution time.
    Herald ten Dam
    Superconsult.nl

Maybe you are looking for

  • How can i sync my iPhoto Library to 2 macs using the same Apple ID?

    Hi, I have 2 mac book pros (1 in the office and 1 at home) and I have all my photos saved on my office mac iPhoto Library. Is there a way I can sync both iPhoto Libraries? I will be using 1 Apple ID or account for both macs. Thanks

  • Anyone know of a List with categories?

    I am trying to make a list with sections so like an alphabetic list, but in the list I would like to have sections with titles (see below). Wondering if anyone has seen an example of something close to this. I plan on having A through Z at the top an

  • Problems with lack of connection between macs on a network.

    For about a month i've had both my macbook and Mac Pro connecting fine over my network but suddenly they don't recognise each other.Is this a problem with my proxie settings within the Network Settings??.Sorry if this question is answered on the foru

  • Burning images to a CD

    This might be a dumb question but how do you copy images on to a CD? It was easy in iPhoto but I can't find the steps in Aperture. Many thanks

  • HT2311 iTunes

    I've downloaded the latest iTunes onto my mac and I can't install it, a message comes up saying "This software requires Mac OS X version 10.6.8 or later" I don't know what to do considering I can't upload anything to my iPhone 5 without updating my i