How to tune query using dblink?

Hello,
I have query running on production DB(Version 9i).
The query is fetching data over the dblink.
Its taking around 14 minutes and total number of rows fetched are around 2 million.
Is there any way I can tune the query? I have used driving site hist but that didn't helped.

Ario wrote:
Hello,
I have query running on production DB(Version 9i).
The query is fetching data over the dblink.
Its taking around 14 minutes and total number of rows fetched are around 2 million.
Is there any way I can tune the query? I have used driving site hist but that didn't helped.
Do some math and tell us if there is a way you can tune this.
We have no idea what "2 million rows" means in terms of size. That could be 1GB of data, it could be 1PB of data. Figure out how much data you're trying to move (size wise), then figure out roughly how fast your network can pipe the data (again, we have no idea if you have a fiber line and this is an internal network between machines, or if you're transporting the data 1/2 way around the globe over a dial up connection).
When you have all that figured out you'll know if the 14 minutes is / or is not an acceptable amount of time.
Cheers,

Similar Messages

  • How to get  query used in LOV

    Hi all,,,
    Assume that my lov is listing (eg empno, ename,dept) when i query for empno. Actually i want to change that empno to deptno ie(deptno,ename,dept) when i queried for empno. How to accomplish this. I think by form personalization we can do ie. BY creating own record group and replacing that with old one, we can do. But i want to know the query used in old record group. How to accomplish this task. plz help me.. Its urgent ... plz... Advance thanks. Any other approach most welcome.. Plz

    Hi all,,,
    Assume that my lov is listing (eg empno, ename,dept) when i query for empno. Actually i want to change that empno to deptno ie(deptno,ename,dept) when i queried for empno. How to accomplish this. I think by form personalization we can do ie. BY creating own record group and replacing that with old one, we can do. But i want to know the query used in old record group. How to accomplish this task. plz help me.. Its urgent ... plz... Advance thanks. Any other approach most welcome.. Plz

  • Query using DBLink

    Iam using 10.1.0.2.0 Version . Both table structure is same in both DB .I want to do both update
    and insert based on my below query
    Source: DB - Different Server
    Table 1: src_Tab_A
    Columns : c_id,seq, code,type,s_code [has composite pk c_id,seq]
    Table 2: Src_TAb_B
    Columns : c_id,seq,lan,code,name,s_code [has composite pk c_id,seq,lan]
    target: DB
    Table 1: tgt_Tab_A
    Columns : c_id,seq, code,type,s_code [has composite pk c_id,seq]
    Table 2: tgt_TAb_B
    Columns : c_id,seq,lan,code,name,s_code [has composite pk c_id,seq,lan]
    SELECT a.C_ID, a.S_CODE, a.CODE, a.SEQ,a.type
    FROM <schema>.src_Tab_A@<DBLINK> a
    WHERE a.C_ID = 20
    AND a.TYPE = 'S'
    AND Exists( SELECT C_ID, S_CODE, CODE, SEQ, TYPE
    FROM tgt_Tab_A b
    WHERE b.C_ID = a.c_id
    AND b.SEQ = a.seq)
    This query is fetching the matching records . But i want to fetch based on ( b.s_code <> a.s_code or b.code <> a.code )
    For example ,
    SELECT a.C_ID, a.S_CODE, a.CODE, a.SEQ,a.type
    FROM <schema>.src_Tab_A@<DBLINK> a
    WHERE a.C_ID = 20
    AND a.TYPE = 'S'
    AND Exists( SELECT C_ID, S_CODE, CODE, SEQ, TYPE
    FROM tgt_Tab_A b
    WHERE (b.C_ID = a.c_id
    AND b.SEQ = a.seq)
    **AND b.s_code <> a.s_code OR b.code <> a.code*)*
    But its not giving the exact output what i want ...
    similarly i want to fetch it from src_tab_b and tgt_tab_b based on not matching records of name and code values..
    How can i do this ... any suggestions for me ...

    Source DB
    SRC_Tab_A               
    C_ID     S_CODE     CODE     SEQ
    21     005     005     5
    21          006     6
    21     007     007     7
    21     008     008     8
    21     009     009     9
    SRC_Tab_B                         
    C_ID     S_CODE     LAN     CODE     SEQ     NAME
    21     005     EN     005     5     Manufacturer
    21          EN     006     6     Formulation Originator
    21     007     EN     007     7     Registration Holder
    21     008     EN     008     8     Active Ingredient Supplier
    21     009     EN     009     9     Agreement Partner
    Target DB
    TGT_Tab_A               
    C_ID     S_CODE     CODE     SEQ
    21     005     005     5
    21     006     006     6
    21     007     007     7
    21     008     008     8
    21     009     009     9
    TGT_Tab_B                         
    C_ID     S_CODE     LAN     CODE     SEQ     NAME
    21     005     EN     005     5     Manufacturer
    21     006     EN     006     6     Formulation originator
    21     007     EN     007     7     MA Holder/Sponsor
    21     008     EN     008     8     Active ingredient supplier
    21     009     EN     009     9     Agreement partner
    I want to compare SRC_Tab_A and TGT_Tab_A, SRC_Tab_B and TGT_Tab_B.. if there is any difference in s_code or
    name then it should display those difference records
    The output should be like this ,
    SRC_Tab_A               
    21          006     6
    SRC_Tab_B                         
    21     007     EN     007     7     Registration Holder
    Please help me to solve this ...

  • How to determine query used in Inventory Status (Available-to-Promise) List

    Hi,
        I'm trying to create a query that will give me  commited qty per item per day. I tried checking table used in the Inventory Status(Available-to-Promise) by enabling systmen information under view buth the SAP is giving me "form=154 Item100000054 Pane3 ......... " Can somebody explain or guide me on how i can create the query.
    Regards

    Hi,
    Welcome you post on the forum.
    Do you need a query report or a formatted search query?
    Thanks,
    Gordon

  • Recursive joins / how to define query using connect by clause

    Hi,
    I have a table A have 1-1 reltionship with table Employee
    Structure of table is as follows
    Table A
    id name employee_id
    100 aa 1
    200 bb 2
    300 cc 3
    400 dd 4
    500 ee 5
    Table Employee
    id parent_id
    1 null
    2 1
    3 2
    4 3
    5 1
    6 1
    I want to get all records from A table whose employee_id is equal to 2 or (recursive)decendants/child of employee with id 2 (i.e. employee with id 2,3,4 )
    i.e I want recursively join where in I get records from table A as
    id name employee_id
    200 bb 2
    300 cc 3 (because it is child of employee with id 2)
    400 dd 4 (becaue it is child of employee with id 3 which is child of 2)
    I know we can use In clause , but it will be performance wise not good.
    Can we do it in Toplink without using IN clause?
    Oracle has connect by clause, but other database might not have this caluse. So how can write a toplink query which can run on any database.
    Any help is highly appreciated.
    Thanks a lot.

    You can use TopLink's Hierarchical Query support but this only works with Oracle DB as it relies on the database to perform the query.
    --Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to tune query

    Hi,
    How i can tune complex query?
    what are the step to follow.

    A very good one
    http://www.dba-oracle.com/art_sql_tune.htm
    Not particularly. At best it's a rambling collection of general principles where you have to work out which bits are right, out of date, or wrong. (Or - like the bit about Oracle 7 - so far out of date as to be a waste of space).
    How much are you going to trust an article about SQL tuning that manages to say the following:
    <i>
    For example, a simple query such as “What students received an A last semester?” can be written in three ways, as shown in below, each returning an identical result.
    </i>
    A nested query:
    SELECT *
    FROM STUDENT
    WHERE
        student_id =
        (SELECT student_id
            FROM REGISTRATION
            WHERE
           grade = 'A'
    A correlated subquery:
    SELECT *
    FROM STUDENT
    WHERE
        0 <
        (SELECT count(*)
            FROM REGISTRATION
            WHERE
            grade = 'A'
            AND
            student_id = STUDENT.student_id
        );Far from returning identical results, the first one returns multiple copies of each student's information, one row for each 'A' they got (along with the registration columns); the second will fail with Oracle error "ORA-01427: single-row subquery returns more than one row" if there is more than one 'A' in the entire registration table; and the third query returns the required result.
    Funnily enough, the most "intuitive" query - which is the one with an existence subquery - is not mentioned.
    The OP would be far better off starting with the Performance Tuning Guide from http://tahiti.oracle.com
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The greatest enemy of knowledge is not ignorance,
    it is the illusion of knowledge." Stephen Hawking.

  • How to tune update using subquery

    T1 has 4 million records
    T2 has 9 million records
    Average number of records updated in T1 = 115,000
    I am trying update table T1 (4 million records), with matching t_id from table T2 (9 million records), every night.
    I tried the 3 version of the update, each of it taking around 30 minutes to update T1.
    If I run the same sql immediately it completes within 5 minutes (execution plans are the same for both runs).
    Could any one please explain what makes it run faster the second time? Any suggestions for performing this
    update in a better way would be greatly appreciated...
    create table T1
    id varchar2 (18) not null,
    t_date date not null,
    t_id varchar2 (18),
    processed varchar2 (1) default 'N',
    constraint T1_pk primary key ( id, t_date )
    create index T1_prcsd on T1(processed);
    create table T2
    id varchar2 (18) not null,
    t_id varchar2 (18) not null
    create unique index customer_idx01 on customer(custnum);
    **1:**
    update T1 a
    set t_id = ( select b.t_id
    from T2 b
    where a.id = b.id)
    where id in ( select id from T2)
    and processed = 'N';
    *2:*
    update T1 a
    set t_id = ( select b.t_id
    from T2 b
    where a.id = b.id)
    where exists ( select 1 from T2 c where a.id = c.id)
    and processed = 'N';
    *3:*
    update ( select /*+ USE_NL(T1) INDEX( T2 T2_idx01 ) */
                                  a.t_id a_t_id
                                  ,c.t_id c_t_id
                   from T1 a, T2 c
                   where a.id = c.id
                   and a.processed = 'N'
    set a_t_id = c_t_id;

    Could any one please explain what makes it run faster the second time?Probably because data is cached if the second run is shortly after the first.
    You already tried the correlated EXISTS I was going to suggest. How long do versions 1 and 2 take?
    Are A.ID and A.PROCESSED both in one composite index?

  • How to tune the query and difference between CBO AND RBO.. Which is good

    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query,
    2)What approach you take to tune query? Do you use Hints?
    3)Where did you tune the query and what are the issue with query?
    4)What is difference between RBO and CBO? where u use RBO and CBO.
    5)Give some information about hash join?
    6) Using explain plan how do u know where the bottle neck in query .. how u will identify where the bottle neck is from explain plan .
    thanks/Kumar

    Hi,
    kumar73 wrote:
    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query, Use EXPLAIN PLAN to see exactly where it is spending its time, and address those areas.
    See the forum FAQ
    SQL and PL/SQL FAQ
    "3. How to improve the performance of my query?"
    2)What approach you take to tune query? Do you use Hints?Hints can help.
    Even more helpful is writing the SQL efficiently (avoiding multiple scans of the same table, filtering early, using built-in rather than user-defined functions, ...), creating and using indexes, and, for large tables, partitioning.
    Table design can have a big impact on performace.
    Look for ways to do part of what you need before the query. This includes denormalizing (when appropriate), the kind of pre-digesting that often takes place in data warehouses, function-based indexes, and, starting in Oracle 11, virtual columns.
    3)Where did you tune the query and what are the issue with query?Either this question is a vague summary of the entire thread, or I don't understand it. Can you re-phrase this part?
    4)What is difference between RBO and CBO? where u use RBO and CBO.Basically, use RBO if you have Oracle 7 or earlier.

  • How to tune this query for the improve performance ?

    Hi All,
    How to tune this query for the improve performance ?
    select a.claim_number,a.pay_cd,a.claim_occurrence_number,
    case
    when sum(case
    when a.payment_status_cd ='0'
    then a.payment_est_amt
    else 0
    end
    )=0
    then 0
    else (sum(case
    when a.payment_status_cd='0'and a.payment_est_amt > 0
    then a.payment_est_amt
    else 0
    end)
    - sum(case
    when a.payment_status_cd<>'0'
    then a.payment_amt
    else 0
    end))
    end as estimate
    from ins_claim_payment a
    where a.as_of_date between '31-jan-03' and '30-aug-06'
    and ( a.data_source = '25' or (a.data_source between '27' and '29'))
    and substr(a.pay_cd,1,1) IN ('2','3','4','8','9')
    group by a.claim_number, a.pay_cd, a.claim_occurrence_number
    Thank you,
    Mcka

    Mcka
    As well as EXPLAIN PLAN, let us know what proportion of rows are visited by this query. It may be that it is not using a full table scan when it should (or vice versa).
    And of course we'd need to know what indexes are available, and how selective they are for the predicated you have in this query ...
    Regards Nigel

  • How to Execute Remote procedures that use DBLinks?

    Using Oracle 10g (RAC Linux) to remote connect Windows 10g to dblink to AS/400 <
    <I have created a procedure that I execute remotely by issuing the following:
    CALL GLOBAL.REFRESH_STAGING@KRONOSLINK();
    The procedure errors as
    Error at line 2
    ORA-20001: ERROR OCCURED
    ORA-06512: at "GLOBAL.REFRESH_STAGING", line 47
    ORA-06512: at line 1
    The procedure runs without error from the host database. The problem is when the procedure makes a call to the dblink.
    I unsuccessfully attempted to capture the error message.
    Question: Is it possible to execute remote procedures that use dblinks? If so, How is that accomplished.
    Question: What is the proper way to handle exceptions in this case?
    Bonus: What can be done to improve this procedure? (Suggestions, like adding return on the procedure).
    CREATE OR REPLACE PROCEDURE GLOBAL.REFRESH_STAGING IS
    NOOBJECT EXCEPTION;
    OBJECTEXIST EXCEPTION;
    PRAGMA EXCEPTION_INIT(NOOBJECT, -00942); -- Exception handling for ORA-00942 - table or view does not exist
    PRAGMA EXCEPTION_INIT(OBJECTEXIST, -00955); -- Exception handling for ORA-009555 - name is already used by an existing object
    sT LONG := '';
    sS LONG := '';
    sST LONG := '';
    cursor csrO is
    SELECT
    SCHEMANAME,
    TABLENAME
    FROM GLOBAL.STAGING_TABLES;
    csrR csrO%ROWTYPE;
    BEGIN
    FOR csrR IN csrO
    LOOP
    sT := csrR.TABLENAME;
    sS := csrR.SCHEMANAME;
    sST := sS || '.' || sT;
    BEGIN
    EXECUTE IMMEDIATE 'drop table global.' || sT || ' purge';
    EXCEPTION
    WHEN NOOBJECT THEN
    NULL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_CALL_STACK);
    DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_STACK);
    RAISE_APPLICATION_ERROR (-20001, 'ERROR OCCURED');
    END;
    BEGIN
    EXECUTE IMMEDIATE 'create table global.' || sT || ' nologging as select * from ' || sST || '@thebosslink';
    COMMIT;
    EXCEPTION
    WHEN OBJECTEXIST THEN
    NULL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_CALL_STACK);
    DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_STACK);
    DBMS_OUTPUT.PUT_LINE(SQLCODE || ' - ' || SQLERRM);
    RAISE_APPLICATION_ERROR (-20001, 'ERROR OCCURED');
    END;
    END LOOP;
    END REFRESH_STAGING;
    Thanks,
    blevels

    SET LINESIZE 500;
    COLUMN DB_LINK FORMAT a20
    COLUMN HOST FORMAT a20
    COLUMN USERNAME FORMAT a20
    COLUMN OWNER FORMAT a10
    COLUMN TABLE_NAME FORMAT a20
    select db_link,username, host from all_db_links where db_link = 'KRONOSLINK';
    select privilege from dba_sys_privs where grantee = 'SYSTEM';
    select owner, table_name from dba_tab_privs where grantee='SYSTEM';
    DBLINK_ USERNAME HOST
    KRONOSLINK SYSTEM ORCL
    1 row selected.
    PRIVILEGE
    GLOBAL QUERY REWRITE
    CREATE MATERIALIZED VIEW
    CREATE TABLE
    UNLIMITED TABLESPACE
    SELECT ANY TABLE
    5 rows selected.
    OWNER TABLENAME_
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCEXP
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCVID
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS INCFIL
    SYS DBMS_ALERT
    SYS DBMS_SYS_ERROR
    SYS DBMS_RULE_EXIMP
    SYS DBMS_AQ
    SYS DBMS_AQADM
    SYS DBMS_AQ_IMPORT_INTER
    NAL
    SYS DBMS_AQELM
    SYS DBMS_TRANSFORM_EXIMP
    SYS SYS_GROUP
    SYS DBMS_DEFER_IMPORT_IN
    TERNAL
    SYS DBMS_REPCAT
    WMSYS WM$UDTRIG_INFO
    SYS SET_TABLESPACE
    SYS CHECK_UPGRADE
    SYS AVINASH
    SYS AVINASH
    SYS AVINASH1
    SYS AVINASH1
    SYS DB_PMP
    SYS DB_PMP
    SYS DIR_TESTCASE
    SYS DIR_TESTCASE
    SYS EXPORT_FULL_DIR
    SYS EXPORT_FULL_DIR
    SYS PUMP
    SYS PUMP
    SYS LOGS
    SYS LOGS
    SYS DPUMP_DIR2
    SYS DPUMP_DIR2
    SYS AVIS
    SYS AVIS
    SYS DPDIR_LCLLGS
    SYS DPDIR_LCLLGS
    67 rows selected.
    Edited by: user10860953 on Jan 28, 2010 10:43 AM

  • How to tune the SQL & solve UNIQUE Contraint issue using without duplicates

    CREATE TABLE REL_ENT_REF
      ROLL_ENT        VARCHAR2(4 BYTE)              NOT NULL,
      ROLL_SUB_ENT    VARCHAR2(3 BYTE)              NOT NULL,
      ROLL_ENT_DESCR  VARCHAR2(50 BYTE),
      ENT             VARCHAR2(4 BYTE)              NOT NULL,
      SUB_ENT         VARCHAR2(3 BYTE)              NOT NULL,
      ENT_DESCR       VARCHAR2(50 BYTE)
    CREATE UNIQUE INDEX REL_ENT_REF_IDX_PK ON REL_ENT_REF
    (ROLL_ENT, ROLL_SUB_ENT, ENT, SUB_ENT);
    ALTER TABLE REL_ENT_REF ADD (
      CONSTRAINT REL_ENT_REF_IDX_PK
    PRIMARY KEY
    (ROLL_ENT, ROLL_SUB_ENT, ENT, SUB_ENT);
    TOTAL NUMBER OF RECORDS FOR TABLE REL_ENT_REF : 123542
    CREATE TABLE REL_COA_REF
      ACCT                    VARCHAR2(9 BYTE)      NOT NULL,
      ACCT_LVL                VARCHAR2(2 BYTE)      NOT NULL,
      ACCT_ID                 VARCHAR2(9 BYTE)      NOT NULL,
      REL_TYPE                VARCHAR2(10 BYTE)     NOT NULL,
      ACCT_TYPE               VARCHAR2(2 BYTE)      NOT NULL,
      ACCT_DESCR              VARCHAR2(43 BYTE),
      POST_ACCT               VARCHAR2(9 BYTE)      NOT NULL,
      POST_ACCT_TYPE          VARCHAR2(2 BYTE),
      POST_ACCT_DESCR         VARCHAR2(43 BYTE),
      SIGN_REVRSL             NUMBER
    CREATE INDEX REL_COA_REF_IDX_01 ON REL_COA_REF
    (ACCT_ID, REL_TYPE, POST_ACCT);
    CREATE UNIQUE INDEX REL_COA_REF_IDX_PK ON REL_COA_REF
    (ACCT_ID, ACCT, REL_TYPE, POST_ACCT);
    TOTAL NUMBER OF RECORDS FOR TABLE REL_COA_REF : 4721918
    CREATE TABLE REL_CTR_HIER_REF
      ENT           VARCHAR2(4 BYTE)                NOT NULL,
      SUB_ENT       VARCHAR2(3 BYTE)                NOT NULL,
      HIER_TBL_NUM  VARCHAR2(3 BYTE)                NOT NULL,
      HIER_ROLL     VARCHAR2(14 BYTE)               NOT NULL,
      HIER_CODE     VARCHAR2(14 BYTE)               NOT NULL,
      SUM_FLAG      VARCHAR2(14 BYTE)               NOT NULL,
      CTR_OR_HIER   VARCHAR2(14 BYTE)               NOT NULL,
      CTR_DETAIL    VARCHAR2(14 BYTE)               NOT NULL,
      CTR_DESCR     VARCHAR2(50 BYTE)
    CREATE INDEX REL_CTR_HIER_REF_IDX_01 ON REL_CTR_HIER_REF
    (HIER_TBL_NUM, HIER_ROLL, SUM_FLAG);
    CREATE UNIQUE INDEX REL_CTR_HIER_REF_IDX_PK ON REL_CTR_HIER_REF
    (ENT, SUB_ENT, HIER_TBL_NUM, HIER_ROLL, SUM_FLAG,
    CTR_DETAIL, CTR_OR_HIER, HIER_CODE);
    CREATE INDEX REL_CTR_HIER_REF_IDX_02 ON REL_CTR_HIER_REF
    (ENT, SUB_ENT, HIER_TBL_NUM, CTR_OR_HIER, SUM_FLAG,
    CTR_DETAIL);
    TOTAL NUMBER OF RECORDS FOR TABLE REL_CTR_HIER_REF : 24151811
    CREATE TABLE REL_TXN_ACT_CM
      ENT               VARCHAR2(4 BYTE),
      SUB_ENT           VARCHAR2(3 BYTE),
      POST_ACCT         VARCHAR2(9 BYTE),
      CTR               VARCHAR2(7 BYTE),
      POST_DATE         DATE,
      EFF_DATE          DATE,
      TXN_CODE          VARCHAR2(2 BYTE),
      TXN_TYPE          VARCHAR2(1 BYTE),
      TXN_AMOUNT        NUMBER(17,2),
      TXN_DESCR         VARCHAR2(46 BYTE),
      TXN_SOURCE        VARCHAR2(1 BYTE)
    CREATE INDEX REL_TXN_ACT_CM_IDX_01 ON REL_TXN_ACT_CM
    (ENT, SUB_ENT, POST_ACCT, POST_DATE, EFF_DATE,
    TXN_AMOUNT);
    CREATE INDEX REL_TXN_ACT_CM_IDX_PK ON REL_TXN_ACT_CM
    (ENT, SUB_ENT, CTR, POST_ACCT, POST_DATE,
    EFF_DATE, TXN_AMOUNT);
    TOTAL NUMBER OF RECORDS FOR TABLE REL_TXN_ACT_CM : 111042301
    CREATE TABLE REL_CLPR_TBOX_GL_TXN
      ORGANIZATION  VARCHAR2(10 BYTE)               NOT NULL,
      ACCOUNT       VARCHAR2(10 BYTE)               NOT NULL,
      APPLICATION   VARCHAR2(10 BYTE)               NOT NULL,
      AMOUNT        NUMBER(17,2)                    NOT NULL
    CREATE UNIQUE INDEX REL_CLPR_TBOX_GL_TXN_IDX ON REL_CLPR_TBOX_GL_TXN
    (ORGANIZATION, ACCOUNT, APPLICATION);
        DELETE FROM REL_CLPR_TBOX_GL_TXN;
        INSERT INTO REL_CLPR_TBOX_GL_TXN
          ORGANIZATION,
          ACCOUNT,
          APPLICATION,
          AMOUNT
        SELECT  --+ INDEX(T REL_TXN_ACT_CM_IDX_PK)
          SUBSTR(REL_CTR_HIER_REF.HIER_CODE, 1, 5) || '.....',
          TXN.POST_ACCT,
          'GL-' || SUBSTR(TXN.TXN_DESCR, 1, 3),
          SUM
            CASE
              WHEN TXN.TXN_CODE IN ('01', '21') THEN 1
                    WHEN TXN.TXN_CODE IN ('02', '22') THEN -1
                    ELSE 0
            END
            CASE
              WHEN REL_COA_REF.ACCT_TYPE IN ('01', '25', '30', '40', '90', '95') THEN 1
                    WHEN REL_COA_REF.ACCT_TYPE IN ('05', '10', '20', '35') THEN -1
                    ELSE 0
            END
            REL_COA_REF.SIGN_REVRSL
            TXN.TXN_AMOUNT
        FROM
          REL_TXN_ACT_CM REL_TXN
            INNER JOIN
          REL_CTR_HIER_REF
            ON
              REL_TXN.ENT = REL_CTR_HIER_REF.ENT AND
              REL_TXN.SUB_ENT = REL_CTR_HIER_REF.SUB_ENT AND
              REL_TXN.CTR = REL_CTR_HIER_REF.CTR_DETAIL
            INNER JOIN
          REL_COA_REF
            ON REL_TXN.POST_ACCT = REL_COA_REF.POST_ACCT
            INNER JOIN
          REL_ENT_REF
            ON
              REL_CTR_HIER_REF.ENT = REL_ENT_REF.ENT AND
              REL_CTR_HIER_REF.SUB_ENT = REL_ENT_REF.SUB_ENT
        WHERE
          REL_TXN.EFF_DATE BETWEEN L_MONTH AND LAST_DAY(L_MONTH) AND
          REL_CTR_HIER_REF.HIER_TBL_NUM = '001' AND
          REL_CTR_HIER_REF.SUM_FLAG = 'D' AND
          REL_CTR_HIER_REF.CTR_OR_HIER = REL_CTR_HIER_REF.CTR_DETAIL AND
          REL_CTR_HIER_REF.HIER_CODE BETWEEN 'AAA' AND 'ZZZ' AND
          REL_COA_REF.REL_TYPE = ' ' AND
          REL_COA_REF.ACCT_ID = 'ALPTER' AND
          REL_COA_REF.ACCT_LVL = '9' AND
          REL_ENT_REF.ROLL_ENT = '999' AND
          REL_ENT_REF.ROLL_SUB_ENT = '111'
        GROUP BY
          SUBSTR(REL_CTR_HIER_REF.HIER_CODE, 1, 5),
          REL_TXN.POST_ACCT,
          SUBSTR(REL_TXN.TXN_DESCR, 1, 3)
        HAVING
          SUM
            CASE
              WHEN REL_TXN.TXN_CODE IN ('01', '21') THEN 1
                    WHEN REL_TXN.TXN_CODE IN ('02', '22') THEN -1
                    ELSE 0
            END
            CASE
              WHEN REL_COA_REF.ACCT_TYPE IN ('01', '25', '30', '40', '90', '95') THEN 1
                    WHEN REL_COA_REF.ACCT_TYPE IN ('05', '10', '20', '35') THEN -1
                    ELSE 0
            END
            REL_COA_REF.SIGN_REVRSL
            REL_TXN.TXN_AMOUNT
          ) <> 0;
    [\CODE]
    While try to run the query(only select statement), it is taking around 3+ hours & while try to insert the same query in the table, getting error called ORA-00001: unique constraint (INSIGHT.CLPR_TBOX_GL_TXN_IDX) violated.
    [\CODE]
    How to tune & resolve this UNIQUE Contraint issue using without duplicates?

    Should the SELECT statement be returning duplicate rows? If you know that there are duplicate rows in the underlying tables, you could add a DISTINCT to the select. Which forces Oracle to do an extra sort which will slow down the insert. If you don't expect duplicate rows, you would need to figure out what join criteria is missing from your query and add that criteria.
    Justin

  • How to tune the query...?

    Hi all,
    I am having a table with millions of records and the query is taking hours
    time. How to tune the query apart from doing the following things.
    1. Creating or Deleting indexes.
    2. Using Bind variables.
    3. Using Hints.
    4. Updating the Statitics regurarly.
    Actually, i have asked this question in interview how to tune the query.
    I told him the above 4 things. Then he told, these are not working, then
    how you will tune this query.
    Thanks in advance,
    Pal

    user546710 wrote:
    Actually, i have asked this question in interview how to tune the query.
    I told him the above 4 things. Then he told, these are not working, then
    how you will tune this query.It actually depends on the scenario/problem given.
    You may want to read this first.
    When your query takes too long ...
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

  • How can I access a database remote without using dblink, synonyms,aliases?

    My store procedure access a remote tables using dblink, synonyms, alias, but by business company requirenments I nedd to use another data base access method. My PL/SQL statement looks like
    select c.cus_id, c.cus_name, p.bankaccno
    into v_cus_id, v_cus_name, v_bankaccno
    from customer c, payment@finantial p
    where c.cus_id = p.cus_id
    Are any method else to connect to several remote databases concurrently?
    If Yes, plase say me how is it, or tell me where do I obtain some examples, or any documentation.
    Edited by: user518321 on Apr 21, 2009 1:58 PM
    Ok, But I must not use any of these data base access method, metioned: dbliks, aliases, synonyms.
    Edited by: user518321 on Apr 21, 2009 2:05 PM
    Ok, It is enough for now, I am surprised for the response time and for their arguments, thanks a lot.
    Edited by: user518321 on Apr 21, 2009 2:50 PM

    If you want to access a table in a remote database using SQL, you will need a database link. It would be exceptionally odd for the business to require that you access a remote database and to prohibit the use of database links. What is the business reason for that combination?
    If you want to look into rather more esoteric solutions, you could load a JDBC driver for the remote database, write a Java stored procedure that queries the remote table using that JDBC driver, and then cobble together some PL/SQL that joins the two result sets. You won't be able to reference the remote table in SQL and the solution won't scale well as data volumes increase and you'll be writing a whole lot of code to manually join tables together, but it does avoid database links. Of course, whatever concerns lead to the ban on database links would probably apply to loading a JDBC driver into the database and writing Java stored procedures to access the remote database, but since you haven't explained the reasoning behind the restrictions, we're just guessing.
    Justin

  • How can I query all the members of a group using querbuilder?  I cannot find any related properties

    How can I query all the members of a group using querbuilder?  I cannot find any related properties describing members under /home/groups/s/sample_group in jcr repository.

    Hi,
    FieldPoint Explorer is no longer used to configure FieldPoint systems. However, I do not think that the configuring your system in FieldPoint Explorer is causing the error.
    FieldPoint systems are now setup in Measurement and Automation Explorer (MAX).  Information on setting up FieldPoint systems in MAX can be found in the MAX help under: Installed Products>> FieldPoint. Also, I recommend upgrading to the latest FieldPoint driver and version of MAX.  The FieldPoint VI's will be slightly different when you upgrade, so there is a good chance that this will eliminate the error.
    Regards,
    Hal L.

  • In DBI , how to find out the Source Query used for the Report

    Hi All,
    How to find out the Source Query used to display the data in the DBI Reports or Dashboards. We can get it in Apps Front end by Going to Help and Record Histroty. But DBI Runs in Internet Explorer so i dont know how to get the source query ( SELECT Query ) Used.
    In IE we have View --> Source . But that does not help since it gives the HTML Coding and not the SELECT Query used.
    If anyone has ever worked on it...Please help me in finding it.
    Thanks,
    Neeraj Shrivastava

    Hi neeraj,
    You can see the query used to display reports.Follow these steps to get the query.
    1)Login to oracle apps
    2)Select "Daily Business Intelligence Administrator" responsiblity.
    3)Now click on "Enable/Disable Debugging" (Now u enabled debugging)
    4)now open the report which you want to see the query of
    5)In view source it displays query along with the bind varilables.
    Feel free to ping me if you have any doubts
    thanks
    kittu

Maybe you are looking for

  • Managing multiple devices with iCloud

    I currently have 3 devices (two iphone 4S and one ipad3) linked to one iTunes and iCloud account. One iPhone and the iPad is for work and I want to completely seperate all contacts, email, calendar, apps, etc. from my personal phone. I currently have

  • Delete a user from a table whose name is a foreign key in other tables

    Dear All; I am trying to figure out an easy way to do this. I just recently took someone application who utilized 500 tables. I am trying to delete a user from a table called member_table. However, I am having problems doing so because the user name

  • New Windows Setup Can Be Synced To Only the Last Used Windows Installation?

    Hello, I have found out that Windows allows you to synchronize only with the last used Windows installation and does not allow you to choose to which of your Windows installations you want to synchronize. Why is that? Here's my experience. 1. I insta

  • HT4191 Unable to see my apps in the library

    I am only able to see the 2 apps that I downloaded last week but not the 50+ that were already purchased and downloaded in the last 2 years.

  • Isuue With Jpanel Refresh

    I have one Jpanel in which i m adding buttons dynamically depending on the condition. When i m running my application then only one button is displayed on the pannel , but as soon i click on the edge of the pannel or trying to resize the pannel all t