Long running select statement and v$session_longops

Oracle Version: 10.2.0.4
I've a long running sql query that takes the estimated 6 minutes to complete and return the result.
While it's running I'd like to observe it into the view v$session_longops.
I altered the session that runs the query with
  ALTER SESSION SET timed_statistics=TRUE;The tables it queries have gathered statistics on them.
However I don't see any rows in the view v$session_longops for the respective SID and serial#. Why is that? What am I missing?
Thank you!

Hi,
Now I understand what you all meant by "loops" here .. Yes, the query does nested loops as one can see from the execution plan. So it could be the reason
SELECT STATEMENT, GOAL = ALL_ROWS                                  
SORT GROUP BY                                                             
  CONCATENATION                              
   TABLE ACCESS BY LOCAL INDEX ROWID     TABLE_1
    NESTED LOOPS                                                   
     NESTED LOOPS
      TABLE ACCESS BY GLOBAL INDEX ROWID     TABLE_2      
       INDEX RANGE SCAN                           IPK_t2_CDATE                               
      TABLE ACCESS BY INDEX ROWID     TABLE_3
       INDEX RANGE SCAN                     IPK_T3                            
     PARTITION RANGE ALL                                                 
      INDEX RANGE SCAN     IRGP_REGCODE                        
   TABLE ACCESS BY LOCAL INDEX ROWID     TABLE_1
    NESTED LOOPS                                                  
     NESTED LOOPS          
      TABLE ACCESS BY GLOBAL INDEX ROWID     TABLE_2     
       INDEX RANGE SCAN                       IPK_t2_STATUS          
      TABLE ACCESS BY INDEX ROWID     TABLE_3     
       INDEX RANGE SCAN                       IPK_T3
     PARTITION RANGE SINGLE               
      INDEX RANGE SCAN                     IRGP_REGCODE          

Similar Messages

  • Bind Variable in SELECT statement and get the value  in PL/SQL block

    Hi All,
    I would like  pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
    Please seee below
    I want to get the below value
    Expected result:
    select  distinct empno ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    100, HR
    select  distinct ename ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    TEST, HR
    select  distinct loc ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    NYC, HR
    Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
    Please suggest
    ----- TABLE LIST
    CREATE TABLE EMP(
    EMPNO NUMBER,
    ENAME VARCHAR2(255),
    DEPT VARCHAR2(255),
    LOC    VARCHAR2(255)
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
    COMMIT;
    CREATE TABLE COLUMNAMES(
    COLUMNAME VARCHAR2(255)
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
    COMMIT;
    CREATE TABLE DEPT(
    DEPT VARCHAR2(255),
    DNAME VARCHAR2(255)
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    COMMIT;
    PL/SQL BLOCK
    DECLARE
      TYPE EMPCurTyp  IS REF CURSOR;
      v_EMP_cursor    EMPCurTyp;
      l_col_val           EMP.ENAME%type;
      l_ENAME_val       EMP.ENAME%type;
    l_col_ddl varchar2(4000);
    l_col_name varchar2(60);
    l_tab_name varchar2(60);
    l_empno number ;
    b_l_col_name VARCHAR2(255);
    b_l_empno NUMBER;
    begin
    for rec00 in (
    select EMPNO aa from  EMP
    loop
    l_empno := rec00.aa;
    for rec in (select COLUMNAME as column_name  from  columnames
    loop
    l_col_name := rec.column_name;
    begin
      l_col_val :=null;
       l_col_ddl := 'select  distinct :b_l_col_name ,pr.dept ' ||'  from emp pr, dept ps where   ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
       dbms_output.put_line('DDL ...'||l_col_ddl);
       OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
    LOOP
        l_col_val :=null;
        FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
        EXIT WHEN v_EMP_cursor%NOTFOUND;
          dbms_output.put_line('l_col_name='||l_col_name ||'  empno ='||l_empno);
       END LOOP;
    CLOSE v_EMP_cursor;
    END;
    END LOOP;
    END LOOP;
    END;

    user1758353 wrote:
    Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
    As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
    However, the data structures are just that - structured. Logical.
    Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
    There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model.

  • Concat java variable to a MySql select statement and exeucte

    Hi,
    I am trying to append a variable to a MySql select statement.
    Overview: I need to retrieve data from a MySql database with a java variable as a reference and select the data in the database based on that variable.
    CODE THAT I CURRENTLY HAVE:
    // Declare variables
    Connection conn = null;
    Statement st = null;
    Resultset rs2 = null;
    String st2 = null;
    String keyid = null;
    // Connect to database
    try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
          st = conn.createStatement();
          // Select data in Database with hanging equal sign
          st2 = ("SELECT * FROM table WHERE keyid= ");
          // Append keyid to hanging equal sign of select statement
          rs2 = st.executeQuery(st2 + keyid);
    }This is not working when I try to display the data.

    What is not working about it? Is there an error message? Stack Trace?
    Where do you get the value of keyId from?
    I would suggest that you use a prepared statement rather than building up a sql string like this. It prevents sql injection attacks
    // Declare variables
    Connection conn = null;
    PreparedStatement stmt = null;
    Resultset rs2 = null;
    String sql= null;
    String keyid = null;
    // Connect to database
    try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
          // Select data in Database with place holder for parameter
          sql = "SELECT * FROM table WHERE keyid= ?";
           // prepare the statement
          stmt = conn.prepareStatement(sql);
          // set the value of key id to use with the query
          stmt.setString(1, keyId);
          // run the query
          rs2 = st.executeQuery();
    catch (Exception e){
      System.out.println("An error occurred " + e.getMessage());
      e.printStackTrace();
    finally{
      if (rs2 != null) try { rs2.close(); } catch(SQLException ex){}
      if (stmt != null) try { stmt.close(); } catch(SQLException ex){}
      if (conn != null) try { con.close(); } catch(SQLException ex){}
    }

  • Long running Update-Statement

    I'm having a update-Statement that is running in Version 1.1 more than 30 minutes, but in Version 1.0 and SQL-Plus only 30 seconds.
    SQL-Developer is running on WinXP
    Oracle is Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    and this was the statement (witch is updating 2830 rows):
    update hist_person p1
    set letzte_vermittlung = (select letzte_vermittlung from hist_person p2
    where p2.datum = add_months(date '2006-01-01',-1)
    and p2.p_nr = p1.p_nr)
    where p1.datum = date '2006-01-01'
    and p1.p_nr in (select aktmon.p_nr
    from hist_person vormon, hist_person aktmon
    where aktmon.datum = date '2006-01-01'
    and vormon.datum = add_months(date '2006-01-01',-1)
    and vormon.p_nr = aktmon.p_nr
    and vormon.letzte_vermittlung > nvl(aktmon.letzte_vermittlung, date '1900-01-01'));

    Mmm, read up on the "NLS_COMP set to ANSI" threads.
    Try setting NLS_COMP to binary for the session, then run your update and see if that fixes the issue. If so, the forthcoming patch will probably fix the issue, else get back here...
    K.

  • Inline select statement and SQL optimizatino

    Hi everyone,
    I am trying to optimze a script but can't get the fulle explainplan in PL/SQL.
    The problem is that the select statements in de column defenition is not explained. below are the 2 scripts I want to compare:
    SQL1:
    Select
    z.title
    , (select name from members where id =z.id) as name
    , z.id
    from job z
    SQL2
    Select
    z.title
    , d.name
    , z.id
    from job z
    left outer join members d on z.id=d.id
    My question is: what is the effect on performance and cost of the 'inline select' statement of name in SQL1
    hope to hear form you soon
    Harm
    Edited by: HALI on 25-nov-2010 1:14

    In respons to your question below is the output:
    I altered the used names, tablenames etc. according to our privacy pollacy.
    A far as I can see the inline statement is not traced.
    The query with ansi-join:
    xplain plan for
    select
      id as Interne
    , mv.ie_id as Act
    , 'H_W' as Rl
    from testing i
    left outer join resutino m on i.hand=m.id
       left outer join vert mv on m.voor || case when m.voeg is not null then ' '|| m.voeg end ||' '||m.naam = mv.source and mv.field = 'employee'
    explain plan succeeded.
    select * from table(dbms_xplan.display)
    PLAN_TABLE_OUTPUT                                                                                                                                                                                       
    | Id  | Operation            |  Name               | Rows  | Bytes | Cost  |                                                                                                                            
    |   0 | SELECT STATEMENT     |                     |   684 | 47880 |    19 |                                                                                                                            
    |   1 |  HASH JOIN OUTER     |                     |   684 | 47880 |    19 |                                                                                                                            
    |   2 |   HASH JOIN OUTER    |                     |   684 | 22572 |    15 |                                                                                                                            
    |   3 |    TABLE ACCESS FULL | testing             |   684 |  5472 |     7 |                                                                                                                            
    |   4 |    TABLE ACCESS FULL | resutino            |   308 |  7700 |     7 |                                                                                                                            
    |   5 |   TABLE ACCESS FULL  | VERT                |   166 |  6142 |     3 |                                                                                                                            
    Note: cpu costing is off, 'PLAN_TABLE' is old version                                                                                                                                                   
    13 rows selected
    The inline select query:
    xplain plan for
    SELECT
    case when (select ie_id  from vert xov where xov.field = 'field' and source in
              (select m.voor || case when m.voeg is not null then ' '|| m.voegend ||' '||m.naam from resultino m where i.hand= m.id)) is not null then
              'X'||(select ie_id  from vert xov where xov.field = 'field' and source in
              (select m.voor || case when m.voeg is not null then ' '|| m.voegend ||' '||m.naam from resultino m where i.hand= m.id))
         else 'X' || (select ie_id from vert xov where xov.source = 'none' and xov.veld = 'employee')
    end                                                    as  Act,
    'ADM' as  Rol,
    i.id as  Interne
    FROM testing i
    explain plan succeeded.
    select * from table(dbms_xplan.display)
    PLAN_TABLE_OUTPUT                                                                                                                                                                                       
    | Id  | Operation            |  Name         | Rows  | Bytes | Cost  |                                                                                                                                  
    |   0 | SELECT STATEMENT     |               |   684 |  5472 |     7 |                                                                                                                                  
    |   1 |  TABLE ACCESS FULL   | testing       |   684 |  5472 |     7 |                                                                                                                                  
    Note: cpu costing is off, 'PLAN_TABLE' is old version                                                                                                                                                   
    9 rows selected

  • Long running update statement needs a performance improve.

    Hi,
    I have the following update statement which runs for over 3 hours and updates 215 million rows, is there anyway I can rewrite it so it performs better?
    UPDATE TABLE1 v
            SET closs = (SELECT MIN(slloss)
                               FROM TABLE2 l
            WHERE polnum = slpoln
            AND      polren = slrenn
            AND      polseq = slseqn
            AND      vehnum = slvehn
            AND      linecvg = sllcvg);Here is the execution plan:
    PLAN_TABLE_OUTPUT
    | Id  | Operation                     | Name        | Rows  | Bytes | Cost (%CPU)|
    |   0 | UPDATE STATEMENT              |             |   214M|  4291M|  2344K  (2)|
    |   1 |  UPDATE                       | TABLE1      |       |       |            |
    |   2 |   TABLE ACCESS FULL           | TABLE1      |   214M|  4291M|  2344K  (2)|
    |   3 |   SORT AGGREGATE              |             |     1 |    21 |            |
    |   4 |    TABLE ACCESS BY INDEX ROWID| TABLE2      |     1 |    21 |     5   (0)|
    |   5 |     INDEX RANGE SCAN          | TABLE2_N2   |     2 |       |     3   (0)|
    ----------------------------------------------------------------------------------Here are create table statements for TABLE1(215million rows) and TABLE2(1million rows):
    CREATE TABLE  TABLE2 (SLCLMN VARCHAR2(11 byte),
        SLFEAT NUMBER(2), SLPOLN NUMBER(9), SLRENN NUMBER(2),
        SLSEQN NUMBER(2), SLVEHN NUMBER(2), SLDRVN NUMBER(2),
        SLCVCD VARCHAR2(6 byte), SLLCVG NUMBER(4), SLSABB
        VARCHAR2(2 byte), SLPRCD VARCHAR2(3 byte), SLRRDT
        NUMBER(8), SLAYCD NUMBER(7), SLCITY VARCHAR2(28 byte),
        SLZIP5 NUMBER(5), SLCEDING VARCHAR2(1 byte), SLCEDELOSS
        VARCHAR2(1 byte), SLRISKTYPE VARCHAR2(1 byte), SLVEHDESIG
        VARCHAR2(1 byte)) 
        TABLESPACE S_DATA PCTFREE 10 PCTUSED 0 INITRANS 1
        MAXTRANS 255
        STORAGE ( INITIAL 106496K NEXT 0K MINEXTENTS 1 MAXEXTENTS
        2147483645 PCTINCREASE 0)
        NOLOGGING
        MONITORING;
    CREATE TABLE  TABLE1 (POLNUM NUMBER(9) NOT NULL,
        POLREN NUMBER(2) NOT NULL, POLSEQ NUMBER(2) NOT NULL,
        VEHNUM NUMBER(2) NOT NULL, CVGCODE VARCHAR2(8 byte) NOT
        NULL, LINECVG NUMBER(4), MAINVEH CHAR(1 byte), MAINCVG
        CHAR(1 byte), CVGLIMIT VARCHAR2(13 byte), CVGDED
        VARCHAR2(10 byte), FULLCVG CHAR(1 byte), CVGGRP CHAR(4
        byte), CYCVG CHAR(1 byte), POLTYPE CHAR(1 byte),
        CHANNEL CHAR(2 byte), UWTIER VARCHAR2(6 byte), SUBTIER
        VARCHAR2(6 byte), THITIER VARCHAR2(3 byte), COMPGRP
        VARCHAR2(8 byte), PRODGRP VARCHAR2(6 byte), UWSYS
        VARCHAR2(6 byte), BRAND VARCHAR2(8 byte), COMP NUMBER(2),
        STATE CHAR(2 byte), PROD CHAR(3 byte), RRDATE DATE,
        STATENUM NUMBER(2), EFT_BP CHAR(1 byte), AGYCODE
        NUMBER(7), AGYSUB CHAR(3 byte), AGYCLASS CHAR(1 byte),
        CLMAGYCODE NUMBER(7), AGYALTCODE VARCHAR2(25 byte),
        AGYRELATION VARCHAR2(10 byte), RATECITY VARCHAR2(28 byte),
        RATEZIP NUMBER(5), RATETERR NUMBER, CURTERR NUMBER,
        CURRRPROD CHAR(6 byte), CURRRDATE DATE, RATESYMB NUMBER,
        SYMBTYPE CHAR(1 byte), CVGTERR NUMBER(3), CVGSYMB
        NUMBER(3), VEHTERR NUMBER, VEHYEAR NUMBER, VEHMAKE
        VARCHAR2(6 byte), VEHMODEL VARCHAR2(10 byte), VEHSUBMOD
        VARCHAR2(10 byte), VEHBODY VARCHAR2(6 byte), VEHVIN
        VARCHAR2(10 byte), VEHAGE NUMBER(3), VEHSYMB NUMBER,
        DRVNUM NUMBER, DUMMYDRV CHAR(1 byte), DRVAGE NUMBER(3),
        DRVSEX VARCHAR2(1 byte), DRVMS VARCHAR2(1 byte), DRVPTS
        NUMBER(3), DRVPTSDD NUMBER(3), DRVGRP CHAR(7 byte),
        DRVSR22 VARCHAR2(1 byte), DRVVTIER CHAR(2 byte),
        BUSUSESUR CHAR(1 byte), EXCLDRVSUR CHAR(1 byte),
        CSCODED NUMBER(5), CSACTUAL NUMBER(5), CSOVERRD
        NUMBER(5), ANNMILES NUMBER(6), DLORIGDATE DATE,
        DLLASTDATE DATE, DLMONTHS NUMBER(6), MATUREDSC CHAR(1
        byte), PERSISTDSC CHAR(1 byte), ANNUALMILES_RANGE
        VARCHAR2(25 byte), CEDEDLOSS VARCHAR2(1 byte), CEDEDPOL
        VARCHAR2(1 byte), CEDEDCVG VARCHAR2(1 byte),
        CONSTRAINT TABLE1_PK PRIMARY KEY(POLNUM, POLREN,
        POLSEQ, VEHNUM, CVGCODE)
        USING INDEX 
        TABLESPACE V_INDEX
        STORAGE ( INITIAL 3874816K NEXT 0K MINEXTENTS 1 MAXEXTENTS
        2147483645 PCTINCREASE 0) PCTFREE 10 INITRANS 2 MAXTRANS 255)
        TABLESPACE U_DATA PCTFREE 10 PCTUSED 0 INITRANS 1
        MAXTRANS 255
        STORAGE ( INITIAL 4194304K NEXT 0K MINEXTENTS 1 MAXEXTENTS
        2147483645 PCTINCREASE 0)
        NOLOGGING
        MONITORING;Thank you very much!

    user6053424 wrote:
    Hi,
    I have the following update statement which runs for over 3 hours and updates 215 million rows, is there anyway I can rewrite it so it performs better?
    UPDATE TABLE1 v
    SET closs = (SELECT MIN(slloss)
    FROM TABLE2 l
    WHERE polnum = slpoln
    AND      polren = slrenn
    AND      polseq = slseqn
    AND      vehnum = slvehn
    AND      linecvg = sllcvg);
    Are you trying to perform a correlated update? If so, you can perform something similar to;
    Sample data;
    create table t1 as (
       select 1 id, 10 val from dual union all
       select 1 id, 10 val from dual union all
       select 2 id, 10 val from dual union all
       select 2 id, 10 val from dual union all
       select 2 id, 10 val from dual);
    Table created
    create table t2 as (
       select 1 id, 100 val from dual union all
       select 1 id, 200 val from dual union all
       select 2 id, 500 val from dual union all
       select 2 id, 600 val from dual);
    Table createdThe MERGE will update each row based on the maximum for each ID;
    merge into t1
    using (select id, max(val) max_val
           from t2
           group by id) subq
    on (t1.id = subq.id)
    when matched then update
        set t1.val = subq.max_val;
    Done
    select * from t1;
            ID        VAL
             1        200
             1        200
             2        600
             2        600
             2        600If you want all rows updated to the same value then remove the ID grouping from the subquery and from the ON clause.

  • In Oracle SQL, cannot use column in select statement and order by

    Hi,
    Is there a work around for this.
    Thanks in advance
    Pablo.

    Hi,
    943981 wrote:
    Hi All,
    This is the error I get:
    ORA-00960: ambiguous column naming in select list
    00960. 00000 - "ambiguous column naming in select list"
    *Cause:    A column name in the order-by list matches more than one select
    list columns.
    *Action:   Remove duplicate column naming in select list.
    Error at Line: 6 Column: 17That error message looks pretty clear to me. What don't you understand?
    Either
    (a) use aliases, so each column has a unique name, or
    (b) remove duplicate columns from the SELECT clause.
    Post your query. It's hard to say exactly what you're doing wrong when we don't know exactly what you're doing.
    For best results, post a complete test script (including CREATE TABLE and INSERT statements, if necessary) that people can to re-create the problem and test their ideas.
    See the forum FAQ {message:id=9360002}

  • Query to run select statement conditionally

    Want: when either variable is null then run a full report, if both variables are not null then run the report with range specified
    I have the following query, but kept getting invliad sql error. Can you help ?
    IF (:P1_START_DATE IS NULL or :P1_END_DATE IS NULL)
    THEN select empno,ename,job,mgr, hiredate from emp;
    else IF (:P1_START_DATE IS NOT NULL and :P1_END_DATE IS NOT NULL)
    then select empno,ename,job,mgr, hiredate from emp where hiredate between :P1_START_DATE and :P1_END_DATE;
    end if;
    Tai

    Hi,
    The way most people deal with that problem is to always filter on parameters, but, when a parameter is not passed, make it default to some value that wuill include all rows. With DATEs, that's easy, because it's easy to specify the earliest and latest DATEs that are possible in Oracle:
    Assuming the datatype of :p1_start_date and :p1_end_date is DATE:
    SELECT  empno
    ,     ename
    ,     job
    ,     mgr
    ,     hiredate
    FROM    emp
    WHERE   hiredate     BETWEEN NVL ( :P1_START_DATE
                                      , T0_DATE ('1', 'J')
                             AND     NVL ( :P1_END_DATE
                            , TO_DATE ('31-Dec-9999')
    ;Te query above treats each parameter independently. If, say, :p1_start_date is NULL, but :p1_end_date is, say, January 1, 2005, then the query above would look for people hired on before January 1, 2005. That is, there would not be a lower limit to hiredate, because :p1_start_date was NULL, but there would be an upper limit, because :p1_end_date was not NULL.
    You're saying that if either parameter is NULL, you want to ignore both of them, not just the one that is NULL.
    Here's one way to do that:
    SELECT  empno
    ,     ename
    ,     job
    ,     mgr
    ,     hiredate
    FROM    emp
    WHERE   hiredate     BETWEEN NVL ( LEAST ( :P1_START_DATE
                                       , :P1_END_DATE
                                      , T0_DATE ('1', 'J')
                             AND     NVL ( GREATEST ( :P1_START_DATE
                                          , :P1_END_DATE
                            , TO_DATE ('31-Dec-9999')
    ;This will also automatically correct the error if someone enters the parameters in the wrong order.
    If you're doing this in PL/SQL, and speed is very impratant, then you may want to have tow separate queries (one with a WHERE clause, the other without), as in the example you posted.
    Edited by: Frank Kulash on Jun 18, 2010 3:29 PM
    MScallion's solution is better.
    It can be simplified like this:
    WHERE  :p1_start_date     IS NULL
    OR     :p1_end_date     IS NULL
    OR     hiredate          BETWEEN :p1_start_date
                          AND     :p1_end_date

  • Cfe01 export DIR to cFolders long run no message and multiple(100) versions

    Dear all,
    Greeting for the Day ! !
    I have one weird issue.. when i export DMS DIR to cFolders using Tcode cfe01,
    the process never ends and processing bar of SAP GUI appears for long time than i have to kill it using stop transaction.
    After that when i browse folder in cFolders the relevant document container contains 100s of versions of original file.
    i think it is some kind of loop in program getting executed...
    How could i fix this issue..
    Please suggest
    Thanking You,
    Tushar Dave

    OSS Raised and Issue resolved
    Solution: Maintain E-mail Address for RFCUSER

  • Latency is very high when SELECT statements are running for LONG

    We are a simple DOWN STREAM streams replication environment ( Archive log is shipped from source , CAPTURE & APPLY are running on destination DB).
    Whenever there is a long running SELECT statement on TARGET the latency become very high.
    SGA_MAX_SIZE = 8GB
    STREAMS_POOL_SIZE=2GB
    APPLY parallelism = 4
    How can resolve this issue?

    Is the log file shipped but not acknowledge? -- NO
    Is the log file not shipped? -- It is shipped
    Is the log file acknowledged by not applied? -- Yes...But Apply process was not stopped. it may be slow or waiting for something?
    It is 10g Environment. I will run AWR.. But what should i look for in AWR?

  • Desc table_name statements no longer running in sql developer

    simple desc statements like desc table_name; used to run in sql developer however they no longer work.
    It was working a few days ago and now the same statements dont return any results. The tables exist as I can run select statements fine just not desc table_name;
    Any ideas how this can be fixed?

    I haven't had problems with the "desc table_name;" functionality for a long time - do you know of anything that has changed since they were working a few days ago?
    If you run the following query with :1 being the table owner and :2 being the table name, do you get the columns listed?SELECT t.column_name "Name",
      DECODE(t.nullable,'Y',NULL,'NOT NULL') "Null",
      UPPER(t.data_type)
      ||
      CASE
        WHEN ( t.data_type = 'VARCHAR' OR t.data_type = 'VARCHAR2' OR t.data_type = 'RAW' OR t.data_type = 'CHAR' )
            AND ( t.data_length != 0 AND NVL(t.data_length,-1) != -1)
        THEN
          CASE
            WHEN(t.char_used = 'C' AND 'BYTE' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.char_length || ' CHAR)'
            WHEN(t.char_used = 'B' AND 'CHAR' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.data_length || ' BYTE)'
            WHEN(t.char_used = 'C' AND 'CHAR' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.char_length || ')'
            WHEN(t.char_used = 'B' AND 'BYTE' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.data_length || ')'
            ELSE '(' || t.data_length || ' BYTE)'
          END
        WHEN (t.data_type = 'NVARCHAR2' OR t.data_type = 'NCHAR')
        THEN '(' || t.data_length/2 || ')'
        WHEN (t.data_type LIKE 'TIMESTAMP%' OR t.data_type LIKE 'INTERVAL DAY%' OR t.data_type LIKE 'INTERVAL YEAR%' OR t.data_type = 'DATE' OR(t.data_type = 'NUMBER' AND (t.data_precision       = 0 OR NVL(t.data_precision,-1) = -1)))
        THEN ''
        WHEN (t.data_scale = 0 OR NVL(t.data_scale,-1) = -1)
        THEN '(' || t.data_precision ||')'
        ELSE '(' || t.data_precision ||',' ||t.data_scale ||')'
      END "Type"
    FROM sys.all_tab_columns t,
      sys.all_col_comments c
    WHERE t.column_name = c.column_name
    AND c.owner         = t.owner
    AND c.table_name    = t.table_name
    AND UPPER(t.owner)  = UPPER(:1)
    AND t.table_name    = :2
    ORDER BY t.column_idtheFurryOne

  • Auto retry of select statements on failure

    I have a IBM Message Broker message flow that accesses the database to fetch some data. following are the steps in a message flow. (similar pattern is there in other flows as well)
    1) Parse the input message
    2) Invoke a ESQL compute node that accesses the database. This uses DataDirect ODBC drivers to access the database.
    3) process the data
    4) Invoke an external Java class that also accesses the database. This Java class uses Spring/Hibernate and uses the Oracle UCP library.
    Steps 2 and 4 access an Oracle database on which failover features are NOT enabled. Following is our observation.
    If the database fails when executing step 2, then the message flow pauses until a valid connection is available and then proceeds with the execution, the point to note is that the message flow does not experience a failure. It simply pauses until it gets a connection and continues once it gets a connection.
    If the database fails when executing step 4, the message flow gets an error.
    What we want is for step 2 and 4 to execute the same way, meaning that we want the message flows to wait until a valid connection is available and then continue without any errors.
    I feel that there is some feature in DataDirect driver that cause step 2 to pause the message flow and prevent an error. We want the same behaviour in step 4 as well.
    So, is there some way (via configuration or any other means) to get this behaviour using oracle UCP library.
    One thing to note is that we are not in position to change the Java code since it has been developed by a third party.
    To achieve this I have written a test and the following are details.
    For this I have created a service with the following properties. Point to note is that we run the service on only one instance at a time, if it goes down then it is started on the second instance.
    Service name: LDL_TEST02
    Service is enabled
    Server pool: CSAHEDA_LDL_TEST02
    Cardinality: 1
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: true
    Failover type: SELECT
    Failover method: NONE
    TAF failover retries: 180
    TAF failover delay: 5
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: BASIC
    Edition:
    Preferred instances: CSAHEDA1
    Available instances: CSAHEDA2
    Following is in my tnsnames.ora file and I am using the oracle oci driver.
    TESTA =
    (DESCRIPTION =
    (ENABLE = BROKEN)
    (LOAD_BALANCE = off)
    (FAILOVER = on)
         (ADDRESS_LIST =
         (ADDRESS = (PROTOCOL = TCP)(HOST = vip.host1)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = vip.host2)(PORT = 1521)))
    (CONNECT_DATA =
    (SERVICE_NAME = LDL_TEST02)
    (FAILOVER_MODE =
    (BACKUP = TESTA2)
    (TYPE = SELECT)
    (METHOD = PRECONNECT)
    (RETRIES = 120)
    (DELAY = 5)
    This is how I run my test.
    1)I have a simple test that simply loops through a list of select statements.
    2)each time it takes a connection from the connection pool, executes the statement and returns the connection to the connection pool.
    3)I keep this running for around 10 minutes.
    4) once the test has started I bring down the service wait for 3 minutes and the start the service on the second instance.
    5) what I expect is for the test to pause for 3 minutes and then get the correct value from executing the select statement. and continue without pause.
    Following is the config for the connection pool.
         <bean id="dd_Datasource" class="oracle.ucp.jdbc.PoolDataSourceFactory" factory-method="getPoolDataSource">
              <property name="connectionFactoryClassName" value="oracle.jdbc.xa.client.OracleXADataSource"/>
              <!-- property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource"/ -->
              <!-- <property name="connectionFactoryClassName" value="sun.jdbc.odbc.ee.DataSource"/-->
              <!-- <property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LDL_TEST02)))" /> -->
              <!-- <property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LDL_TEST02)))" />-->
              <!-- property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2) (PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=LDL_TEST02)(FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))" /-->
              <!-- <property name="URL" value="jdbc:oracle:oci:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS_LIST=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2) (PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LDL_TEST01)(FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))" /> -->
              <property name="URL" value="jdbc:oracle:oci:/@TESTA" />
              <!-- JDBC ODBC Bridge Driver -->
              <!-- property name="URL" value="jdbc:odbc:LT_Test_DB"/-->
              <!-- DataDirect URLs -->
              <!-- property name="URL" value="datadirect:oracle://vip.host1:1521;SID=LDL_TEST01"/-->
              <property name="user" value="user" />
              <property name="password" value="user" />     
              <property name="connectionPoolName" value="dd_connectionpool" />
              <property name="minPoolSize" value="2" />
              <property name="maxPoolSize" value="4" />                     
              <property name="initialPoolSize" value="2" />
              <property name="connectionWaitTimeout" value="10000" />
              <!-- Note:
                   The setSQLForValidateConnection property is not recommended when using an Oracle JDBC driver.
                   UCP for JDBC performs an internal ping when using an Oracle JDBC driver.
                   The mechanism is faster than executing an SQL statement and is overridden if this property is set.
                   Instead, set the setValidateConnectionOnBorrow property to true and do not
                   include the setSQLForValidateConnection property. -->
              <property name="validateConnectionOnBorrow" value="true"/>
              <!-- FCF stuff -->
              <!-- property name="connectionCachingEnabled" value="true"/-->
              <!-- property name="fastConnectionFailoverEnabled" value="true"/-->
              <!-- <property name="ONSConfiguration" value="nodes=vip.host1:1521,vip.host2:1521"/>-->
         </bean>     
    As you can see I have tried many combinations.
    Sometimes I see the thread pause for 3 minutes without error and then continue.
    Sometime I start seeing 'oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource' as soon as the servic is down.
    Sometime the first error above is seen after 30 seconds (always the first one).
    Can you guys shed any light on this? And how can I get the desired behaviour?
    Edited by: user12181209 on 30-May-2012 02:22
    reworded.
    Edited by: user12181209 on May 30, 2012 6:28 AM
    reworded the title for clarity.
    Edited by: user12181209 on Jun 1, 2012 6:01 AM

    Hi,
    Yesterday, a similar question on running slow view was post :
    View is tooo slow....
    You can read different questions to try to help you.
    Nicolas.

  • Long running table partitioning job

    Dear HANA grus,
    I've just finished table partitioning jobs for CDPOS(change document item) with 4 partitions by hash with 3 columns.
    Total data volumn is around 340GB and the table size was 32GB !!!!!
    (migration job was done without disabling CD, so currently deleting data on the table with RSCDOK99)
    Before partitioning, the data volumn of the table was around 32GB.
    After partitioning, the size has changed to 25GB.
    It took around One and half hour with exclusive lock as mentioned in the HANA adminitration guide.
    (It is QA DB, so less complaints)
    I thought that I might not can do this in the production DB.
    Does anyone hava any idea for accelerating this task?? (This is the fastest DBMS HANA!!!!)
    Or Do you have any plan for online table partitioning functionality??(To HANA Development team)
    Any comments would be appreciate.
    Cheers,
    - Jason

    Jason,
    looks like we're cross talking here...
    What was your rationale to partition the table in the first place?
           => To reduce deleting time of CDPOS            (As I mentioned it was almost 10% quantity of whole Data volume, So I would like to save deleting time of the table from any pros of partitioning table like partitioning pruning)
    Ok, I see where you're coming from, but did you ever try out if your idea would actually work?
    As deletion of data is heavily related with locating the records to be deleted, creating an index would have probably be the better choice.
    Thinking about it... you want to get rid of 10% of your data and in order to speed the overall process up, you decide to move 100% of the data into sets of 25% of the data - equally holding their 25% share of the 10% records to be deleted.
    The deletion then should run along these 4 sets of 25% of data.
    It's surely me, but where is the speedup potential here?
    How many unloads happened during the re-partitioning?
           => It was fully uploaded in the memory before partitioning the table by myself.(from HANA studio)
    I was actually asking about unloads _during_ the re-partitioning process. Check M_CS_UNLOADS for the time frame in question.
    How do the now longer running SQL statements look like?
           => As i mentioned selecting/deleting increased almost twice.
    That's not what I asked.
    Post the SQL statement text that was taking longer.
    What are the three columns you picked for partitioning?
           => mandant, objectclas, tabname(QA has 2 clients and each of them have nearly same rows of the table)
    Why those? Because these are the primary key?
    I wouldn't be surprised if the SQL statements only refer to e.g. MANDT and TABNAME in the WHERE clause.
    In that case the partition pruning cannot work and all partitions have to be searched.
    How did you come up with 4 partitions? Why not 13, 72 or 213?
           => I thought each partitions' size would be 8GB(32GB/4) if they are divided into same size(just simple thought), and 8GB size is almost same size like other largest top20 tables in the HANA DB.
    Alright, so basically that was arbitrary.
    For the last comment of your reply, most people would do partition for their existing large tables to get any benefit of partitioning(just like me). I think your comment can be applied for the newly inserting data.
    Well, not sure what "most people" would do.
    HASH partitioning a large existing table certainly is not an activity that is just triggered off in a production system. Adding partitions to a range partitions table however happens all the time.
    - Lars

  • Need SSIS event handler for long running event

    Hi,
    I have a long running table load task that I would like to monitor using an event handler. I have tried the progress and information events but neither generates a message during the actual table load. Is there a way to invoke an
    event during the SSIS data flow task when it 1%, 2% done?
    thanks
    oldmandba

    Do you now how many rows the source table have ? You can run SELECT statement on the destination to find out how many data has been inserted.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Conditional Mysql select statement

    HI Folks
    can anyone point me in the right direction with a MySQL statement.
    I will try to layout my thinking here:
    I have a form with three inputs area, name and search. I am trying to write a Mysql select statement that selects records from a single table if they match the criteria. Easy for two variables but I'm lost after that.
    1. The form includes these three inputs:
    area - drop down menu (Any as default)
    name - drop down menu (Any as default)
    search box - text area (Blank as default)
    2. The form submits to itself leaving me with these three variables
    $search=$_GET['search']
    $area=$_GET['area']
    $name=$_GET['area']
    SELECT * FROM database WHERE database.description LIKE '%$search%' AND database.area LIKE '$area' AND database.name LIKE '$name'
    3. This is where I get confused. How do I get the SQL to Select everything correctly. I have tried using PHP if/else code to fix it but I end up running around in circles with six different Select statements and haven't yet got that to work.
    So I have come to the conclusion that there must be an easier way.  I see search forms with dozens of  search criteria on websites every day an d I only have 3 - so it can't be this complicated. Right?
    I know I need to start from the beginning again but can anyone let me know how to approach it before I begin?
    Cheers
    Dave

    Typically, I would build the where clause dynamically, based upon the values in your form. If the form field contains 'Any', leave it out of the where clause. So you can test each field value and either append or not to the end of the where clause.

Maybe you are looking for

  • ISE - What happens when the on-boarded certificate expires?

    I'm trying to design a good BYOD deployment model but have a few questions that need direct answers.  I have down how to go about on-boarding and getting a certificate on a device, the ISE provides great flow for this to happen in many ways.  My ques

  • RADIUS won't start after upgrading to 10.6

    I upgraded a Mac mini from 10.5 to 10.6 recently, and for some reason RADIUS won't start. The only way I can get it going is to run "radiusd -X" from the CLI which starts it in debug mode. Has anyone else had this problem? It doesn't seem to log any

  • Changes to a Script

    Hello, I have a script that I'm hoping that someone could help me change a few problem spots with it ?

  • Starting managed server

    Hi all, I have two servers in which the first server is having admin server and a managed server. And the second server is having a managed server which is clustered to the first one. But the problem is i can see the admin server running in the admin

  • I don't have the option "Create from Scanner".  How do I scan my documents?

    I am trying to scan multiple documents (to save and email), but I don't have the option of "Create from Scanner" on the Adobe Reader XI.  How do I scan my documents (multiple pages on one file, not each page on a seperate file)?