Strage Performance Problems with SQL Statements....

Hi,
I have realized a strange performance collapse while changing simple things in SQL Statements...
I have build a simple Statement:
SELECT
a.AAA,
a.BBB,
a.CCC,
b.AAA
from
TABLE_A a,
TABLE_B b,
TABLE_C c
where
a.XXX=b.XXX
and c.XXX = a.XXX
and c.yyy = 'SOMETHING'
Its very fast, even with complex XSL Transformations...
After Putting a GROUP BY or DISTINCT into the statement (to surpress Dataset "Clones") it tooks around 100 times more Time then before....
I have tested the statement in a SQLPlus, it was as fast as before, but in the XMLPublisher it tooks much longer.....
Have you realizesd this Problem before?
Greetings...

PROBLEM SOLVED !
It has to be 8.1.6 across the whole environment.
null

Similar Messages

  • Performance problem with SQL in NT vs. Solaris

    Hi, I am using the thin driver in classes12.zip. The 8.1.5 server runs on a solaris box. With the same code executing the same sql statement against the same database using the same version of JRE, Statement.execute() takes 5-10 times longer on a solaris client then a NT client. The other java code doesn't show any noticeable performance degradation. Has anyone seen this problem before? Thanks in advance.

    JDK1.3.0 on NT and JDK1.2.2/JDK1.3.0Beta on Solaris (tried both jdk on solaris, pretty much the same result). The network set up is this:
    1 Oracle Server (8.1.5)
    1 Web Server (Alliaire JRun, running servlets, communicates with oracle server via JDBC thin driver)
    a couple clients using explorer or netscape
    The problem is actually the web server. When the webserver is installed on NT, a sql call (stmt.executeUpdate(sql) for example) takes say 10 seconds, the same call will take twice as long or more on Solaris. The reason why I don't think JRun solaris/NT version makes that much of a difference is that besides the JDBC calls, all the other java codes completes at about the same rate.
    null

  • Performance problem with MERGE statement

    Version : 11.1.0.7.0
    I have an insert statement like following which is taking less than 2 secs to complete and inserts around 4000 rows:
    INSERT INTO sch.tab1
              (c1,c2,c3)
    SELECT c1,c2,c3
       FROM sch1.tab1@dblink
      WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink);I wanted to change it to a MERGE statement just to avoid duplicate data. I changed it to following :
    MERGE INTO sch.tab1 t1
    USING (SELECT c1,c2,c3
       FROM sch1.tab1@dblink
      WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink) t2
    ON (t1.c1 = t2.c1)
    WHEN NOT MATCHED THEN
    INSERT (t1.c1,t1.c2,t1.c3)
    VALUES (t2.c1,t2.c2,t2.c3);The MERGE statement is taking more than 2 mins (and I stopped the execution after that). I removed the WHERE clause subquery inside the subquery of the USING section and it executed in 1 sec.
    If I execute the same select statement with the WHERE clause outside the MERGE statement, it takes just 1 sec to return the data.
    Is there any known issue with MERGE statement while implementing using above scenario?

    riedelme wrote:
    Are your join columns indexed?
    Yes, the join columns are indexed.
    You are doing a remote query inside the merge; remote queries can slow things down. Do you have to select all thr rows from the remote table? What if you copied them locally using a materialized view?Yes, I agree that remote queries will slow things down. But the same is not happening while select, insert and pl/sql. It happens only when we are using MERGE. I have to test what happens if we use a subquery refering to a local table or materialized view. Even if it works, I think there is still a problem with MERGE in case of remote subqueries (atleast till I test local queries). I wish some one can test similar scenarios so that we can know whether it is a genuine problem or some specific problem from my side.
    >
    BTW, I haven't had great luck with MERGE either :(. Last time I tried to use it I found it faster to use a loop with insert/update logic.
    Edited by: riedelme on Jul 28, 2009 12:12 PM:) I used the same to overcome this situation. I think MERGE needs to be still improved functionally from Oracle side. I personally feel that it is one of the robust features to grace SQL or PL/SQL.

  • Strange problem with SQL-Statement

    Hi guys,
    i encountered a strange problem trying to execute a statement
    like this:
    Insert Into Data Set Text = 'Exception-Type: {0} Message: {1}';
    I'm using createStatement and executeUpdate.
    But the message stored looks like:
    Exception-Type: 0{} Message: 1{}
    I'm using MySQL 3.23. if I use ODBC everthing is o.k.!?
    Any suggestions
    Thanks

    I found a solution,
    i've thought it through once again. the sql-parsing
    mechanism seemed to be the right direction.
    i guess the odbc mysql implementation does a sql-statement
    conversion, so the string is stored correctly into the
    database. the jdbc-implementation doesn't.
    if i replace { with \{ it works. the backlash can be used
    to masquerade some characters in mysql.
    my application is database independent (or it should be)
    so i wonder if this works with oracle , db2 etc.
    mike

  • Problem with SQL Statement for Result Filtering

    Dear Visual Composer Experts,
    Here is another Question from me: I have a SQL Query that is working as the data service
    Select AB.AgingBandID, AB.AgingBand,
    Sum(Case when priority='Emergency' then '1' Else 0 End) as [Emergency],
    Sum(Case when priority='Ugent' then '1' Else 0 End) as Ugent,
    Sum(Case when priority='High' then '1' Else 0 End) as High,
    Sum(Case when priority='Medium' then '1' Else 0 End) as Medium,
    Sum(Case when priority='Low' then '1' Else 0 End) as Low
    from DimAgingBand AB left outer join
    (Select AgingBandID , priority , yeardesc
    from vNotifications where YearDesc = (select year(getdate())-1)) as vN
    on AB.AgingBandID=vN.AgingBandID
    where AB.AgingBandID<>'1'  
    Group by  AB.AgingBandID, AB.AgingBand
    Order by AB.AgingBandID
    That would return me a table as in the following:
         Agingband     E     U     H     M     L
         < 1week     0     0     0     0     1
         1 - 2 weeks     0     0     0     0     0
         2 - 4weeks     0     0     0     0     1
    > 1month     8     2     1     1     6
    Now that I would like to add some parameters to filter the result, so I modify the query and put it in the SQL Statement input port of the same data service. The query is like this:
         "Select AB.AgingBandID, AB.AgingBand,Sum(Case when priority='Emergency' then '1' Else 0 End) as [Emergency],Sum(Case when priority='Ugent' then '1' Else 0 End) as Ugent,Sum(Case when priority='High' then '1' Else 0 End) as High,Sum(Case when priority='Medium' then '1' Else 0 End) as Medium,Sum(Case when priority='Low' then '1' Else 0 End) as Low from DimAgingBand AB left outer join (Select AgingBandID , priority , yeardesc from vNotifications where YearDesc like '2009%' and Branch like '" & if(STORE@selectedBranch=='ALL', '%', STORE@selectedBranch) & "' and MainWorkCentre like '%') as vN on AB.AgingBandID=vN.AgingBandID where AB.AgingBandID<>'1' Group by AB.AgingBandID, AB.AgingBand Order by AB.AgingBandID"
    However this input port query keeps giving me error as NullPointerException. I have actually specified a condition where the query will run if only STORE@selectedBranch != u2018u2019.
    I have other filtering queries working but they are not as complicated query as this one. Could it be possible that query in the input port cannot handle left outer join?
    Could it be anything else?
    Help is very much appreciated.
    Thanks & Regard,
    Sarah

    Hi,
    Thank you very much for your replys. I've tested if the dynamic value of the condition is integer, it's OK
    But if the ClassID type is not integer, it's string, I write  a SQL Statement like:
    "Select DBADMIN.Class.ClassName from DBADMIN.Class where DBADMIN.Class.ClassID = '1' "
    or with dynamic condition:
    "Select DBADMIN.Class.ClassName from DBADMIN.Class where DBADMIN.Class.ClassID = '"&@ClassID&"'"
    or I write the SQL Statement for insert/update/delete data,
    I always have errors.
    I've tested if the dynamic value of the condition is integer, it's OK
    Do you know this problem ?
    Thank you very much & kindly regards,
    Tweety

  • Problem with sql statement after migration

    Hi, recently I copied a production database X to a remote location, to serve as a test upgrade database. Original is 32 bit and test database is 64 bit. After migration it turned out that one sql statement consumed much more CPU during EXECUTE phase than on production database. Explain plans are the same. Why CPU is different? How can I trace the problem?
    ORIGINAL SERVER TKPROF OUTPUT:
    call count cpu elapsed disk query current rows
    Parse 1 0.12 0.33 0 0 2 0
    Execute 1 542.60 2165.29 2 6 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 542.73 2165.62 2 6 2 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 66 (SPB)
    Rows     Row Source Operation
          0  SORT UNIQUE (cr=6 pr=2 pw=0 time=719909655 us)
          0   FILTER  (cr=6 pr=2 pw=0 time=719909615 us)
          2    NESTED LOOPS  (cr=0 pr=0 pw=0 time=719895787 us)
          2     HASH JOIN  (cr=0 pr=0 pw=0 time=719881575 us)
          2      NESTED LOOPS  (cr=0 pr=0 pw=0 time=1210563833 us)
          2       NESTED LOOPS  (cr=0 pr=0 pw=0 time=1210549798 us)
          2        NESTED LOOPS  (cr=0 pr=0 pw=0 time=1210519159 us)
    330261         REMOTE  TWFLPROCESSINSTANCES (cr=0 pr=0 pw=0 time=29176788 us)
          2         REMOTE  TAMCONTRACTEDITEMD (cr=0 pr=0 pw=0 time=1177866001 us)
          2        REMOTE  TAMPROPVALUES (cr=0 pr=0 pw=0 time=30580 us)
          2       REMOTE  TREPVALUELISTITEMS (cr=0 pr=0 pw=0 time=13973 us)
    24542745      REMOTE  TAMCONTRACTEDITEMD (cr=0 pr=0 pw=0 time=638116004 us)
          2     REMOTE  TWFLPROCESSINSTANCES (cr=0 pr=0 pw=0 time=14154 us)
          2    INDEX RANGE SCAN IDX_PROCES_ID (cr=6 pr=2 pw=0 time=13706 us)(object id 546934)
    Rows     Execution Plan
          0  INSERT STATEMENT   MODE: ALL_ROWS
          0   SORT (UNIQUE)
          0    FILTER
          2     NESTED LOOPS
          2      HASH JOIN
          2       NESTED LOOPS
          2        NESTED LOOPS
          2         NESTED LOOPS
    330261          REMOTE OF 'TWFLPROCESSINSTANCES' (REMOTE)
                         [T6STDBY.WR]
                        SELECT /*+ OPAQUE_TRANSFORM */ "ID","STATUS","STARTDATE"
                        FROM "DIALOG6"."TWFLPROCESSINSTANCES" "PI" WHERE
                          "STATUS"<>'A' AND "STATUS"<>'N' AND "STARTDATE">=:1-30
          2          REMOTE OF 'TAMCONTRACTEDITEMD' (REMOTE)
                         [T6STDBY.WR]
                        SELECT /*+ OPAQUE_TRANSFORM */ "CITEM_ID","ROOTCITEM_ID",
                        "PRODUCT_ID","CONTRACT_ID" FROM
                        "DIALOG6"."TAMCONTRACTEDITEMD" "CI" WHERE "PRODUCT_ID"=
                          934 AND "CONTRACT_ID"=:1
          2         REMOTE OF 'TAMPROPVALUES' (REMOTE) [T6STDBY.WR]
                       SELECT /*+ OPAQUE_TRANSFORM */ "PROPERTY_ID",
                       "VALUEOBJECT_ID","CONTRACTEDITEM_ID","DTO","ISVALID"
                       FROM "DIALOG6"."TAMPROPVALUES" "TV" WHERE "DTO" IS NULL
                       AND "ISVALID"='Y' AND "CONTRACTEDITEM_ID"=:1 AND
                         "PROPERTY_ID"=930326
          2        REMOTE OF 'TREPVALUELISTITEMS' (REMOTE) [T6STDBY.WR]
                      SELECT /*+ OPAQUE_TRANSFORM */ "ID","NAME" FROM
                        "DIALOG6"."TREPVALUELISTITEMS" "TVL" WHERE "ID"=:1
    24542745       REMOTE OF 'TAMCONTRACTEDITEMD' (REMOTE) [T6STDBY.WR]
                     SELECT /*+ OPAQUE_TRANSFORM */ "CITEM_ID","CONTRACT_ID" FROM
                       "DIALOG6"."TAMCONTRACTEDITEMD" "CINAD"
          2      REMOTE OF 'TWFLPROCESSINSTANCES' (REMOTE) [T6STDBY.WR]
                    SELECT /*+ OPAQUE_TRANSFORM */ "ID" FROM
                    "DIALOG6"."TWFLPROCESSINSTANCES" "SYS_ALIAS_1" WHERE "ID"=
                      :1
          2     INDEX   MODE: ANALYZED (RANGE SCAN) OF 'IDX_PROCES_ID'
                    (INDEX)
    REMOTE SERVER TKPROF OUTPUT:
    call count cpu elapsed disk query current rows
    Parse 1 0.15 0.15 0 0 2 0
    Execute      1   1210.69    3831.70          0          6          0           0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 1210.85 3831.85 0 6 2 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 66 (SPB)
    Rows     Row Source Operation
          0  SORT UNIQUE (cr=6 pr=0 pw=0 time=681448432 us)
          0   FILTER  (cr=6 pr=0 pw=0 time=681448397 us)
          2    NESTED LOOPS  (cr=0 pr=0 pw=0 time=681448144 us)
          2     HASH JOIN  (cr=0 pr=0 pw=0 time=681443808 us)
          2      NESTED LOOPS  (cr=0 pr=0 pw=0 time=168646003 us)
          2       NESTED LOOPS  (cr=0 pr=0 pw=0 time=168636029 us)
          2        NESTED LOOPS  (cr=0 pr=0 pw=0 time=168580989 us)
    327667         REMOTE  TWFLPROCESSINSTANCES (cr=0 pr=0 pw=0 time=9177863 us)
          2         REMOTE  TAMCONTRACTEDITEMD (cr=0 pr=0 pw=0 time=158011360 us)
          2        REMOTE  TAMPROPVALUES (cr=0 pr=0 pw=0 time=55007 us)
          2       REMOTE  TREPVALUELISTITEMS (cr=0 pr=0 pw=0 time=9947 us)
    24542745      REMOTE  TAMCONTRACTEDITEMD (cr=0 pr=0 pw=0 time=3509657414 us)
          2     REMOTE  TWFLPROCESSINSTANCES (cr=0 pr=0 pw=0 time=4309 us)
          2    INDEX RANGE SCAN IDX_PROCES_ID (cr=6 pr=0 pw=0 time=160 us)(object id 552075)
    Rows     Execution Plan
          0  INSERT STATEMENT   MODE: ALL_ROWS
          0   SORT (UNIQUE)
          0    FILTER
          2     NESTED LOOPS
          2      HASH JOIN
          2       NESTED LOOPS
          2        NESTED LOOPS
          2         NESTED LOOPS
    327667          REMOTE OF 'TWFLPROCESSINSTANCES' (REMOTE)
                         [T6STDBY.WR]
                        SELECT /*+ OPAQUE_TRANSFORM */ "ID","STATUS","STARTDATE"
                        FROM "DIALOG6"."TWFLPROCESSINSTANCES" "PI" WHERE
                          "STATUS"<>'A' AND "STATUS"<>'N' AND "STARTDATE">=:1-30
          2          REMOTE OF 'TAMCONTRACTEDITEMD' (REMOTE)
                         [T6STDBY.WR]
                        SELECT /*+ OPAQUE_TRANSFORM */ "CITEM_ID","ROOTCITEM_ID",
                        "PRODUCT_ID","CONTRACT_ID" FROM
                        "DIALOG6"."TAMCONTRACTEDITEMD" "CI" WHERE "PRODUCT_ID"=
                          934 AND "CONTRACT_ID"=:1
          2         REMOTE OF 'TAMPROPVALUES' (REMOTE) [T6STDBY.WR]
                       SELECT /*+ OPAQUE_TRANSFORM */ "PROPERTY_ID",
                       "VALUEOBJECT_ID","CONTRACTEDITEM_ID","DTO","ISVALID"
                     FROM "DIALOG6"."TAMPROPVALUES" "TV" WHERE "DTO" IS NULL
                       AND "ISVALID"='Y' AND "CONTRACTEDITEM_ID"=:1 AND
                         "PROPERTY_ID"=930326
          2        REMOTE OF 'TREPVALUELISTITEMS' (REMOTE) [T6STDBY.WR]
                      SELECT /*+ OPAQUE_TRANSFORM */ "ID","NAME" FROM
                        "DIALOG6"."TREPVALUELISTITEMS" "TVL" WHERE "ID"=:1
    24542745       REMOTE OF 'TAMCONTRACTEDITEMD' (REMOTE) [T6STDBY.WR]
                     SELECT /*+ OPAQUE_TRANSFORM */ "CITEM_ID","CONTRACT_ID" FROM
                       "DIALOG6"."TAMCONTRACTEDITEMD" "CINAD"
          2      REMOTE OF 'TWFLPROCESSINSTANCES' (REMOTE) [T6STDBY.WR]
                    SELECT /*+ OPAQUE_TRANSFORM */ "ID" FROM
                    "DIALOG6"."TWFLPROCESSINSTANCES" "SYS_ALIAS_1" WHERE "ID"=
                      :1
          2     INDEX   MODE: ANALYZED (RANGE SCAN) OF 'IDX_PROCES_ID'
                    (INDEX)Edited by: Przemek P on 2012-01-27 07:40
    Edited by: Przemek P on 2012-01-27 07:50

    Could you please edit your post and use \ tags so the output is more user friendly?
    Type: \Your Code Here\It will display as:Your Code Here                                                                                                                                                                                                                                                                                                                                                                       

  • Problems with SQL statement ..Urgent Help required

    Hi
    I have a table with something like this
    ::: inidicates column seperation
    col1 ::: col2 ::: col3 ::: col4
    ab,abc,abvfg,fghy ::: x1 ::: y1 ::: z1
    ba,mkl,huji,kill ::: x2 ::: y2 ::: z2
    I want to get something like this :
    col1 ::: col2 ::: col3 ::: col4
    ab ::: x1 ::: y1 ::: z1
    abc ::: x1 ::: y1 ::: z1
    abvfg ::: x1 ::: y1 ::: z1
    fghy ::: x1 ::: y1 ::: z1
    and so on......
    Either a procedure or a single sql statement is fine..
    PS: the first column can have any number of words separated with comma (,)
    Please advise
    Thanks in advance

    create table kris (
    a varchar2(200),
    b varchar2(20),
    c varchar2(20),
    d varchar2(20));
    insert into kris values('ab,abc,abvfg,fghy', 'x1','y1','z1');
    insert into kris values('ba,mkl,huji,kill', 'x2','y2','z2');
    select substr(','||a||',', instr(','||a||',', ',', 1, rn) +1,
         instr(','||a||',', ',', 1, rn+1) - instr(','||a||',', ',', 1, rn) -1)
         v,b,c,d
    from (select length(a) - length(translate(a, '1,', '1')) +1 L,
         a, b, c, d from kris) t, (select rownum rn from cat) c
         where c.rn <= t.L
    order by a, rn;
    V B C D
    ab x1 y1 z1
    abc x1 y1 z1
    abvfg x1 y1 z1
    fghy x1 y1 z1
    ba x2 y2 z2
    mkl x2 y2 z2
    huji x2 y2 z2
    kill x2 y2 z2

  • Problem with sql statement

    hi
    i have a strange problem....when i run the following code with the 'if' statement commented out then it works fine. but when i have to search a particular name, say roy , then i include that if statement. but now it gives an error like no such data found.
    if the return typ of result.getString(2) is a string type then i wonder what is the problem. i enclose the code below.
    import java.sql.*;
    import java.io.*;
    public class checkDoc
         public static void main(String args[])
              String name;
              ResultSet result;
              try
                   name= "roy";
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con;
                   con = DriverManager.getConnection("jdbc:odbc:MyDataSource","","");
                   Statement stat = con.createStatement();
                   result = stat.executeQuery("Select * from Details1");
                   while (result.next())
    /* problem here*/
    /*     if(result.getString(2).equals(name))
         */               System.out.println(result.getString(2));
              catch(Exception e)
                   System.out.println("Error"+e);

    thanks alot for that help...but now there is another silly problem!..
    i following is perhaps the simplest code possible for insering data into an ACCESS database.(simplest possible with just one column by the name Doc_name and table name is docdetails)...but it gives the error...
    "java.sql.SQLException:syntax error or in INSERT INTO statement"
    someone plz help!
    import java.sql.*;
    public class checkDoc4
         public static void main(String args[])
              ResultSet rs;
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con;
                   con = DriverManager.getConnection("jdbc:odbc:MyDataSource2","","");
    Statement stat = con.createStatement();
                        stat.executeUpdate("INSERT INTO docdetails" +
         "VALUES ('ankur')");          
              catch(Exception e)
                   System.out.println("Error"+e);

  • Again the SUM and DISTINCT Problem (With SQL Statement)

    Here is the actual SQL,
    select
    NVL(l.pr_cust_prod,'zzzzz') A,
    NVL(l.pr_prod_code,'zzzzz') B,
    NVL(l.pr_lot_no,'zzzzz') C,
    NVL(l.db_waf_qty,'99999') lotQty,
    NVL(t.db_cust_po,'zzzzz') poNum,
    NVL(p.oe_po_line,'99999') poLineNum,
    i.db_shpmt_no invNum,
    from
    db_invoice i, db_line_lot l, db_inv_item t, db_prod_line p
    where
    l.db_shpmt_no like 'U388%'
    and i.db_invo_date > sysdate - 500
    and l.pr_run_type = 'PR'
    and l.db_shpmt_no = i.db_shpmt_no
    and l.db_shpmt_no = t.db_shpmt_no
    and l.db_item_no = t.db_item_no
    and p.db_ref_numa1 = t.db_tsmc_po
    and l.db_shpmt_no not in
    (select distinct db_shpmt_no from ftp_cust_ship
    where DB_MAST_ACCT='U388' and sys_name='SENT')
    and l.pr_prod_code like '%Z_'
    group by l.pr_lot_no, l.db_line_numb, l.pr_cust_prod, l.pr_prod_code,
    t.db_cust_po, i.db_delv_cod2, l.db_lot_desc, i.db_shpmt_no,
    p.oe_po_line
    order by lotNum
    the problem is that if I dont use SELECT DISTINCT at beginning
    the result is like
    F , LOTQTY , PONUM , POLINENUM
    DP8568.00,25 ,BVI10080 ,1
    DP8568.00,25 ,BVI10080 ,2
    DP8568.00,25 ,BVI10080 ,1
    DP8568.00,25 ,BVI10080 ,1
    DP8568.00,25 ,BVI10080 ,2
    DP8568.00,25 ,BVI10080 ,1
    DP8568.00,25 ,BVI10080 ,1
    DP8568.00,25 ,BVI10080 ,2 //pleae note the QTY and POLINENUM
    Then if Add SELECT DISTINCT, the result will be
    F ,LOTQTY , PONUM , POLINENUM
    DP8568.00,25 ,BVI10080,1
    DP8568.00,25 ,BVI10080,2
    but I change the NVL(l.db_waf_qty,'99999') lotQty, statement to NVL((SUM( l.db_waf_qty)),'99999') lotQty,
    this will give me the result
    F ,LOTQTY, PONUM , POLINENUM
    DP8568.00,75 , BVI10080 ,2
    DP8568.00,125 , BVI10080 ,1
    Which I excepted the result as
    F ,LOTQTY, PONUM , POLINENUM
    DP8568.00,25 , BVI10080 ,2
    DP8568.00,25 , BVI10080 ,1
    And Advise??
    Thanks a lot
    Jon

    based on the data set you given
    SQL>
    SQL> With t As
      2  (
      3  Select 'DP8568' c1 ,0.25 c2,'BVI10080' c3,1 c4 From dual Union All
      4  Select 'DP8568' ,0.25 ,'BVI10080' ,2           From dual Union All
      5  Select 'DP8568' ,0.25 ,'BVI10080' ,1           From dual Union All
      6  Select 'DP8568' ,0.25 ,'BVI10080' ,1           From dual Union All
      7  Select 'DP8568' ,0.25 ,'BVI10080' ,2           From dual Union All
      8  Select 'DP8568' ,0.25 ,'BVI10080' ,1           From dual Union All
      9  Select 'DP8568' ,0.25 ,'BVI10080' ,1           From dual Union All
    10  Select 'DP8568' ,0.25 ,'BVI10080' ,2           From dual
    11  )
    12  Select c1,
    13         sum(c2) lot_qty,
    14         c3,
    15         c4
    16  From
    17  (
    18    Select c1, --Sum(c2) over (Partition By c1,c4 Order By c4)
    19           row_number() over (Partition By c1,c4 Order By c4) rn,
    20           c2,
    21           c3,
    22           c4
    23    From t
    24  ) Where rn = 1
    25  Group By c1, c3, c4;
    C1        LOT_QTY C3               C4
    DP8568       0.25 BVI10080          2
    DP8568       0.25 BVI10080          1
    SQL>

  • Problems with SQL statement

    Here is the problem that I have .. I have a table that gets updated every 30 minutes.. and the columns are:
    Day Shift MDate
    The data is as follows:
    wed M 09012003
    wed N 09012003
    thu M 09022003
    thu N 09022003
    I want a SQL or PL/SQL that can help me in grabbing the distinct MDate where I have the instance of both M and N in the shift.
    For the above data, I want to get distinct MDates as 09012003
    09022003
    But here is the problem; at some point in time say in the evening.. the data looks like this
    wed M 09012003
    wed N 09012003
    thu M 09022003
    For the above data, I want to get distinct MDates as 09012003
    This is because "day" column with "thu" does not have both the instances of M and N in the "shift" column
    Any help in this regard is highly appreciated..
    Thanks in advance

    Use 'group by' and 'having':
    create table ttest(Day varchar2(3), Shift varchar2(1), MDate varchar(8));
    insert into ttest values('wed', 'M', '09012003');
    insert into ttest values('wed', 'N', '09012003');
    insert into ttest values('thu', 'M', '09022003');
    insert into ttest values('thu', 'N', '09022003');
    select distinct mdate from ttest group by mdate having count(1) > 1;
    MDATE
    09012003
    09022003
    delete from ttest;
    insert into ttest values('wed', 'M', '09012003');
    insert into ttest values('wed', 'N', '09012003');
    insert into ttest values('thu', 'M', '09022003');
    select distinct mdate from ttest group by mdate having count(1) > 1;
    MDATE
    09012003

  • Performance Problem with SQL Query

    Hi
    I have a SQL Query (say, SSS) which runs quite fast when I run it from TOAD.
    But when the same query is being used as
    INSERT INTO <table> VALUES <SSS>;
    It is taking hours to complete.
    The Original Query(OSQ) was changed to this SQL query(SSS) for Performance improvement.
    The Cost has also improved quite a lot from OSQ to SSS. But when SSS runs from inside a procedure it is taking the same long hours as OSQ used to take.
    Please help ASAP as it needs to get fixed.
    Thanks
    Arnab

    SELECT SRM.ID PROJECT_ID,
    SRM.UNIQUE_NAME PROJECT_CODE,
    ODFP.GS_FINANCE_PROJ_CODE,
    ODFP.GS_PRODUCT_CODE,
    ODFP.GS_CUSTOMER,
    ODFP.GS_LEGAL_ENT_REF,
    ODF_PRJ_TYPE.NAME GS_PROJ_TYPE,
    ODF_SRC_SYS.NAME GS_SOURCE_SYSTEM,
    RESM.FIRST_NAME||' '||RESM.LAST_NAME GS_PROJECT_MANAGER,
    ODFP.GS_LEG_PROJ_NUM,
    ODFP.GS_SUPP_DOC ,
    ODFP.GS_REQUEST_ID ,
    ODFP.GS_CONTRACT ,
    ODFP.GS_SIEBEL_REF,
    DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg)LAB_BDGT,
    DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)NLI_BDGT,
    (DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg))+(DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)) sum_lab_nonlab_budg,
    frct.LABOUR,
    frct.NON_LABOUR,
    frct.LABOUR+frct.NON_LABOUR FORCAST_TOT_SUM,
    gfr.code GFR_CODE,
    odfp.gs_rev_recognition,
    rev_rec.NAME gs_rev_recognition,
    DECODE(odfp.gs_prevent_reqtxn,1,'YES','0','NO','NO'),
    GS_PROGTYPE.NAME,
    COMM_APPR.UNIQUE_NAME COMM_APPROVER_EIN,
    COMM_APPR.FIRST_NAME||' '||COMM_APPR.LAST_NAME COMM_APPROVER_NAME,
    PR_APPR.UNIQUE_NAME PR_APPROVER_EIN,
    PR_APPR.FIRST_NAME||' '||PR_APPR.LAST_NAME PR_APPROVER_NAME,
    ODFP.GS_BILL_BUD,
    frct.FRCST_REVENUE TOTAL_FRC_REVENUE,
    actuals.LABOUR_ACTUALS,
    actuals.NL_ACTUALS,
    -- get_wip_totalcost(prjp.prid,'L') LABOUR_ACTUALS,
    -- get_wip_totalcost(prjp.prid,'M') NL_ACTUALS,
    ODFP.GS_ASS_PRODUCT_CODE,
    PROJ_TEMPLATE.ID GS_PROJ_TEMPLATE_ID,
    PROJ_TEMPLATE.UNIQUE_NAME GS_PROJ_TEMPLATE_CODE,
    PROJ_TEMPLATE.name GS_PROJ_TEMPLATE_NAME,
    DECODE( NVL(ODFP.GS_FIN_TEMPLATE,0) ,0,'NO',1,'YES') GS_FIN_TEMPLATE,
    ODF_PRJ_TYPE.LOOKUP_CODE GS_PROJ_TYPE
    FROM PROJECTS SRM,
    J_PROJECTS PRJP,
    A_PROJECT ODFP,
    RESOURCES RESM,
    s_gfr gfr,
    RESOURCES PROJ_ACCT,
    RESOURCES COMM_APPR,
    RESOURCES PR_APPR,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_PROJECT_TYPE'
    AND LOOKUP.ID =CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_PRJ_TYPE,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_SOURCE_SYSTEM'
    AND LOOKUP.ID =CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_SRC_SYS,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_PROG_TYPE'
    AND LOOKUP.ID =CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS')GS_PROGTYPE,
    (SELECT odf_parent_id
    ,SUM(gs_lab_budg) lab_budg
    ,SUM(gs_nl_budg) nli_budg
    FROM T_CHANGES
    WHERE gs_status='APPR'
    GROUP BY odf_parent_id) budg,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_REV_RECOGNITION'
    AND LOOKUP.ID = CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS') rev_rec,
    (SELECT FRCP1.project_id,
    NVL(SUM(CASE WHEN srmr.resource_type=0 THEN for_val.cost ELSE NULL END),0) AS LABOUR,
    NVL(SUM(CASE WHEN srmr.resource_type <> 0 THEN for_val.cost ELSE NULL END),0) AS NON_LABOUR,
    NVL(SUM(for_val.revenue),0) AS FRCST_REVENUE
    FROM T_PROPERTIES FRCP1,
    T_DETAILS FOR_DET,
    RESOURCES SRMR,
    T_VALUES FOR_VAL
    WHERE (FRCP1.project_id, revision) IN (SELECT project_id, MAX(revision)
    FROM T_PROPERTIES FRCP
    WHERE FRCP.status=2
    AND FRCP.PERIOD_TYPE='SEMI_MONTHLY'
    GROUP BY project_id)
    AND FRCP1.PERIOD_TYPE='SEMI_MONTHLY'
    AND FOR_DET.forecast_id=frcp1.id
    AND SRMR.id(+)=FOR_DET.detail_id
    AND FOR_VAL.currency_type='BILLING'
    AND FOR_VAL.forecast_details_id=FOR_DET.ID
    GROUP BY FRCP1.project_id) frct,
    (SELECT srmp.id
    ,NVL(SUM(CASE WHEN wip.transtype='L' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS LABOUR_ACTUALS
    ,NVL(SUM(CASE WHEN wip.transtype='M' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS NL_ACTUALS
    FROM A_WIP WIP
    ,om_periods biz
    ,P_VALUES WIPVAL
    ,PROJECTS SRMP
    ,A_PROJECT ODF
    WHERE biz.period_type ='SEMI_MONTHLY'
    AND TRUNC(wip.TRANSDATE) BETWEEN biz.start_date AND biz.end_date
    AND WIP.TRANSNO=WIPVAL.TRANSNO
    AND WIPVAL.CURRENCY_TYPE='BILLING'
    AND SRMP.UNIQUE_NAME=WIP.PROJECT_CODE
    AND SRMP.ID=ODF.ID
    AND UPPER(ODF.partition_code)='GLOBAL'
    AND UPPER(WIP.external_id) <> 'SPREADSHEET'
    GROUP BY srmp.id) actuals,
    RESOURCES BUD_HOLDER,
    PROJECTS PROJ_TEMPLATE
    WHERE SRM.ID = PRJP.PRID
    AND ODFP.ID=PRJP.PRID
    AND ODFP.PARTITION_CODE='GLOBAL'
    AND RESM.id(+)=prjp.manager_id
    AND ODFP.GS_PROJECT_TYPE = ODF_PRJ_TYPE.LOOKUP_CODE(+)
    AND ODFP.GS_SOURCE_SYSTEM = ODF_SRC_SYS.LOOKUP_CODE(+)
    AND ODFP.GS_prog_type = GS_PROGTYPE.LOOKUP_CODE(+)
    AND budg.odf_parent_id(+)=SRM.ID
    AND frct.project_id(+) = prjp.prid
    AND ODFP.gs_risk_gfr=gfr.code(+)
    AND ODFP.GS_REV_RECOGNITION=rev_rec.LOOKUP_CODE(+)
    AND ODFP.GS_PROJ_ACCT = PROJ_ACCT.ID(+)
    AND ODFP.GS_COMM_APPR = COMM_APPR.ID(+)
    AND ODFP.GS_PR_APPR = PR_APPR.ID(+)
    AND actuals.id(+) = prjp.prid -- Arnab
    AND ODFP.GS_BUDGET_HOLDER=BUD_HOLDER.ID(+)
    AND ODFP.GS_TEMPLATE_USED=PROJ_TEMPLATE.ID(+)
    The above is OSQ with cost 45000. ... takes 1-1.5 hours through Toad
    SELECT SRM.ID PROJECT_ID,
    SRM.UNIQUE_NAME PROJECT_CODE,
    ODFP.GS_FINANCE_PROJ_CODE,
    ODFP.GS_PRODUCT_CODE,
    ODFP.GS_CUSTOMER,
    ODFP.GS_LEGAL_ENT_REF,
    ODF_PRJ_TYPE.NAME GS_PROJ_TYPE,
    ODF_SRC_SYS.NAME GS_SOURCE_SYSTEM,
    RESM.FIRST_NAME||' '||RESM.LAST_NAME GS_PROJECT_MANAGER,
    ODFP.GS_LEG_PROJ_NUM,
    ODFP.GS_SUPP_DOC ,
    ODFP.GS_REQUEST_ID ,
    ODFP.GS_CONTRACT ,
    ODFP.GS_SIEBEL_REF,
    DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg)LAB_BDGT,
    DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)NLI_BDGT,
    (DECODE(budg.ODF_PARENT_ID,NULL,PRJP.bdgt_cst_total, budg.lab_budg))+(DECODE(budg.ODF_PARENT_ID,NULL,0,budg.nli_budg)) sum_lab_nonlab_budg,
    frct.LABOUR,
    frct.NON_LABOUR,
    frct.LABOUR+frct.NON_LABOUR FORCAST_TOT_SUM,
    gfr.code GFR_CODE,
    odfp.gs_rev_recognition,
    rev_rec.NAME gs_rev_recognition,
    DECODE(odfp.gs_prevent_reqtxn,1,'YES','0','NO','NO'),
    GS_PROGTYPE.NAME,
    COMM_APPR.UNIQUE_NAME COMM_APPROVER_EIN,
    COMM_APPR.FIRST_NAME||' '||COMM_APPR.LAST_NAME COMM_APPROVER_NAME,
    PR_APPR.UNIQUE_NAME PR_APPROVER_EIN,
    PR_APPR.FIRST_NAME||' '||PR_APPR.LAST_NAME PR_APPROVER_NAME,
    ODFP.GS_BILL_BUD,
    frct.FRCST_REVENUE TOTAL_FRC_REVENUE,
    -- actuals.LABOUR_ACTUALS, -- Arnab
    -- actuals.NL_ACTUALS, -- Arnab
    get_wip_totalcost(prjp.prid,'L') LABOUR_ACTUALS, -- Arnab
    get_wip_totalcost(prjp.prid,'M') NL_ACTUALS, -- Arnab
    ODFP.GS_ASS_PRODUCT_CODE,
    PROJ_TEMPLATE.ID GS_PROJ_TEMPLATE_ID,
    PROJ_TEMPLATE.UNIQUE_NAME GS_PROJ_TEMPLATE_CODE,
    PROJ_TEMPLATE.name GS_PROJ_TEMPLATE_NAME,
    DECODE( NVL(ODFP.GS_FIN_TEMPLATE,0) ,0,'NO',1,'YES') GS_FIN_TEMPLATE,
    ODF_PRJ_TYPE.LOOKUP_CODE GS_PROJ_TYPE
    FROM PROJECTS SRM,
    J_PROJECTS PRJP,
    A_PROJECT ODFP,
    RESOURCES RESM,
    s_gfr gfr,
    RESOURCES PROJ_ACCT,
    RESOURCES COMM_APPR,
    RESOURCES PR_APPR,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_PROJECT_TYPE'
    AND LOOKUP.ID =CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_PRJ_TYPE,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_SOURCE_SYSTEM'
    AND LOOKUP.ID =CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS') ODF_SRC_SYS,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_PROG_TYPE'
    AND LOOKUP.ID =CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS')GS_PROGTYPE,
    (SELECT odf_parent_id
    ,SUM(gs_lab_budg) lab_budg
    ,SUM(gs_nl_budg) nli_budg
    FROM T_CHANGES
    WHERE gs_status='APPR'
    GROUP BY odf_parent_id) budg,
    (SELECT CAP.NAME
    ,LOOKUP.LOOKUP_CODE
    FROM S_NLS CAP,
    N_LOOKUPS LOOKUP
    WHERE LOOKUP_TYPE ='GS_REV_RECOGNITION'
    AND LOOKUP.ID = CAP.PK_ID
    AND CAP.LANGUAGE_CODE='en'
    AND CAP.TABLE_NAME = 'CMN_LOOKUPS') rev_rec,
    (SELECT FRCP1.project_id,
    NVL(SUM(CASE WHEN srmr.resource_type=0 THEN for_val.cost ELSE NULL END),0) AS LABOUR,
    NVL(SUM(CASE WHEN srmr.resource_type <> 0 THEN for_val.cost ELSE NULL END),0) AS NON_LABOUR,
    NVL(SUM(for_val.revenue),0) AS FRCST_REVENUE
    FROM T_PROPERTIES FRCP1,
    T_DETAILS FOR_DET,
    RESOURCES SRMR,
    T_VALUES FOR_VAL
    WHERE (FRCP1.project_id, revision) IN (SELECT project_id, MAX(revision)
    FROM T_PROPERTIES FRCP
    WHERE FRCP.status=2
    AND FRCP.PERIOD_TYPE='SEMI_MONTHLY'
    GROUP BY project_id)
    AND FRCP1.PERIOD_TYPE='SEMI_MONTHLY'
    AND FOR_DET.forecast_id=frcp1.id
    AND SRMR.id(+)=FOR_DET.detail_id
    AND FOR_VAL.currency_type='BILLING'
    AND FOR_VAL.forecast_details_id=FOR_DET.ID
    GROUP BY FRCP1.project_id) frct,
    /* (SELECT srmp.id
    ,NVL(SUM(CASE WHEN wip.transtype='L' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS LABOUR_ACTUALS
    ,NVL(SUM(CASE WHEN wip.transtype='M' THEN WIPVAL.TOTALCOST ELSE NULL END),0) AS NL_ACTUALS
    FROM A_WIP WIP
    ,om_periods biz
    ,P_VALUES WIPVAL
    ,PROJECTS SRMP
    ,A_PROJECT ODF
    WHERE biz.period_type ='SEMI_MONTHLY'
    AND TRUNC(wip.TRANSDATE) BETWEEN biz.start_date AND biz.end_date
    AND WIP.TRANSNO=WIPVAL.TRANSNO
    AND WIPVAL.CURRENCY_TYPE='BILLING'
    AND SRMP.UNIQUE_NAME=WIP.PROJECT_CODE
    AND SRMP.ID=ODF.ID
    AND UPPER(ODF.partition_code)='GLOBAL'
    AND UPPER(WIP.external_id) <> 'SPREADSHEET'
    GROUP BY srmp.id) actuals, */ -- Arnab
    RESOURCES BUD_HOLDER,
    PROJECTS PROJ_TEMPLATE
    WHERE SRM.ID = PRJP.PRID
    AND ODFP.ID=PRJP.PRID
    AND ODFP.PARTITION_CODE='GLOBAL'
    AND RESM.id(+)=prjp.manager_id
    AND ODFP.GS_PROJECT_TYPE = ODF_PRJ_TYPE.LOOKUP_CODE(+)
    AND ODFP.GS_SOURCE_SYSTEM = ODF_SRC_SYS.LOOKUP_CODE(+)
    AND ODFP.GS_prog_type = GS_PROGTYPE.LOOKUP_CODE(+)
    AND budg.odf_parent_id(+)=SRM.ID
    AND frct.project_id(+) = prjp.prid
    AND ODFP.gs_risk_gfr=gfr.code(+)
    AND ODFP.GS_REV_RECOGNITION=rev_rec.LOOKUP_CODE(+)
    AND ODFP.GS_PROJ_ACCT = PROJ_ACCT.ID(+)
    AND ODFP.GS_COMM_APPR = COMM_APPR.ID(+)
    AND ODFP.GS_PR_APPR = PR_APPR.ID(+)
    AND     actuals.id(+) = prjp.prid  Arnab
    AND ODFP.GS_BUDGET_HOLDER=BUD_HOLDER.ID(+)
    AND ODFP.GS_TEMPLATE_USED=PROJ_TEMPLATE.ID(+)
    This one in SSS where "-- Arnab " are only changes .....
    The cost of this 7000.....finishes in 1 - 1.5 min in Toad
    This is used as INSERT INTO TABLE <Select Query> ... this was taking 1.5 Hours to run.
    It was changed using BULK COLLECT - still its taking around 1.5 hours to run...
    Thanks
    Arnab

  • Serious performance Problems with SQL

    I am running this query to a oracle 10
    update ETY_MEDIASHEET set PUB_TYPE = 'REVOKED' where id in (9090,9094,9100,9106,9112,9118,9124,9130,9136,9142,9148,9154,9160,9166,9172)
    I am using ejb3 with hibernate as entitymanager. However, due to performace I need to set status quickly (so that gui gets correct data), thus i have to set it "hard" in the database.
    This query takes a very long time. From seconds if the list has 1-2-3 items, and to minutes if it has 50+ items
    Any1 got an idea as to solve this issue? or even why it occurs?
    BTW - I am no sql star.

    yes, the ID has a index (as well as title).
    the table holds data representing albums and albumtracks
    "Column Name"     "Data Type"     "Nullable"     "Data Default"     "COLUMN ID"     "Primary Key"     "COMMENTS"
    "ID"     "NUMBER(19,0)"     "No"     ""     "2"     "1"     ""
    "SHEET_TYPE"     "VARCHAR2(31 Char)"     "No"     ""     "1"     ""     ""
    "CRE_DATE"     "TIMESTAMP(6)"     "Yes"     ""     "3"     ""     ""
    "CRE_USER"     "VARCHAR2(255 Char)"     "Yes"     ""     "4"     ""     ""
    "MOD_DATE"     "TIMESTAMP(6)"     "Yes"     ""     "5"     ""     ""
    "MOD_USER"     "VARCHAR2(255 Char)"     "Yes"     ""     "6"     ""     ""
    "PUB_DATE"     "TIMESTAMP(6)"     "Yes"     ""     "7"     ""     ""
    "PUB_USER"     "VARCHAR2(255 Char)"     "Yes"     ""     "8"     ""     ""
    "PUB_MSG"     "VARCHAR2(255 Char)"     "Yes"     ""     "9"     ""     ""
    "PUB_TYPE"     "VARCHAR2(255 Char)"     "Yes"     ""     "10"     ""     ""
    "TITLE"     "VARCHAR2(512 Char)"     "Yes"     ""     "11"     ""     ""
    "PUBLISHER_LINE"     "VARCHAR2(512 Char)"     "Yes"     ""     "12"     ""     ""
    "COPYRIGHT_LINE"     "VARCHAR2(512 Char)"     "Yes"     ""     "13"     ""     ""
    "RELEASE_DATE"     "TIMESTAMP(6)"     "Yes"     ""     "14"     ""     ""
    "ORGRELEASE_DATE"     "TIMESTAMP(6)"     "Yes"     ""     "15"     ""     ""
    "PARENTAL_ADVISORY"     "NUMBER(1,0)"     "Yes"     ""     "16"     ""     ""
    "PUBLISHABLE"     "NUMBER(1,0)"     "Yes"     ""     "17"     ""     ""
    "IS_FOR_SALE"     "NUMBER(1,0)"     "Yes"     ""     "18"     ""     ""
    "PACKAGE_TYPE"     "VARCHAR2(255 Char)"     "Yes"     ""     "19"     ""     ""
    "EDITION"     "VARCHAR2(255 Char)"     "Yes"     ""     "20"     ""     ""
    "DURATION"     "NUMBER(10,0)"     "Yes"     ""     "21"     ""     ""
    "LANGUAGE_CODE"     "VARCHAR2(255 Char)"     "Yes"     ""     "22"     ""     ""
    "PRODUCTION_COMPANY"     "VARCHAR2(255 Char)"     "Yes"     ""     "23"     ""     ""
    "OFFICIAL_SITE"     "VARCHAR2(255 Char)"     "Yes"     ""     "24"     ""     ""
    "RECOMMENDED_FROM"     "VARCHAR2(255 Char)"     "Yes"     ""     "25"     ""     ""
    "LABEL"     "VARCHAR2(255 Char)"     "Yes"     ""     "26"     ""     ""
    "RECORDINGCOUNTRY"     "VARCHAR2(255 Char)"     "Yes"     ""     "27"     ""     ""
    "VERSION"     "VARCHAR2(255 Char)"     "Yes"     ""     "28"     ""     ""
    "CATALOG_ID"     "NUMBER(19,0)"     "Yes"     ""     "29"     ""     ""
    "SUPPLIER_PRICECODE_ID"     "NUMBER(19,0)"     "Yes"     ""     "30"     ""     ""
    "SUPPLIER_ID"     "NUMBER(19,0)"     "Yes"     ""     "31"     ""     ""
    Index
    "Index Name"     "Columns"     "Uniqueness"     "Status"     "Index Type"     "Temporary"     "Partitioned"     "Function Index Status"     "Join Index"
    "SYS_C0025348"     "ID"     "UNIQUE"     "VALID"     "NORMAL"     "N"     "NO"     ""     "NO"
    "IDX_ETY_SHEET_TITLE"     "TITLE"     "NONUNIQUE"     "VALID"     "NORMAL"     "N"     "NO"     ""     "NO"

  • Performance Problem in SQL Statement

    Hi,
    I am using a SELECT statement where the execution time is taking longer time:
    SELECT MSD,IMS,BOOK_IND FROM RW_TABLE,TABLE(GET_SUD)
    WHERE SERVED_MSISDN=MSD
    (MSD Column is a Object type from TABLE Function TABLE(GET_SUD) and (SERVED_MSISDN is a column of the table RW_TABLE)
    Any help will be needful for me
    Thanks and Regards

    Your query:
    SELECT MSD,IMS,BOOK_IND
    FROM RW_TABLE,TABLE(GET_SUD)
    WHERE SERVED_MSISDN=MSDYou reference two tables - RW_TABLE and GET_SUD - yet you have no join between them. Hence Oracle is doing a CARTESIAN PRODUCT between the two data sets. As each table or data set gets bigger, so will the results, and so will the elapsed time.
    You need to join the two tables together properly. Read a book on Relational Databases if you do not understand what a join is between tables, and why it is needed.
    I would also guess that you lack an index on the SERVED_MSISDN column on its own, or as the leading column in an index. Instead Oracle is reading every entry in an index to find any matching rows (FAST FULL SCAN CTVA_ETL.TEMP_INDX). So again, as the tables get bigger so the FULL SCAN of the whole index will take longer too.
    John
    [Database Performance Blog|http://databaseperformance.blogspot.com]

  • Problem with SQL statement - Missing double quote in identifier

    Hi
    I am unable to run the following query in TOAD.
    SELECT A.* FROM (SELECT VC.CAMPAIGN_NUMBER," +
                   "VC.CAMPAIGN_TITLE,VC.CAMPAIGN_DESC,VC.START_DATE,VC.END_DATE,VC.CAMPAIGN_TYPE,VC.APPLICABILITY," +
                   "VC.CAMPAIGN_PRIORITY FROM VM_CAMPAIGN VC WHERE VC.APPLICABILITY = 'Y' and VC.COUNTRY_CODE = ? " +
                   "and VC.LANGUAGE_CODE = ? AND VC.CAMPAIGN_TYPE = ? AND SYSDATE BETWEEN VC.START_DATE AND " +
                   "VC.END_DATE AND NOT EXISTS (SELECT 'X' FROM VM_CAMPAIGN_VIN VCV WHERE (VCV.VIN = ? AND " +
                   "VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER))UNION SELECT VC.CAMPAIGN_NUMBER,VC.CAMPAIGN_TITLE," +
                   "VC.CAMPAIGN_DESC,VCV.START_DATE,VCV.END_DATE,VC.CAMPAIGN_TYPE,VC.APPLICABILITY,VC.CAMPAIGN_PRIORITY " +
                   "FROM VM_CAMPAIGN_VIN VCV ,VM_CAMPAIGN VC WHERE VCV.VIN = ? AND " +
                   "VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER AND VC.COUNTRY_CODE = ? AND VC.LANGUAGE_CODE = ? AND " +
                   "VC.CAMPAIGN_TYPE = ? AND SYSDATE BETWEEN VCV.START_DATE AND VCV.END_DATE AND SYSDATE BETWEEN " +
                   "VC.START_DATE AND VC.END_DATE) A ORDER BY A.CAMPAIGN_PRIORITY DESC, A.END_DATE
    I am getting "Missing double quote in identifier"
    I am not sure how to rectify this SQL code. Any suggestions are welcome
    thanks in advance

    maybe this will work.
    SELECT A.*
      FROM (SELECT VC.CAMPAIGN_NUMBER,
                   VC.CAMPAIGN_TITLE,
                   VC.CAMPAIGN_DESC,
                   VC.START_DATE,
                   VC.END_DATE,
                   VC.CAMPAIGN_TYPE,VC.APPLICABILITY,
                   VC.CAMPAIGN_PRIORITY
              FROM VM_CAMPAIGN VC
             WHERE VC.APPLICABILITY = 'Y'
               And VC.COUNTRY_CODE =  '&country_code'
               And VC.LANGUAGE_CODE = '&language_code'
               AND VC.CAMPAIGN_TYPE = '&campaign_type'
               AND SYSDATE BETWEEN VC.START_DATE AND VC.END_DATE
               AND NOT EXISTS (SELECT 'X'
                                 FROM VM_CAMPAIGN_VIN VCV
                                WHERE (VCV.VIN = &VIN AND
                                       VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER))
            UNION
            SELECT VC.CAMPAIGN_NUMBER,
                   VC.CAMPAIGN_TITLE,
                   VC.CAMPAIGN_DESC,
                   VCV.START_DATE,
                   VCV.END_DATE,
                   VC.CAMPAIGN_TYPE,
                   VC.APPLICABILITY,
                   VC.CAMPAIGN_PRIORITY
              FROM VM_CAMPAIGN_VIN VCV,
                   VM_CAMPAIGN VC
              WHERE VCV.VIN = &VIN
                AND VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER
                AND VC.COUNTRY_CODE = '&country_code'
                AND VC.LANGUAGE_CODE = '&language_code'
                AND VC.CAMPAIGN_TYPE = '&campaign_type'
                AND SYSDATE BETWEEN VCV.START_DATE AND VCV.END_DATE
                AND SYSDATE BETWEEN VC.START_DATE AND VC.END_DATE) A
    ORDER BY A.CAMPAIGN_PRIORITY DESC, A.END_DATE

  • Performance Problems with "For all Entries" and a big internal table

    We have big Performance Problems with following Statement:
    SELECT * FROM zeedmt_zmon INTO TABLE gt_zmon_help
      FOR ALL ENTRIES IN gt_zmon_help
        WHERE
        status = 'IAI200' AND
        logdat IN gs_dat AND
        ztrack = gt_zmon_help-ztrack.
    In the internal table gt_zmon_help are over 1000000 entries.
    Anyone an Idea how to improve the Performance?
    Thank you!

    >
    Matthias Weisensel wrote:
    > We have big Performance Problems with following Statement:
    >
    >  
    SELECT * FROM zeedmt_zmon INTO TABLE gt_zmon_help
    >   FOR ALL ENTRIES IN gt_zmon_help
    >     WHERE
    >     status = 'IAI200' AND
    >     logdat IN gs_dat AND
    >     ztrack = gt_zmon_help-ztrack.
    >
    > In the internal table gt_zmon_help are over 1000000 entries.
    > Anyone an Idea how to improve the Performance?
    >
    > Thank you!
    You can't expect miracles.  With over a million entries in your itab any select is going to take a bit of time. Do you really need all these records in the itab?  How many records is the select bringing back?  I'm assuming that you have got and are using indexes on your ZEEDMT_ZMON table. 
    In this situation, I'd first of all try to think of another way of running the query and restricting the amount of data, but if this were not possible I'd just run it in the background and accept that it is going to take a long time.

Maybe you are looking for

  • URGENT: SSO for multiple Applications

    I have integrated 4 different applications in a single domain with OAM for SSO. Individually all apps are working fine (for SSO). Now I want to Apply only single login for all the applications. So what changes need to be done in OAM side? Continuing

  • Problem excluding 'Others' in subtotal after applying Top N sort

    Hi all,  question from a newby. My  V8.5 Crystal report has two levels of grouping, Store and Brand with expense $ values subtotalled for each level.  I am only interested in the Top 10 Stores per Brand so have used the Top N/Sort Group Expert so tha

  • Reconciliation reports in SAP IDM

    Hello I am working on IDM 7.2 SP8 configuration and so far its going good and was able to configured scenerios. I wanted some reports (Reconcillation report) and saw some blog where its advised to install SAP IDM RDS solution, I am just wondering how

  • How to define a printer for a system

    Hi, I have installed a PS system with 8.47 tools. How can I a define physical printer for it that can be used by users or batch process ? Thank you.

  • CS5 Bridge Output to PDF option not available

    Have selected all jpg images that I want to combine into single PDF in bridge window. When I select Output option the button Output to Web or PDF not highlighted for use - Can't make it work.  Any ideas? Running on mac.  thanks