Correlated subquery execution problem

Hi
In correlated subqueries which query executed first whether the inner query or outer query i.e while oracle processing the query
give me example
thanx
asp

I would say the outer query would be executed first as the inner query is dependant upon that but I guess in some circumstances the CBO will turn this rule on its head
SQL> select ename from emp
  2  where exists ( select null from dept where dept.deptno = emp.deptno )
  3  /
ENAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME
JAMES
FORD
MILLER
14 rows selected.
Execution Plan
   0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=14 Bytes=16
          8)
   1    0   NESTED LOOPS (SEMI) (Cost=4 Card=14 Bytes=168)
   2    1     TABLE ACCESS (FULL) OF 'EMP' (TABLE) (Cost=3 Card=14 Byt
          es=126)
   3    1     INDEX (UNIQUE SCAN) OF 'PK_DEPT' (INDEX (UNIQUE)) (Cost=
          1 Card=7 Bytes=21)
  1  select ename from emp
  2* where not exists ( select null from dept where dept.deptno = emp.deptno )
SQL> /
no rows selected
Execution Plan
   0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=1 Bytes=12)
   1    0   NESTED LOOPS (ANTI) (Cost=4 Card=1 Bytes=12)
   2    1     TABLE ACCESS (FULL) OF 'EMP' (TABLE) (Cost=3 Card=14 Byt
          es=126)
   3    1     INDEX (UNIQUE SCAN) OF 'PK_DEPT' (INDEX (UNIQUE)) (Cost=
          1 Card=7 Bytes=21)

Similar Messages

  • Top n Analysis using correlated subquery

    Please explain this query. It is doing top n analysis using correlated subquery. I need explaination of execution of this query.
    Select distinct a.sal
    From emp a
    where 1=(select count ( distinct b.sal) from emp b
         where a.sal <=b.sal)
    Thanks in advance

    Try breaking the query down and rewriting it in order to follow the logic;
    SQL> --
    SQL> -- Start by getting each salary from emp along with a count of all salaries in emp
    SQL> --
    SQL> select   a.sal,
            (select count (distinct b.sal) from scott.emp b ) count_sal
    from scott.emp a
    order by 1 desc
           SAL  COUNT_SAL
          5000         12
          3000         12
          3000         12
          2975         12
          2850         12
          2450         12
          1600         12
          1500         12
          1300         12
          1250         12
          1250         12
          1100         12
           950         12
           800         12
    14 rows selected.
    SQL> --
    SQL> --Add a condition to the count for only salaries below or equal to the current salarySQL> --
    SQL> select   a.sal,
            (select count (distinct b.sal) from scott.emp b where a.sal <=b.sal) rank_sal
    from scott.emp a
    order by 1 desc
           SAL   RANK_SAL
          5000          1
          3000          2
          3000          2
          2975          3
          2850          4
          2450          5
          1600          6
          1500          7
          1300          8
          1250          9
          1250          9
          1100         10
           950         11
           800         12
    14 rows selected.
    SQL> --
    SQL> -- Add a condition to only pick the nth highest salary
    SQL> --
    SQL> select    a.sal,
             (select count (distinct b.sal) from scott.emp b where a.sal <=b.sal) rank_sal
    from scott.emp a
    where (select count (distinct b.sal) from scott.emp b where a.sal <=b.sal) = 4
           SAL   RANK_SAL
          2850          4
    1 row selected.Hope this helps.

  • SQL Bug in "Minus" in correlated subquery presence of index (11.2.0.1.0)

    SQL Bug in "Minus" in correlated subquery presence of index
    (Oracle Database 11g Release 11.2.0.1.0)
    Below, there is a small example that shows the bug. Further below,
    there are some more comments.
    drop table Country;
    create table Country
    (code VARCHAR2(4) constraint countrykey PRIMARY KEY,
    name VARCHAR2(35));
    -- if the key constraint is not given, the bug does not occur
    drop table City;
    create table City
    (name VARCHAR2(35),
    country VARCHAR2(4),
    population number);
    drop table Locatedon;
    create table Locatedon
    (city VARCHAR2(35),
    country VARCHAR2(4),
    island VARCHAR2(35));
    insert into country values('E','Spain');
    insert into country values('F','France');
    insert into country values('S','Sweden');
    insert into country values('GB','Sweden');
    insert into city values('Ajaccio','F',53500);
    insert into city values('Paris','F',2152423);
    insert into city values('Palma','E',322008);
    insert into city values('Madrid','E',3041101);
    insert into city values('Stockholm','S',711119);
    insert into city values('London','GB',6967500);
    insert into locatedon values('Ajaccio','F','Corse');
    insert into locatedon values('Palma','E','Mallorca');
    insert into locatedon values('London','GB','Great Britain');
    -- all countries that have a city that is not located on
    -- some island: should be E, F, S.
    Select c.name
    From country c
    Where exists
    ((Select name
    From city
    Where city.country=c.code)
    minus
    (Select city
    From locatedon
    Where locatedon.country=c.code)
    -- wrong answer: only Sweden; Spain and France not in the answer!
    select distinct country from
    ((Select name, country
    From city)
    minus
    (Select city, country
    From locatedon)
    -- correct answer: E, F, S
    Comments:
    The bug has been found by students in our SQL course.
    Using a larger database from that course, the bug can be reproduced
    (same queries as above) at
    http://www.semwebtech.org/sqlfrontend/
    (wrong: 142 answers, correct: 154 answers)
    During reducing it to a simple sample, there were some interesting
    observations: trying with smaller and simpler tables (without the keys)
    and synthetic data, the bug did not occur immediately. When
    restating the query after about one day, the bug occurred. Obviously,
    Oracle creates some index on its own in course of its internal
    optimization that (or more exactly, its usage) exhibits the bug. The
    query plan (showed in SQL Developer) was the same before and after.
    Wolfgang

    There's a typo in the test data - GB should presumably not be in Sweden. However....
    the bug did not occur immediatelyIt's possible. But what would have almost certainly happened is that the execution plan DID change at some point. There are various reasons why it might not be immediate.
    Obviously, Oracle creates some index on its own in course of its internal optimizationFar from obvious, what are you on about?
    The query plan was the same before and afterBet you it wasn't.
    A clear illustration of the issue and indication that it must be a bug is below.
    Simply by hinting a different access method, we can change the result. Therefore, bug.
    See [url http://support.oracle.com]Oracle Support and search for "wrong results".
    Please raise with Oracle Support to get confirmation of bug.
    There have been so many wrong results bugs recently, it's getting ridiculous.
    It's a real issue, IMHO.
    If you can't trust the DB to get your data right....
    Note that the query plan is very much NOT the same and it is the difference in query plan which s that is the root cause of the bug.
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL> SELECT c.name
      2  FROM   country1 c
      3  WHERE  exists ((SELECT name
      4                  FROM   city1
      5                  WHERE  city1.country=c.code)
      6                  MINUS
      7                 (SELECT city
      8                  FROM   locatedon1
      9                  WHERE  locatedon1.country=c.code));
    NAME
    Sweden
    SQL> SELECT /*+ full(c) */
      2         c.name
      3  FROM   country1 c
      4  WHERE  exists ((SELECT name
      5                  FROM   city1
      6                  WHERE  city1.country=c.code)
      7                  MINUS
      8                 (SELECT city
      9                  FROM   locatedon1
    10                  WHERE  locatedon1.country=c.code));
    NAME
    Spain
    France
    Sweden
    SQL> explain plan for
      2  SELECT c.name
      3  FROM   country1 c
      4  WHERE  exists ((SELECT name
      5                  FROM   city1
      6                  WHERE  city1.country=c.code)
      7                  MINUS
      8                 (SELECT city
      9                  FROM   locatedon1
    10                  WHERE  locatedon1.country=c.code));
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 156929629
    | Id  | Operation                    | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |            |     1 |    27 |    12  (25)| 00:00:01 |
    |   1 |  NESTED LOOPS                |            |       |       |            |          |
    |   2 |   NESTED LOOPS               |            |     1 |    27 |    12  (25)| 00:00:01 |
    |   3 |    VIEW                      | VW_SQ_1    |     6 |    24 |    10  (20)| 00:00:01 |
    |   4 |     MINUS                    |            |       |       |            |          |
    |   5 |      SORT UNIQUE             |            |     6 |   138 |            |          |
    |   6 |       TABLE ACCESS FULL      | CITY1      |     6 |   138 |     4   (0)| 00:00:01 |
    |   7 |      SORT UNIQUE             |            |     3 |    69 |            |          |
    |   8 |       TABLE ACCESS FULL      | LOCATEDON1 |     3 |    69 |     4   (0)| 00:00:01 |
    |*  9 |    INDEX UNIQUE SCAN         | COUNTRYKEY |     1 |       |     0   (0)| 00:00:01 |
    |  10 |   TABLE ACCESS BY INDEX ROWID| COUNTRY1   |     1 |    23 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       9 - access("VW_COL_1"="C"."CODE")
    Note
       - dynamic sampling used for this statement (level=4)
    26 rows selected.
    SQL> explain plan for
      2  SELECT /*+ full(c) */
      3         c.name
      4  FROM   country1 c
      5  WHERE  exists ((SELECT name
      6                  FROM   city1
      7                  WHERE  city1.country=c.code)
      8                  MINUS
      9                 (SELECT city
    10                  FROM   locatedon1
    11                  WHERE  locatedon1.country=c.code));
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1378726376
    | Id  | Operation            | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |            |     1 |    23 |    14  (15)| 00:00:01 |
    |*  1 |  FILTER              |            |       |       |            |          |
    |   2 |   TABLE ACCESS FULL  | COUNTRY1   |     4 |    92 |     4   (0)| 00:00:01 |
    |   3 |   MINUS              |            |       |       |            |          |
    |   4 |    SORT UNIQUE       |            |     1 |    23 |     5  (20)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL| CITY1      |     1 |    23 |     4   (0)| 00:00:01 |
    |   6 |    SORT UNIQUE       |            |     1 |    23 |     5  (20)| 00:00:01 |
    |*  7 |     TABLE ACCESS FULL| LOCATEDON1 |     1 |    23 |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter( EXISTS ( (SELECT "NAME" FROM "CITY1" "CITY1" WHERE
                  "CITY1"."COUNTRY"=:B1)MINUS (SELECT "CITY" FROM "LOCATEDON1" "LOCATEDON1"
                  WHERE "LOCATEDON1"."COUNTRY"=:B2)))
       5 - filter("CITY1"."COUNTRY"=:B1)
       7 - filter("LOCATEDON1"."COUNTRY"=:B1)
    Note
       - dynamic sampling used for this statement (level=4)
    27 rows selected.Just to show that it's related to query transformation:
    SQL> SELECT /*+ 
      2             no_query_transformation
      3         */
      4         c.name
      5  FROM   country1 c
      6  WHERE  exists ((SELECT name
      7                  FROM   city1
      8                  WHERE  city1.country=c.code)
      9                  MINUS
    10                 (SELECT city
    11                  FROM   locatedon1
    12                  WHERE  locatedon1.country=c.code));
    NAME
    Spain
    France
    Sweden
    SQL> Edited by: Dom Brooks on Jun 30, 2011 2:50 PM

  • JDOQL Correlated Subquery - Bad SQL

    Hi,
    When I execute a JDOQL correlated subquery, the generated SQL is either
    invalid or incorrect. Exactly what happens depends on the exact query, and
    on the target database type, but I believe it all stems from the same
    problem, which has to do with table aliasing.
    If you need further details to reproduce this, please let me know. I'll be
    glad to help in any way I can to get this situation remedied quickly, as I
    am depending on this functionality. I have a test application to
    demonstrate the problem.
    I'm using Kodo 3.3.3 and application identity.
    Paul Mogren
    CommerceHub

    For the record, this is in part due to a bug in Kodo's SQL92 joining.
    See http://bugzilla.solarmetric.com/show_bug.cgi?id=1156
    -Patrick
    Paul Mogren wrote:
    Certainly... Here's a simple example using Microsoft's JDBC Driver for SQL
    Server 2000, and kodo.jdbc.sql.SQLServerDictionary, which produces invalid
    SQL.
    The query:
    pm.newQuery(Container.class,
    "(select from Entry entry where entries.contains(entry) &&
    entry.containedId != 1).isEmpty()");
    The classes:
    class Contained {
    private int id; //pk
    class Container {
    private int id; //pk
    private Set entries = new HashSet(); //<Entry>
    class Entry {
    private int containerId; //pk
    private int containedId; //pk
    private Container container; //persistent-redundant
    private Contained contained; //persistent-redundant
    The result:
    Incorrect syntax near the keyword 'WHERE'. {prepstmnt 31598780 SELECT
    t0.container_id, t0.lock FROM  WHERE (NOT EXISTS (SELECT DISTINCT
    t2.contained_id, t2.container_id FROM dbo.entry t2 WHERE (t1.contained_id
    = t2.contained_id AND t1.container_id = t2.container_id AND
    t2.contained_id <> ?) AND t0.container_id = t1.container_id))
    [params=(int) 1]} [code=156, state=HY000]
    Patrick Linskey wrote:
    Hi Paul,
    Kodo's correlated subquery support does have some known limitations. Can
    you post a sample JDOQL statement + corresponding SQL statement?
    -Patrick
    Paul Mogren wrote:
    Hi,
    When I execute a JDOQL correlated subquery, the generated SQL is either
    invalid or incorrect. Exactly what happens depends on the exact query, and
    on the target database type, but I believe it all stems from the same
    problem, which has to do with table aliasing.
    If you need further details to reproduce this, please let me know. I'll be
    glad to help in any way I can to get this situation remedied quickly, as I
    am depending on this functionality. I have a test application to
    demonstrate the problem.
    I'm using Kodo 3.3.3 and application identity.
    Paul Mogren
    CommerceHub

  • Second Time, RFC execution Problem!

    Hi all,
    Has any one encountered this problem, when calling RFC First time fine and getting data from BAPI, when i call same RFC again, Second Time, RFC execution Problem!. Any idea!, Now i restarted server, that may cause the problem. Other than this, please give me your idea.
    Thanks
    Ravi Golla

    Hi Bhavik,
    <b>In View Controller:</b>
    public void onActionCreateProject(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionCreateProject(ServerEvent)
        wdThis.wdGetArchCompController().CreateProject();
         wdThis.wdFirePlugOutToProjectCreationResult();
        //@@end
    <b>In Custom Controller:
    </b>
    wdDoInit()
    __Arch__Arm_Project_Create_Input create = new __Arch__Arm_Project_Create_Input();
         wdContext.node__Arch__Arm_Project_Create_Input().bind(create);
    public void CreateProject( )
        //@@begin CreateProject()
         try
                             wdContext.current__Arch__Arm_Project_Create_InputElement().modelObject().execute();
                             wdContext.nodeOutput().invalidate();
                        catch(WDDynamicRFCExecuteException ex)
                             wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(ex.toString());
                             ex.printStackTrace();
        //@@end
    I am using other functional modules they all working fine, this is one only has problem
    Thanks  Bhavic.
    Regards
    Ravi

  • Performance of using a Select For Update vs a correlated subquery

    I was wondering wether or not it is more effecient to use the
    Select ... For Update (with a cursor etc.) versus a correlated
    subquery.
    I can accomplish the same thing with either however performance
    at our site is an issue.

    Use select for update cursor as that is faster as it updates
    based on the rowid. One thing to keep in mind is that rowid is
    session specific and the rows to be updated get locked so that
    nobody else can update them till the lock is released. I have
    had very good performance results with these cursors.
    Good luck !
    Sudha

  • How does oracle execute a correlated subquery .... some confusion

    How does oracle 10g execute a correlated subquery?
    I read some articles online & i am a little confused.
    example:
    select * from emp e
    where e.deptno in (select d.deptno from dept d
    where e.deptno = d.deptno);
    My questions .......
    1.In the above example, does oracle read the entire outer table first and then run the inner query using the rows returned by the outer query?
    I read in some articles that they execute simultaneously.
    How does this work?
    2.Should the inner query have lesser amount of rows compared to the outer query for a good performance?
    3.Can every correlated subquery be converted to a join and if so which one to use?
    Truly appreciate any inputs on how oracle executes it at the backend.
    Thanks in advance.

    user10541890 wrote:
    How does oracle 10g execute a correlated subquery?
    I read some articles online & i am a little confused.
    example:
    select * from emp e
    where e.deptno in (select d.deptno from dept d
    where e.deptno = d.deptno);
    My questions .......
    1.In the above example, does oracle read the entire outer table first and then run the inner query using the rows returned by the outer query?
    I read in some articles that they execute simultaneously.
    How does this work?SQL is not a procedural language. SQL code specifies what the system sill do, not how the system wlll do it; that's entirely up to the system.
    What does it matter to you whether the two are done together, or if one is completed before the other begins?
    The system will probably choose to run ucorellated subqueiris only once, and correlated queries multiple times as needed.
    2.Should the inner query have lesser amount of rows compared to the outer query for a good performance?That usually doesn't matter.
    It some cases, you may want to consider whether the subquery is correlated or not. If the subquery is very costly, and produces, say, 1 million rows, but you know the main query will only produce about 5 rows, then you may want to do a correlated subquery rather than an uncorrelated one.
    3.Can every correlated subquery be converted to a join and if so which one to use?I believe so.
    Use whichever is easier to code and debug. That will change depnding on the data and the requirements.
    If performance is an issue, try different ways. Usually, where I've noticed a big difference, join was fastest.
    By the way, it's unusual to have a correlated IN-subquery.
    Usually IN-subqueris are uncorrelated, like this:
    select  *
    from      emp     e
    where     e.deptno     in ( select  d.deptno
                        from    dept     d
                      );(This and the queries below produce the same resutls as your original query.)
    Correlated subqueries are usually used for scalar subqueries or EXISTS subqueries, like this:
    select  *
    from      emp     e
    where     EXISTS ( select  d.deptno
               from    dept     d
                    where   e.deptno = d.deptno
                );To do the same thing with a join:
    select  e.*
    from      emp     e
    join     dept     d     on     e.deptno     = d.deptno
    ;assuming dept.deptno is unique.

  • Difference between a regular subquery and a correlated subquery

    Can someone explain EXACTLY what is a correlated subquery and could you give me an example? I'm taking an Oracle DBA class and I would appreciate your feedback. Thanks. :)

    "Normal" subquery (the subquery is executed only once for the statement):
    select name
    from emp
    where salary > (select avg(emp2.salary) from emp emp2);
    Correlated subquery (it is executed for each row of the main query):
    select name
    from emp
    where salary > (select avg(salary) from emp emp2
    where emp2.deptno = emp.deptno);
    Can someone explain EXACTLY what is a correlated subquery and could you give me an example? I'm taking an Oracle DBA class and I would appreciate your feedback. Thanks. :)

  • QA08 execution problem

    Hi all,
    QA08 execution problem, one material lying in QA32 stock that is cancel condition only (qa32 status for the material is LTCA, CALC) so I canu2019t deactivate the insp type through QA08, kindly help me to solve the problem.

    Hi,
    Thanks a lot your suggestion is 100% correct, problem has solved.
    Regards,
    Karthick.

  • Scalar Correlated Subquery Problem

    SELECT a.unit_id
    , NVL((
    SELECT COUNT(*)
    FROM (
    SELECT b.unit_id
    , b.rfq_id
    , b.vendor_id
    FROM RFQ_DISPATCHED b
    WHERE b.unit_id a.unit_id
    AND b.vendor_id = a.vendor_id
    AND b.rfq_id = a.rfq_id
    GROUP BY a.business_unit, a.rfq_id, a.vendor_id)),0) AS bid_qty
    FROM rfq_disp_hdr a
    WHERE a.unit_id = '00021'
    Oracle won't let me do this. Is it because it's correlated to a Query View? I know I can just create a view as a work around and then do a select on the view but any other suggestions on how to handle it?
    Thanks all!!

    Hi,
    Damorgan is right; whenever you have a question, you should post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data, and an explanation of how you get from the data to the results
    (4) Your best attempt so far (formatted) (You posted this, but since it's unformated, it's very hard to read.)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
    Formatted tabular output is okay for (3). Type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
    You've been using this forum longer than I have; you should know this by now.
    It looks like the immediate problem is that you're trying to correlate a sub-query to its grandparent, not its parent. That is, the scalar sub-query could be correlated to the main query (its parent), and the in-line view could be corellated to the scalar sub-query (its parent), but the in-line view can not be correlated to the main query.
    Why are you using an in-line view? It looks like what you're trying to do is:
    SELECT      a.unit_id
    ,      NVL ( (
              SELECT        COUNT(*)
              FROM        RFQ_DISPATCHED b
              WHERE        b.unit_id a.unit_id
              AND        b.vendor_id     = a.vendor_id
              AND        b.rfq_id      = a.rfq_id
              GROUP BY  a.business_unit
              ,       a.rfq_id
              ,       a.vendor_id
             , 0
             ) AS bid_qty
    FROM      rfq_disp_hdr      a
    WHERE      a.unit_id      = '00021'but I think if correct this error, you'll just get another one. GROUPing by correlated values is very suspicious. So is doing a GROUP BY in a scalar sub-query like you're doing.
    If you really want to solve this problem, you'll have to post the information requested.

  • Subquery execution plan issue

    Hi All,
    Oracle v11.2.0.2
    I have a SELECT query which executes in less than a second and selects few records.
    Now, if I put this SELECT query in IN clause of a DELETE command, that takes ages (even when DELETE is done using its primary key).
    See below query and execution plan.
    Here is the SELECT query
    SQL> SELECT   ITEM_ID
      2                         FROM   APP_OWNER.TABLE1
      3                        WHERE   COLUMN1 = 'SomeValue1234'
      4                                OR (COLUMN1 LIKE 'SomeValue1234%'
      5                                    AND REGEXP_LIKE (
      6                                          COLUMN1,
      7                                          '^SomeValue1234[A-Z]{3}[0-9]{5}$'
      8  ));
       ITEM_ID
      74206192
    1 row selected.
    Elapsed: 00:00:40.87
    Execution Plan
    Plan hash value: 3153606419
    | Id  | Operation          | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |             |     2 |    38 |     7   (0)| 00:00:01 |
    |   1 |  CONCATENATION     |             |       |       |            |          |
    |*  2 |   INDEX RANGE SCAN | PK_TABLE1   |     1 |    19 |     4   (0)| 00:00:01 |
    |*  3 |   INDEX UNIQUE SCAN| PK_TABLE1   |     1 |    19 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("COLUMN1" LIKE 'SomeValue1234%')
           filter("COLUMN1" LIKE 'SomeValue1234%' AND  REGEXP_LIKE
                  ("COLUMN1",'^SomeValue1234[A-Z]{3}[0-9]{5}$'))
       3 - access("COLUMN1"='SomeValue1234')
           filter(LNNVL("COLUMN1" LIKE 'SomeValue1234%') OR LNNVL(
                  REGEXP_LIKE ("COLUMN1",'^SomeValue1234[A-Z]{3}[0-9]{5}$')))
    Statistics
              0  recursive calls
              0  db block gets
              8  consistent gets
              0  physical reads
              0  redo size
            348  bytes sent via SQL*Net to client
            360  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processedNow see the DELETE command. ITEM_ID is the primary key for TABLE2
    SQL> delete from TABLE2 where ITEM_ID in (
      2  SELECT   ITEM_ID
      3                         FROM   APP_OWNER.TABLE1
      4                        WHERE   COLUMN1 = 'SomeValue1234'
      5                                OR (COLUMN1 LIKE 'SomeValue1234%'
      6                                    AND REGEXP_LIKE (
      7                                          COLUMN1,
      8                                          '^SomeValue1234[A-Z]{3}[0-9]{5}$'
      9  ))
    10  );
    1 row deleted.
    Elapsed: 00:02:12.98
    Execution Plan
    Plan hash value: 173781921
    | Id  | Operation               | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | DELETE STATEMENT        |                             |     4 |   228 | 63490   (2)| 00:12:42 |
    |   1 |  DELETE                 | TABLE2                      |       |       |            |          |
    |   2 |   NESTED LOOPS          |                             |     4 |   228 | 63490   (2)| 00:12:42 |
    |   3 |    SORT UNIQUE          |                             |     1 |    19 | 63487   (2)| 00:12:42 |
    |*  4 |     INDEX FAST FULL SCAN| I_TABLE1_3                  |     1 |    19 | 63487   (2)| 00:12:42 |
    |*  5 |    INDEX RANGE SCAN     | PK_TABLE2                   |     7 |   266 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter("COLUMN1"='SomeValue1234' OR "COLUMN1" LIKE 'SomeValue1234%' AND
                  REGEXP_LIKE ("COLUMN1",'^SomeValue1234[A-Z]{3}[0-9]{5}$'))
       5 - access("ITEM_ID"="ITEM_ID")
    Statistics
              1  recursive calls
              5  db block gets
         227145  consistent gets
         167023  physical reads
            752  redo size
            765  bytes sent via SQL*Net to client
           1255  bytes received via SQL*Net from client
              4  SQL*Net roundtrips to/from client
              3  sorts (memory)
              0  sorts (disk)
              1  rows processedWhat can be the issue here?
    I tried NO_UNNEST hint, which made difference, but still the DELETE was taking around a minute (instead of 2 minutes), but that is way more than that sub-second response.
    Thanks in advance

    rahulras wrote:
    SQL> delete from TABLE2 where ITEM_ID in (
    2  SELECT   ITEM_ID
    3                         FROM   APP_OWNER.TABLE1
    4                        WHERE   COLUMN1 = 'SomeValue1234'
    5                                OR (COLUMN1 LIKE 'SomeValue1234%'
    6                                    AND REGEXP_LIKE (
    7                                          COLUMN1,
    8                                          '^SomeValue1234[A-Z]{3}[0-9]{5}$'
    9  ))
    10  );
    The optimizer will transform this delete statement into something like:
    delete from table2 where rowid in (
        select t2.rowid
        from
            table2 t2,
            table1 t1
        where
                t1.itemid = t2.itemid  
        and     (t1.column1 =  etc.... )
    )With the standalone subquery against t1 the optimizer has been a little clever with the concatenation operation, but it looks as if there is something about this transformed join that makes it impossible for the concatenation mechanism to be used. I'd also have to guess that something about the way the transformation has happened has made Oracle "lose" the PK index. As I said in another thread a few minutes ago, I don't usually look at 10053 trace files to solve optimizer problems - but this is the second one today where I'd start looking at the trace if it were my problem.
    You could try rewriting the query in this explicit join and select rowid form - that way you could always force the optimizer into the right path through table1. It's probably also possible to hint the original to make the expected path appear, but since the thing you hint and the thing that Oracle optimises are so different it might turn out to be a little difficult. I'd suggest raising an SR with Oracle.
    Regards
    Jonathan Lewis

  • Package execution problem with SQLSERVERAGENT

    Hello,
    I'm having a problem with the execution of SSIS packages: I created locally a package with SQL Server Data Tools, then I deployed it on my server in the SSISDB database. Then I created a job to execute periodically this package with SQL Server Agent. The
    package works fine and does everything I want, but I always get a failed notification. In the global view of the execution I can see:
    Result: "failed"
    Package name: "Package.dtsx"
    Task name: "Package"
    Execution access path: "\Package"
    Every other task returns a success and their execution access path is a subfolder of "\Package". I tried everything I found on the web, check the "Runtime 32bits" box, create a "Job Account" user to execute the package via a
    "Job Account Proxy", modify the ProtectionLevel of the package to "DontSaveSensitive", give the "Job Account" user full rights on everything, nothing works.
    Do you have an idea of what my problem is and how to solve it?
    I must precise that all my packages do the same thing: I have a loop on all the csv files in a folder that for each file loads the contents of the file in my database and the delete the file. I observed that the error message do not appear when there is
    no file in the folder when the package executes.
    Thanks in advance.

    Not sure what error message, is the one "est introuvable.
    Cette erreur est retournée par la collection Connections lorsque l'élément de connexion spécifique est introuvable"?
    So, here is in short: the ForEach Loop once in its beginning of operation "senses" the files currently present in the working folder. If a new file arrives after this stage, it will not see it.
    In your case it seems that the ForEach "saw" a file at the beginning, but it was gone at the time the processing wanted it for execution.
    Like many above indicated, the common practice, call
    it elegant or not is to indeed move the files to a different directory (working folder). This is done to avoid collisions with some other activity in that folder.
    Furthermore, you can have all the files deleted using a ForEach against the working folder as say in
    http://beyondrelational.com/modules/2/blogs/88/posts/10178/ssis-delete-files-from-specified-folder-using-file-system-task-in-sql-server.aspx And there is no need to delete the working folder
    itself.
    The job is run in SQL Server's Agent
    need to be set to run using a domain proxy account as it needs write access to the file system.
    Arthur My Blog

  • Correlating on Directory problem

    Dear All,
    I have some strange problem with correlation. In BPM there is a fork with 2 recieve steps which are recieving filea.
    If I correlate on Directory every time a new instance of BP is created (even is the files where form the same directory(in CCs the Directory checkbox is also marked)). Then I tried to change the correlation to SenderService and it works perfectly, as the files come from one Sender than no new instances of BP are created.
    Any ideas what can be wrong with directories? (I have checked in XML Dynamic Configuration and the Directory names are for sure the same, but the correlation doesn't work).
    Best Regards,
    Artsiom Anichenka

    From what I've seen, there is really a bug there.
    Even though you are able to select ASMAs in the expression editor of the correlation editor, they won't be filled by BPE. I'd say to raise an OSS.
    Meanwhile, if you need to make the scenario work right away, you should extend your data type to contain the directory in the payload (and fill it with dynamic configuration in a mapping).
    Regards,
    Henrique.

  • Command line program execution problem.

    Hey there, I'm about to complete my Java thesis project, but I can't fix a problem: i have to find a command line programme (which is in python but i think its not a big deal) through a java programme. Getting some information around I ended up i could execute the program with the command:
    Process proc = Runtime.getRuntime().exec("...");
    and create the streams:
    OutputStream out = proc.getOutputS 14.49
    InputStream in = proc.getInputStream();
    the problem is that calling a programme which prints on screen something and then it ends (ex. ipconfig) the following sequence works out:
    do
    int i=in.read();
    if(i==-1) break;
    System.out.print((char)i);
    }while(true);
    instead in the specific case of the programme that i need to execute it canno't work because this programme after its opening prints a couple of lines, at this stage you need to type the input in and when the eof font is sent the output is printed. i've tried to send the input thru OutputStream but the execution gets stuck when it reads the output (in.read());
    Can you guys help me out? What do i need to do? Please it's very important, let me know ASAP.
    Thanks very much,
    Fabio

    I would not recommend the use of raw "InputStream" for much of anything.
    Try Scanner if you can use JDK5, if not, try BufferedReader.
    Scanner:
    Process proc = Runtime.getRuntime().exec("...");
    BufferedOutputStream out = new BufferedOutputStream(proc.getOutputStream());
    Scanner in = new Scanner(proc.getInputStream());
    while(in.hasNextLine()) {
         String s = in.nextLine();
         System.out.println(s);
    }BufferedReader:
    Process proc = Runtime.getRuntime().exec("...");
    BufferedOutputStream out = new BufferedOutputStream(proc.getOutputStream());
    BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    String l = " ";
    while(l != null) {
         l = r.nextLine();
         System.out.println(s);
    }

  • Script execution problem

    dear sir
    i got a problem with script execution. i have successfully  activate the form painter in ABAP editor. but i am getting the error like "Form  ZLASRISUD language EN is not active and has no errors". please give me the solution for above as soon as possible.

    dear sir
    i got a problem with script execution. i have successfully  activate the form painter in ABAP editor. but i am getting the error like "Form  ZLASRISUD language EN is not active and has no errors". please give me the solution for above as soon as possible.

Maybe you are looking for

  • How can i set class path in ubuntu JAVA_HOME ?

    how can i set class path in ubuntu <JAVA_HOME>?

  • HFM Performance and Number of JV Line Items

    How much of consolidation time and SmartView response time is tied to number of JV line items? For example, one year we had 1,200 total JVs with 164,000 line items. If we could cut this by 25% or so, would there be great benefit in performance? Thank

  • Newbie Q about Frame 8 and XML

    I am an experienced Frame user but have never used structure in Frame. We're all on 7.2 where I work but soon to upgrade to Frame 8. In the marketing poop on Adobe's site they say you can use XSLT or DTD to open XML files in Frame, but I know that in

  • Audio plays but error message when trying to export movie.

    I had several projects working great. But then, in the finder, I renamed some of the folders that contained the audio files that were used in iMovie. Now, the audio files are still visible in iMovie, and they still sound. The only problem is, that th

  • Merging

    so i have two separate groups on my AIM ichat account and i wanted to merge them both but then the only thing to do seems to be drag/drop the online friends into the first group and delete the other group [but this deletes all my friends that are off