Sql is very slow

Sql Query
SELECT DISTINCT '13ck0823ba', ' ', b.emplid,
                NVL ((SELECT SUM (b3.total_gross)
                        FROM sysadm.ps_pay_calendar a3,
                             sysadm.ps_pay_check b3
                       WHERE a3.run_id = a.run_id
                         AND b3.emplid = b.emplid
                         AND b3.company = b.company
                         AND b3.paygroup = b.paygroup
                         AND b3.pay_end_dt = b.pay_end_dt
                         AND a3.company = b.company
                         AND a3.paygroup = b.paygroup
                         AND a3.pay_end_dt = b.pay_end_dt),
                     0
                0,
                NVL ((SELECT SUM (b1.lbr_dist_amt)
                        FROM sysadm.ps_py_ldtl_tbl a1,
                             sysadm.ps_tl_payable_time b1
                       WHERE a1.run_id = a.run_id
                         AND b1.emplid = b.emplid
                         AND a1.pay_system = b1.pay_system
                         AND a1.payroll_req_num = b1.payroll_req_num),
                     0
                    ) AS tl_pay_amt,
                0,
                NVL ((SELECT /*+ USE_NL(B2 C2) */
                             SUM (c2.oi_foreign_amt)
                        FROM sysadm.ps_py_ldtl_tbl a2,
                             sysadm.ps_tl_payable_time b2,
                             sysadm.ps_oi_prj_resource c2
                       WHERE a2.run_id = a.run_id
                         AND b2.emplid = b.emplid
                         AND a2.pay_system = b2.pay_system
                         AND a2.payroll_req_num = b2.payroll_req_num
                         AND b2.emplid = c2.emplid
                         AND (   b2.seq_nbr = c2.seq_nbr
                              OR b2.seq_nbr = SUBSTR (c2.resource_id, -13, 12)
                         AND b2.dur = c2.trans_dt
                         AND c2.analysis_type = 'TLB'),
                     0
                    ) AS tlb_pay,
                0, 0, 0
           FROM sysadm.ps_pay_calendar a, sysadm.ps_pay_check b
          WHERE a.run_id = '13CK0823BA'
            AND a.company = b.company
            AND a.paygroup = b.paygroup
            AND a.pay_end_dt = b.pay_end_dt;
Explain Plan
| Id  | Operation                      | Name               | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |IN-OUT|
|   0 | SELECT STATEMENT               |                    |   354 | 18054 |     7  (15)| 00:00:01 |        |      |
|   1 |  SORT AGGREGATE                |                    |     1 |    56 |            |          |        |      |
|   2 |   NESTED LOOPS                 |                    |       |       |            |          |        |      |
|   3 |    NESTED LOOPS                |                    |     1 |    56 |     4   (0)| 00:00:01 |        |      |
|*  4 |     INDEX RANGE SCAN           | PS0PAY_CALENDAR    |     1 |    26 |     1   (0)| 00:00:01 |        |      |
|*  5 |     INDEX RANGE SCAN           | PS1PAY_CHECK       |     1 |       |     2   (0)| 00:00:01 |        |      |
|   6 |    TABLE ACCESS BY INDEX ROWID | PS_PAY_CHECK       |     1 |    30 |     3   (0)| 00:00:01 |        |      |
|   7 |  SORT AGGREGATE                |                    |     1 |    40 |            |          |        |      |
|*  8 |   HASH JOIN                    |                    |    11 |   440 |   151   (1)| 00:00:02 |        |      |
|*  9 |    INDEX RANGE SCAN            | PS0PY_LDTL_TBL     |    10 |   190 |     2   (0)| 00:00:01 |        |      |
|  10 |    TABLE ACCESS BY INDEX ROWID | PS_TL_PAYABLE_TIME |   953 | 20013 |   148   (0)| 00:00:02 |        |      |
|* 11 |     INDEX RANGE SCAN           | IDX$$_49B90004     |   953 |       |     5   (0)| 00:00:01 |        |      |
|  12 |  SORT AGGREGATE                |                    |     1 |   118 |            |          |        |      |
|  13 |   NESTED LOOPS                 |                    |     1 |   118 |    79   (0)| 00:00:01 |        |      |
|  14 |    NESTED LOOPS                |                    |     1 |    99 |    78   (0)| 00:00:01 |        |      |
|  15 |     REMOTE                     | PS_PROJ_RESOURCE   |    18 |  1206 |     6   (0)| 00:00:01 | FSLINK | R->S |
|* 16 |     TABLE ACCESS BY INDEX ROWID| PS_TL_PAYABLE_TIME |     1 |    32 |     4   (0)| 00:00:01 |        |      |
|* 17 |      INDEX RANGE SCAN          | IDX$$_49B90004     |     1 |       |     3   (0)| 00:00:01 |        |      |
|* 18 |    INDEX RANGE SCAN            | PS0PY_LDTL_TBL     |     1 |    19 |     1   (0)| 00:00:01 |        |      |
|  19 |  HASH UNIQUE                   |                    |   354 | 18054 |     7  (15)| 00:00:01 |        |      |
|  20 |   NESTED LOOPS                 |                    |   354 | 18054 |     6   (0)| 00:00:01 |        |      |
|* 21 |    INDEX RANGE SCAN            | PS0PAY_CALENDAR    |     3 |    78 |     2   (0)| 00:00:01 |        |      |
|* 22 |    INDEX RANGE SCAN            | PSEPAY_CHECK       |   103 |  2575 |     2   (0)| 00:00:01 |        |      |
Predicate Information (identified by operation id):
   4 - access("A3"."RUN_ID"=:B1 AND "A3"."COMPANY"=:B2 AND "A3"."PAYGROUP"=:B3 AND "A3"."PAY_END_DT"=:B4)
   5 - access("B3"."EMPLID"=:B1 AND "B3"."COMPANY"=:B2 AND "B3"."PAYGROUP"=:B3 AND "B3"."PAY_END_DT"=:B4)
   8 - access("A1"."PAY_SYSTEM"="B1"."PAY_SYSTEM" AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("PAYROLL_REQ_NUM"))="B1
              "."PAYROLL_REQ_NUM" AND SYS_OP_DESCEND("PAYROLL_REQ_NUM")=SYS_OP_DESCEND("B1"."PAYROLL_REQ_NUM"))
   9 - access("A1"."RUN_ID"=:B1)
  11 - access("B1"."EMPLID"=:B1)
  16 - filter(("B2"."SEQ_NBR"="SEQ_NBR" OR "B2"."SEQ_NBR"=TO_NUMBER(SUBSTR("RESOURCE_ID",-13,12))) AND
              "B2"."DUR"="TRANS_DT")
  17 - access("B2"."EMPLID"="EMPLID")
       filter("B2"."EMPLID"=:B1)
  18 - access("A2"."RUN_ID"=:B1 AND "A2"."PAY_SYSTEM"="B2"."PAY_SYSTEM" AND
              SYS_OP_DESCEND("PAYROLL_REQ_NUM")=SYS_OP_DESCEND("B2"."PAYROLL_REQ_NUM"))
       filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("PAYROLL_REQ_NUM"))="B2"."PAYROLL_REQ_NUM")
  21 - access("A"."RUN_ID"='13CK0823BA')
  22 - access("A"."COMPANY"="B"."COMPANY" AND "A"."PAYGROUP"="B"."PAYGROUP" AND
              "A"."PAY_END_DT"="B"."PAY_END_DT")
Remote SQL Information (identified by operation id):
  15 - SELECT /*+ USE_NL ("PS_PROJ_RESOURCE") */ "RESOURCE_ID","ANALYSIS_TYPE","TRANS_DT","FOREIGN_AMOUNT","E
        MPLID","SEQ_NBR" FROM "SYSADM"."PS_PROJ_RESOURCE" "PS_PROJ_RESOURCE" WHERE "EMPLID"=:1 AND
        "ANALYSIS_TYPE"='TLB' (accessing 'FSLINK' )
57 rows selected.

Kindly find the actual plan.
SQL Monitoring Report
SQL Text
SELECT /* sqlt_s31029 */ DISTINCT '13ck0823ba' , ' ' , B.EMPLID , NVL(( SELECT SUM(B3.TOTAL_GROSS) FROM SYSADM.PS_PAY_CALENDAR A3 , SYSADM.PS_PAY_CHECK B3 WHERE A3.RUN_ID = A.RUN_ID AND B3.EMPLID = B.EMPLID AND B3.COMPANY = B.COMPANY AND B3.PAYGROUP = B.PAYGROUP AND B3.PAY_END_DT = B.PAY_END_DT AND A3.COMPANY = B.COMPANY AND A3.PAYGROUP = B.PAYGROUP AND A3.PAY_END_DT = B.PAY_END_DT ),0), 0, NVL( ( SELECT SUM(B1.LBR_DIST_AMT) FROM SYSADM.PS_PY_LDTL_TBL A1 , SYSADM.PS_TL_PAYABLE_TIME B1 WHERE
A1.RUN_ID = A.RUN_ID AND B1.EMPLID = B.EMPLID AND A1.PAY_SYSTEM = B1.PAY_SYSTEM AND A1.PAYROLL_REQ_NUM = B1.PAYROLL_REQ_NUM ),0)AS TL_PAY_AMT, 0, NVL( ( SELECT /*+ USE_NL(B2 C2) */ SUM(C2.OI_FOREIGN_AMT) FROM SYSADM.PS_PY_LDTL_TBL A2 , SYSADM.PS_TL_PAYABLE_TIME B2 , SYSADM.PS_OI_PRJ_RESOURCE C2 WHERE A2.RUN_ID = A.RUN_ID AND B2.EMPLID = B.EMPLID AND A2.PAY_SYSTEM = B2.PAY_SYSTEM AND A2.PAYROLL_REQ_NUM = B2.PAYROLL_REQ_NUM AND B2.EMPLID = C2.EMPLID AND ( B2.SEQ_NBR = C2.SEQ_NBR OR B2.SEQ_NBR =
SUBSTR( C2.RESOURCE_ID,-13,12)) AND B2.DUR = C2.TRANS_DT AND C2.ANALYSIS_TYPE = 'TLB' ),0) AS TLB_PAY,0,0,0 FROM SYSADM.PS_PAY_CALENDAR A, SYSADM.PS_PAY_CHECK B WHERE A.RUN_ID = '13CK0823BA' AND A.COMPANY = B.COMPANY AND A.PAYGROUP = B.PAYGROUP AND A.PAY_END_DT = B.PAY_END_DT
Global Information
Status              :  DONE (ALL ROWS)
Instance ID         :  1
Session             :  SYS (594:719)
SQL ID              :  7kw0g9wd8456b
SQL Execution ID    :  16777216
Execution Started   :  09/18/2013 03:35:47
First Refresh Time  :  09/18/2013 03:36:02
Last Refresh Time   :  09/18/2013 07:04:57
Duration            :  12550s
Module/Action       :  sqltxadmin.sqlt$a (xecute)/31029 41 ALTER SESSION SET EVENT
Service             :  SYS$USERS
Program             :  [email protected] (TNS V1-V3
Fetch Calls         :  143
Global Stats
====================================================================================================
| Elapsed |   Cpu   |    IO    | Concurrency | Cluster  |  Other   | Fetch | Buffer | Read | Read  |
| Time(s) | Time(s) | Waits(s) |  Waits(s)   | Waits(s) | Waits(s) | Calls |  Gets  | Reqs | Bytes |
====================================================================================================
|   12550 |    6451 |     1079 |        0.01 |     2.61 |     5018 |   143 |     2G | 206K |   2GB |
====================================================================================================
SQL Plan Monitoring Details (Plan Hash Value=298818496)
================================================================================================================================================================================================
| Id |            Operation             |        Name        |  Rows   | Cost |   Time    | Start  | Execs |   Rows   | Read  | Read  |  Mem  | Activity |           Activity Detail           |
|    |                                  |                    | (Estim) |      | Active(s) | Active |       | (Actual) | Reqs  | Bytes | (Max) |   (%)    |             (# samples)             |
================================================================================================================================================================================================
|  0 | SELECT STATEMENT                 |                    |         |      |     12536 |    +15 |  2125 |     2125 |       |       |       |          |                                     |
|  1 |   SORT AGGREGATE                 |                    |       1 |      |     12536 |    +15 |  2125 |     2125 |       |       |       |          |                                     |
|  2 |    NESTED LOOPS                  |                    |         |      |     12536 |    +15 |  2125 |     2163 |       |       |       |          |                                     |
|  3 |     NESTED LOOPS                 |                    |       1 |    4 |     12536 |    +15 |  2125 |     2163 |       |       |       |          |                                     |
|  4 |      INDEX RANGE SCAN            | PS0PAY_CALENDAR    |       1 |    1 |     12536 |    +15 |  2125 |     2125 |       |       |       |          |                                     |
|  5 |      INDEX RANGE SCAN            | PS1PAY_CHECK       |       1 |    2 |     12536 |    +15 |  2125 |     2163 |  1575 |  12MB |       |     0.01 | db file sequential read (1)         |
|  6 |     TABLE ACCESS BY INDEX ROWID  | PS_PAY_CHECK       |       1 |    3 |     12536 |    +15 |  2163 |     2163 |    78 | 624KB |       |          |                                     |
|  7 |   SORT AGGREGATE                 |                    |       1 |      |     12536 |    +15 |  2124 |     2124 |       |       |       |          |                                     |
|  8 |    HASH JOIN                     |                    |      11 |  151 |     12536 |    +15 |  2124 |    29600 |       |       |    1M |          |                                     |
|  9 |     INDEX RANGE SCAN             | PS0PY_LDTL_TBL     |      10 |    2 |     12536 |    +15 |  2124 |    70092 |       |       |       |          |                                     |
| 10 |     TABLE ACCESS BY INDEX ROWID  | PS_TL_PAYABLE_TIME |     953 |  148 |     12550 |     +1 |  2124 |       3M |  192K |   1GB |       |     0.90 | Cpu (2)                             |
|    |                                  |                    |         |      |           |        |       |          |       |       |       |          | db file sequential read (111)       |
| 11 |      INDEX RANGE SCAN            | IDX$$_49B90004     |     953 |    5 |     12551 |     +0 |  2124 |       3M | 11273 |  88MB |       |     0.06 | db file sequential read (8)         |
| 12 |   SORT AGGREGATE                 |                    |       1 |      |     12536 |    +15 |  2124 |     2124 |       |       |       |          |                                     |
| 13 |    NESTED LOOPS                  |                    |       1 |   79 |     12536 |    +15 |  2124 |    33990 |       |       |       |          |                                     |
| 14 |     NESTED LOOPS                 |                    |       1 |   78 |     12536 |    +15 |  2124 |       3M |       |       |       |          |                                     |
| 15 |      REMOTE                      | PS_PROJ_RESOURCE   |      18 |    6 |     12547 |     +4 |  2124 |       3M |       |       |       |     4.13 | Cpu (1)                             |
|    |                                  |                    |         |      |           |        |       |          |       |       |       |          | SQL*Net message from dblink (58)    |
|    |                                  |                    |         |      |           |        |       |          |       |       |       |          | SQL*Net more data from dblink (459) |
| 16 |      TABLE ACCESS BY INDEX ROWID | PS_TL_PAYABLE_TIME |       1 |    4 |     12539 |    +12 |    3M |       3M |       |       |       |     2.14 | Cpu (268)                           |
| 17 |       INDEX RANGE SCAN           | IDX$$_49B90004     |       1 |    3 |     12536 |    +15 |    3M |       4G |       |       |       |     0.48 | Cpu (60)                            |
| 18 |     INDEX RANGE SCAN             | PS0PY_LDTL_TBL     |       1 |    1 |     12536 |    +15 |    3M |    33990 |       |       |       |     0.01 | Cpu (1)                             |
| 19 |   HASH UNIQUE                    |                    |     354 |    7 |     12536 |    +15 |     1 |     2117 |       |       |    1M |          |                                     |
| 20 |    NESTED LOOPS                  |                    |     354 |    6 |     12536 |    +15 |     1 |     2147 |       |       |       |          |                                     |
| 21 |     INDEX RANGE SCAN             | PS0PAY_CALENDAR    |       3 |    2 |     12536 |    +15 |     1 |        7 |       |       |       |          |                                     |
| 22 |     INDEX RANGE SCAN             | PSEPAY_CHECK       |     103 |    2 |     12536 |    +15 |     7 |     2147 |    70 | 560KB |       |          |                                     |
================================================================================================================================================================================================

Similar Messages

  • SQL Azure very slow

    Hi Experts
    We have SQL Azure database that is running very slow, so i took a backup of the database and restored on my on premise sql server express edition. 
    I tried a update statement on a logs tables that have approximately about 1,062,367 records.
    UPDATE logs set FileId = NULL
    where LEN(FileId) < 36
    The above update statement updates about 910,593 records on localhost host in 20 sec and if i run the same updates statement on SQL Azure it took 40mins and 16sec. The update statement was issues using SQL Server management studio installed on my local machine.
    With reference to internet connection, we have fiber connection with download speed of 70.62mbps and upload speed of 84.09mbps 
    I am not sure whats going wrong with SQL Azure database i.e. could there be a specific fault on my database at Microsoft side etc.
    Any advice or suggestion will be highly appreciated.
    Kind Regards
    Bhavesh
    Bhavesh

    I have waited for 40 min for the update to complete and it has successfully and updated logs table so i can't re-run the update statement again because there will be no records to update.
    I have managed to find another example that took about 10 mins to complete on the SSMS but when ran the same query on the azure management portal it took only 6 secs which puzzled me. 
    Here is the query: 
    select   
     l.Value3 as ClientReference,
     l.[Key] as ActivityUser,
     l.Value2 as FormDisplayName,
     l.Value6 as Status,
     l.DateStamp as LastUpdated,
     l.[Action] as FileDescription,
     l.CompanyId as ClientID,
     l.FileId as FileID,
     f.id
    from Logs l
    LEFT OUTER JOIN files f on f.Id = l.FileId 
    where l.AccountId = 578
    and type = 1
    The above query returns about 3694 records only.
    Here is the details of the query performance 
    Azure Management Portal
    Duration(ms): 6487
    CPU(ms): 2443
    Logical Reads: 74729
    Physical Reads: 66147
    Logical Writes: 0
    SSMS
    Duration(ms): 615259
    CPU(ms): 3666
    Logical Reads: 74729
    Physical Reads: 71370
    Logical Writes: 0
    Any update will be appreciated.
    Bhavesh

  • SQL Query very slow.

    I have a table which has 40million data in it. Of-course partitioned!.
    begin
    pk_cm_entity_context.set_entity_in_context(1);
    end;
    SELECT COUNT(1) FROM XFACE_ADDL_DETAILS_TXNLOG;
    alter table XFACE_ADDL_DETAILS_TXNLOG rename to XFACE_ADDLDTS_TXNLOG_PTPART;
    SELECT COUNT(1) FROM XFACE_ADDLDTS_TXNLOG_PTPART;
    -- Create table
    create table XFACE_ADDL_DETAILS_TXNLOG
    REF_TXN_NO CHAR(40),
    REF_USR_NO CHAR(40),
    REF_KEY_NO VARCHAR2(50),
    REF_TXN_NO_ORG CHAR(40),
    REF_USR_NO_ORG CHAR(40),
    RECON_CODE VARCHAR2(25),
    COD_TASK_DERIVED VARCHAR2(5),
    COD_CHNL_ID VARCHAR2(6),
    COD_SERVICE_ID VARCHAR2(10),
    COD_USER_ID VARCHAR2(30),
    COD_AUTH_ID VARCHAR2(30),
    COD_ACCT_NO CHAR(22),
    TYP_ACCT_NO VARCHAR2(4),
    COD_SUB_ACCT_NO CHAR(16),
    COD_DEP_NO NUMBER(5),
    AMOUNT NUMBER(15,2),
    COD_CCY VARCHAR2(3),
    DAT_POST DATE,
    DAT_VALUE DATE,
    TXT_TXN_NARRATIVE VARCHAR2(60),
    DATE_CHEQUE_ISSUE DATE,
    TXN_BUSINESS_TYPE VARCHAR2(10),
    CARD_NO CHAR(20),
    INVENTORY_CODE CHAR(10),
    INVENTORY_NO CHAR(20),
    CARD_PASSBOOK_NO CHAR(30),
    COD_CASH_ANALYSIS CHAR(20),
    BANK_INFORMATION_NO CHAR(8),
    BATCH_NO CHAR(10),
    SUMMARY VARCHAR2(60),
    MAIN_IC_TYPE CHAR(1),
    MAIN_IC_NO CHAR(48),
    MAIN_IC_NAME CHAR(64),
    MAIN_IC_CHECK_RETURN_CODE CHAR(1),
    DEPUTY_IC_TYPE CHAR(1),
    DEPUTY_IC_NO CHAR(48),
    DEPUTY_NAME CHAR(64),
    DEPUTY_IC_CHECK_RETURN_CODE CHAR(1),
    ACCOUNT_PROPERTY CHAR(4),
    CHEQUE_NO CHAR(20),
    COD_EXT_TASK CHAR(10),
    COD_MODULE CHAR(4),
    ACC_PURPOSE_CODE VARCHAR2(15),
    NATIONALITY CHAR(3),
    CUSTOMER_NAME CHAR(192),
    COD_INCOME_EXPENSE CHAR(6),
    COD_EXT_BRANCH CHAR(6),
    COD_ACCT_TITLE CHAR(192),
    FLG_CA_TT CHAR(1),
    DAT_EXT_LOCAL DATE,
    ACCT_OWNER_VALID_RESULT CHAR(1),
    FLG_DR_CR CHAR(1),
    FLG_ONLINE_UPLOAD CHAR(1),
    FLG_STMT_DISPLAY CHAR(1),
    COD_TXN_TYPE NUMBER(1),
    DAT_TS_TXN TIMESTAMP(6),
    LC_BG_GUARANTEE_NO VARCHAR2(20),
    COD_OTHER_ACCT_NO CHAR(22),
    COD_MOD_OTHER_ACCT_NO CHAR(4),
    COD_CC_BRN_SUB_ACCT NUMBER(5),
    COD_CC_BRN_OTHR_ACCT NUMBER(5),
    COD_ENTITY_VPD NUMBER(5) default NVL(sys_context('CLIENTCONTEXT','entity_code'),11),
    COD_EXT_TASK_REV VARCHAR2(10)
    partition by hash (REF_TXN_NO)
    PARTITIONS 128
    store in (FCHDATA1,FCHDATA2,FCHDATA3,FCHDATA4, FCHDATA5, FCHDATA6, FCHDATA7, FCHDATA8);
    insert /*+APPEND NOLOGGING */ into XFACE_ADDL_DETAILS_TXNLOG
    select /*+PARALLEL */ * from XFACE_ADDLDTS_TXNLOG_PTPART;
    -- Add comments to the table
    comment on table XFACE_ADDL_DETAILS_TXNLOG
    is ' Additional Data log table ';
    -- Add comments to the columns
    comment on column XFACE_ADDL_DETAILS_TXNLOG.REF_TXN_NO
    is 'Transaction Reference Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.REF_USR_NO
    is 'User Reference Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.REF_KEY_NO
    is 'Unique key to identify a leg of the transaction';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.REF_TXN_NO_ORG
    is 'Original Transaction Reference Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.REF_USR_NO_ORG
    is 'Original Transaction User Reference Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.RECON_CODE
    is 'Reconciliation of transactions in future';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_TASK_DERIVED
    is 'Transaction mnemonic for the request';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_CHNL_ID
    is 'Channel ID';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_SERVICE_ID
    is 'Service ID';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_USER_ID
    is 'User ID';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_AUTH_ID
    is 'Authorizer ID';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_ACCT_NO
    is 'It can be Card number or MCA or GL or CASH GL';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.TYP_ACCT_NO
    is 'Type of input (Valid values CARD, MCA, GL, CASH, LN)';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_SUB_ACCT_NO
    is 'MC Sub Account Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_DEP_NO
    is 'Deposit Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.AMOUNT
    is 'Transaction Amount';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_CCY
    is 'Currency Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DAT_POST
    is 'Posting Date of the transaction';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DAT_VALUE
    is 'Value Date of the transaction';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.TXT_TXN_NARRATIVE
    is 'Text Transaction Narrative';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DATE_CHEQUE_ISSUE
    is 'Date of Issue of Cheque';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.TXN_BUSINESS_TYPE
    is 'Transaction Business Type';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.CARD_NO
    is 'Card Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.INVENTORY_CODE
    is 'Inventory Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.INVENTORY_NO
    is 'Inventory Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.CARD_PASSBOOK_NO
    is 'Card Passbook Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_CASH_ANALYSIS
    is 'Cash Analysis Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.BANK_INFORMATION_NO
    is 'Bank Information Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.BATCH_NO
    is 'Batch Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.SUMMARY
    is 'Summary';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.MAIN_IC_TYPE
    is 'IC Type';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.MAIN_IC_NO
    is 'IC Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.MAIN_IC_NAME
    is 'IC Name';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.MAIN_IC_CHECK_RETURN_CODE
    is 'IC Check Return Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DEPUTY_IC_TYPE
    is 'Deputy IC Type';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DEPUTY_IC_NO
    is 'Deputy IC Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DEPUTY_NAME
    is 'Deputy Name';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DEPUTY_IC_CHECK_RETURN_CODE
    is 'Deputy IC Check Return Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.ACCOUNT_PROPERTY
    is 'Account Property';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.CHEQUE_NO
    is 'Cheque Number';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_EXT_TASK
    is 'External Task Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_MODULE
    is 'Module Code - CH, TD, RD , LN, CASH, GL';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.ACC_PURPOSE_CODE
    is 'Account Purpose Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.NATIONALITY
    is 'Nationality';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.CUSTOMER_NAME
    is 'Customer Name';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_INCOME_EXPENSE
    is 'Income Expense Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_EXT_BRANCH
    is 'External Branch Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_ACCT_TITLE
    is 'Account Title Code';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.FLG_CA_TT
    is 'Cash or Funds Transfer flag';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DAT_EXT_LOCAL
    is 'Local Date';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.ACCT_OWNER_VALID_RESULT
    is 'Account Owner Valid Result';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.FLG_DR_CR
    is 'Flag Debit Credit - D, C.';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.FLG_ONLINE_UPLOAD
    is 'Flag Online Upload - O, U.';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.FLG_STMT_DISPLAY
    is 'Statement Display Flag - Y/N, Y(Normal Reversal), N(Correction Reversal)';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_TXN_TYPE
    is 'To denote the kind of transaction:
    1 ?Cash Credit Transaction
    2 ?Cash Debit Transaction
    3 ?Funds Transfer Credit Transaction
    4 ?Funds Transfer Debit Transaction
    comment on column XFACE_ADDL_DETAILS_TXNLOG.DAT_TS_TXN
    is 'Date and Timestamp of the record being inserted';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.LC_BG_GUARANTEE_NO
    is 'LC/BG Guarantee Number for which the request for the Liquidation has been initiated.';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_OTHER_ACCT_NO
    is 'Other Account No';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_MOD_OTHER_ACCT_NO
    is 'Module Code of Other Account No - CH, TD, RD , LN, CASH, GL';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_CC_BRN_SUB_ACCT
    is 'Branch Code for Sub Account';
    comment on column XFACE_ADDL_DETAILS_TXNLOG.COD_CC_BRN_OTHR_ACCT
    is 'Branch Code for Other Account';
    -- Create/Recreate indexes
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_1;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_2;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_3;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_4;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_5;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_6;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_7;
    drop index IN_XFACE_ADDL_DETAILS_TXNLOG_8;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_1 on XFACE_ADDL_DETAILS_TXNLOG (REF_TXN_NO, REF_KEY_NO, COD_SUB_ACCT_NO, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH (REF_TXN_NO, REF_KEY_NO, COD_SUB_ACCT_NO) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_2 on XFACE_ADDL_DETAILS_TXNLOG (REF_USR_NO, REF_KEY_NO, COD_SUB_ACCT_NO, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(REF_USR_NO, REF_KEY_NO, COD_SUB_ACCT_NO) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_3 on XFACE_ADDL_DETAILS_TXNLOG (COD_SUB_ACCT_NO, FLG_STMT_DISPLAY,DAT_POST COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(COD_SUB_ACCT_NO, FLG_STMT_DISPLAY) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_4 on
    XFACE_ADDL_DETAILS_TXNLOG (COD_ACCT_NO, REF_TXN_NO, COD_TXN_TYPE, COD_USER_ID, COD_EXT_BRANCH, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(COD_ACCT_NO, REF_TXN_NO, COD_TXN_TYPE, COD_USER_ID, COD_EXT_BRANCH)
    PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_5 on XFACE_ADDL_DETAILS_TXNLOG (COD_USER_ID, DAT_POST, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(COD_USER_ID) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_6 on XFACE_ADDL_DETAILS_TXNLOG (REF_TXN_NO_ORG, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(REF_TXN_NO_ORG) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_7 on XFACE_ADDL_DETAILS_TXNLOG (DAT_EXT_LOCAL, DAT_POST,TXN_BUSINESS_TYPE, FLG_ONLINE_UPLOAD, COD_CHNL_ID, REF_TXN_NO, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(DAT_EXT_LOCAL) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    /* Previous Key order: (COD_EXT_BRANCH,DAT_POST,REF_TXN_NO_ORG,COD_SERVICE_ID,COD_ENTITY_VPD) */
    create index IN_XFACE_ADDL_DETAILS_TXNLOG_8 on XFACE_ADDL_DETAILS_TXNLOG (DAT_POST, COD_EXT_BRANCH, REF_TXN_NO_ORG, COD_SERVICE_ID, COD_ENTITY_VPD)
    GLOBAL PARTITION BY HASH(DAT_POST) PARTITIONS 128 STORE IN (FCHINDX1, FCHINDX2, FCHINDX3, FCHINDX4) PARALLEL (DEGREE 32) NOLOGGING;
    ALTER TABLE XFACE_ADDL_DETAILS_TXNLOG NOPARALLEL PCTFREE 50 INITRANS 128 LOGGING;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_1 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_2 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_3 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_4 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_5 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_6 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_7 NOPARALLEL INITRANS 128;
    ALTER index IN_XFACE_ADDL_DETAILS_TXNLOG_8 NOPARALLEL INITRANS 128;
    BEGIN
    DBMS_RLS.ADD_POLICY(OBJECT_SCHEMA => UPPER('FCR44HOST'),
    OBJECT_NAME => UPPER('XFACE_ADDL_DETAILS_TXNLOG '),
    POLICY_NAME => 'FC_ENTITY_POLICY',
    FUNCTION_SCHEMA => UPPER('FCR44HOST'),
    POLICY_FUNCTION => 'pk_cm_vpd_policy.get_entity_predicate',
    STATEMENT_TYPES => 'select,insert,update,delete',
    UPDATE_CHECK => TRUE,
    ENABLE => TRUE,
    STATIC_POLICY => FALSE,
    POLICY_TYPE => DBMS_RLS.SHARED_STATIC,
    LONG_PREDICATE => FALSE,
    SEC_RELEVANT_COLS => NULL,
    SEC_RELEVANT_COLS_OPT => NULL);
    END;
    begin
    dbms_stats.gather_table_stats(ownname => 'FCR44HOST',tabname => 'XFACE_ADDL_DETAILS_TXNLOG', cascade=>true,method_opt=>'for all columns size 1',degree => 32, GRANULARITY => 'PARTITION');
    end;
    Query which takes time.
    INSERT INTO xface_addl_dtls_tlog_temp
    (ref_txn_no,
    ref_usr_no,
    ref_key_no,
    ref_txn_no_org,
    ref_usr_no_org,
    recon_code,
    cod_task_derived,
    cod_chnl_id,
    cod_service_id,
    cod_user_id,
    cod_auth_id,
    cod_acct_no,
    typ_acct_no,
    cod_sub_acct_no,
    cod_dep_no,
    amount,
    cod_ccy,
    dat_post,
    dat_value,
    txt_txn_narrative,
    date_cheque_issue,
    txn_business_type,
    card_no,
    inventory_code,
    inventory_no,
    card_passbook_no,
    cod_cash_analysis,
    bank_information_no,
    batch_no,
    summary,
    main_ic_type,
    main_ic_no,
    main_ic_name,
    main_ic_check_return_code,
    deputy_ic_type,
    deputy_ic_no,
    deputy_name,
    deputy_ic_check_return_code,
    account_property,
    cheque_no,
    cod_ext_task,
    cod_module,
    acc_purpose_code,
    nationality,
    customer_name,
    cod_income_expense,
    cod_ext_branch,
    cod_acct_title,
    flg_ca_tt,
    dat_ext_local,
    acct_owner_valid_result,
    flg_dr_cr,
    flg_online_upload,
    flg_stmt_display,
    cod_txn_type,
    dat_ts_txn,
    lc_bg_guarantee_no,
    cod_other_acct_no,
    cod_mod_other_acct_no,
    cod_cc_brn_sub_acct,
    cod_cc_brn_othr_acct,
    cod_ext_task_rev,
    sessionid)
    SELECT ref_txn_no,
    ref_usr_no,
    ref_key_no,
    ref_txn_no_org,
    ref_usr_no_org,
    recon_code,
    cod_task_derived,
    cod_chnl_id,
    cod_service_id,
    cod_user_id,
    cod_auth_id,
    cod_acct_no,
    typ_acct_no,
    cod_sub_acct_no,
    cod_dep_no,
    amount,
    cod_ccy,
    dat_post,
    dat_value,
    txt_txn_narrative,
    date_cheque_issue,
    txn_business_type,
    card_no,
    inventory_code,
    inventory_no,
    card_passbook_no,
    cod_cash_analysis,
    bank_information_no,
    batch_no,
    summary,
    main_ic_type,
    main_ic_no,
    main_ic_name,
    main_ic_check_return_code,
    deputy_ic_type,
    deputy_ic_no,
    deputy_name,
    deputy_ic_check_return_code,
    account_property,
    cheque_no,
    cod_ext_task,
    cod_module,
    acc_purpose_code,
    nationality,
    customer_name,
    cod_income_expense,
    cod_ext_branch,
    cod_acct_title,
    flg_ca_tt,
    dat_ext_local,
    acct_owner_valid_result,
    flg_dr_cr,
    flg_online_upload,
    flg_stmt_display,
    cod_txn_type,
    dat_ts_txn,
    lc_bg_guarantee_no,
    cod_other_acct_no,
    cod_mod_other_acct_no,
    cod_cc_brn_sub_acct,
    cod_cc_brn_othr_acct,
    cod_ext_task_rev,
    var_l_sessionid
    FROM xface_addl_details_txnlog
    WHERE cod_sub_acct_no = var_pi_cod_acct_no
    AND dat_post between var_pi_start_dat AND var_pi_end_dat;
    Index referred is in_xface_addl_details_txnlog_3.
    First time when i execute the query it takes huge time. but subsequent queries are faster. This is only if i pass same account and criteria again.
    Observed that first time it goes for physical reads which takes time. and subsequent runs physical reads are less.....
    Request suggestions.....this is account statement inquiry user may have 10000txns in a day as well
    Bymistake earlier i raised this in "Oracle -> Text"
    Slow inserts due to physical reads every time for fresh account i am passin
    They suggested to use bind variable. But as i know, we are already using bind variables to bind account number and start and end date.

    My Replies below.
    Whenever you post provide your 4 digit Oracle version (SELECT * FROM V$VERSION).
    Ans :
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE     11.2.0.3.0     Production"
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    1. If your question is about the INSERT query into xface_addl_dtls_tlog_temp why didn't you post any information about the DDL for that table? Is it the same structure as the table you did post DDL for?
    Ans :
    -- Create table
    create global temporary table XFACE_ADDL_DTLS_TLOG_TEMP
    REF_TXN_NO CHAR(40) not null,
    REF_USR_NO CHAR(40) not null,
    REF_KEY_NO VARCHAR2(50),
    REF_TXN_NO_ORG CHAR(40),
    REF_USR_NO_ORG CHAR(40),
    RECON_CODE VARCHAR2(25),
    COD_TASK_DERIVED VARCHAR2(5),
    COD_CHNL_ID VARCHAR2(6),
    COD_SERVICE_ID VARCHAR2(10),
    COD_USER_ID VARCHAR2(30),
    COD_AUTH_ID VARCHAR2(30),
    COD_ACCT_NO CHAR(22),
    TYP_ACCT_NO VARCHAR2(4),
    COD_SUB_ACCT_NO CHAR(16),
    COD_DEP_NO NUMBER(5),
    AMOUNT NUMBER(15,2),
    COD_CCY VARCHAR2(3),
    DAT_POST DATE,
    DAT_VALUE DATE,
    TXT_TXN_NARRATIVE VARCHAR2(60),
    DATE_CHEQUE_ISSUE DATE,
    TXN_BUSINESS_TYPE VARCHAR2(10),
    CARD_NO CHAR(20),
    INVENTORY_CODE CHAR(10),
    INVENTORY_NO CHAR(20),
    CARD_PASSBOOK_NO CHAR(30),
    COD_CASH_ANALYSIS CHAR(20),
    BANK_INFORMATION_NO CHAR(8),
    BATCH_NO CHAR(10),
    SUMMARY VARCHAR2(60),
    MAIN_IC_TYPE CHAR(1),
    MAIN_IC_NO VARCHAR2(150),
    MAIN_IC_NAME VARCHAR2(192),
    MAIN_IC_CHECK_RETURN_CODE CHAR(1),
    DEPUTY_IC_TYPE CHAR(1),
    DEPUTY_IC_NO VARCHAR2(150),
    DEPUTY_NAME VARCHAR2(192),
    DEPUTY_IC_CHECK_RETURN_CODE CHAR(1),
    ACCOUNT_PROPERTY CHAR(4),
    CHEQUE_NO CHAR(20),
    COD_EXT_TASK CHAR(10),
    COD_MODULE CHAR(4),
    ACC_PURPOSE_CODE VARCHAR2(15),
    NATIONALITY CHAR(3),
    CUSTOMER_NAME CHAR(192),
    COD_INCOME_EXPENSE CHAR(6),
    COD_EXT_BRANCH CHAR(6),
    COD_ACCT_TITLE VARCHAR2(360),
    FLG_CA_TT CHAR(1),
    DAT_EXT_LOCAL DATE,
    ACCT_OWNER_VALID_RESULT CHAR(1),
    FLG_DR_CR CHAR(1),
    FLG_ONLINE_UPLOAD CHAR(1),
    FLG_STMT_DISPLAY CHAR(1),
    COD_TXN_TYPE NUMBER(1),
    DAT_TS_TXN TIMESTAMP(6),
    LC_BG_GUARANTEE_NO VARCHAR2(20),
    COD_OTHER_ACCT_NO CHAR(22),
    COD_MOD_OTHER_ACCT_NO CHAR(4),
    COD_CC_BRN_SUB_ACCT NUMBER(5),
    COD_CC_BRN_OTHR_ACCT NUMBER(5),
    COD_EXT_TASK_REV VARCHAR2(10),
    SESSIONID NUMBER default USERENV('SESSIONID') not null
    on commit delete rows;
    -- Create/Recreate indexes
    create index IN_XFACE_ADDL_DTLS_TLOG_TEMP on XFACE_ADDL_DTLS_TLOG_TEMP (COD_SUB_ACCT_NO, REF_TXN_NO, COD_SERVICE_ID, REF_KEY_NO, SESSIONID);
    2. Why doesn't your INSERT query use APPEND, NOLOGGING and PARALLEL like the first query you posted? If those help for the first query why didn't you try them for the query you are now having problems with?
    Ans :
    I will try to use append but i cannot use parallel since i have hardware limitations.
    3. What does this mean: 'Index referred is in_xface_addl_details_txnlog_3.'? You haven't posted any plan that refers to any index. Do you have an execution plan? Why didn't you post it?
    Ans :
    Plan hash value: 4081844790
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
    | 0 | INSERT STATEMENT | | | | 5 (100)| | | |
    | 1 | LOAD TABLE CONVENTIONAL | | | | | | | |
    | 2 | FILTER | | | | | | | |
    | 3 | PARTITION HASH ALL | | 1 | 494 | 5 (0)| 00:00:01 | 1 | 128 |
    | 4 | TABLE ACCESS BY GLOBAL INDEX ROWID| XFACE_ADDL_DETAILS_TXNLOG | 1 | 494 | 5 (0)| 00:00:01 | ROWID | ROWID |
    | 5 | INDEX RANGE SCAN | IN_XFACE_ADDL_DETAILS_TXNLOG_3 | 1 | | 3 (0)| 00:00:01 | 1 | 128 |
    4. Why are you defining 37 columns as CHAR datatypes? Are you aware that CHAR data REQUIRES the use of the designated number of BYTES/CHARACTERS?
    Ans :
    I understand and appreciate your points, but since it is huge application and is built over a period of time. I am afraid if i will be allowed to do change on datatypes. there are lot of queries over this table.
    5. Are you aware that #4 means those 37 columns columns, even if all of them are NULL, mean that your MINIMUM record length is 1012? Care to guess how many of those records Oracle can fit into an 8k block? And that is if you ignore the other 26 VARCHAR2, NUMBER and DATE columns.
    Two of your columns take 192 bytes MINIMUM even if they are null
    CUSTOMER_NAME CHAR(192),
    COD_ACCT_TITLE CHAR(192)
    Why are you wasting all of that space? If you are using a multi-byte character set and your data is multi-byte those 37 columns are using even more space because some characters will use more than one byte.
    If the name and title average 30 characters/bytes then those two columns alone use 300+ unused bytes. With 40 million records those unused bytes, just for those two columns take 12 GB of space.
    WIth a block size of 8k that would totally waste 1.5 million blocks that Oracle has to read just to ignore the empty space that isn't being used.
    I highly suspect that your use of CHAR is a large part of this performance problem and probably other performance problems in your system. Not only for this table but for any other table that uses similar CHAR datatypes and wastes space.
    Please reconsider your use of CHAR datatypes like this. I can't imagine what justification you have for using them.
    Ans :
    I understand your points, but since it is huge application is built over a period of time. I am afraid if i will be allowed to do change on datatypes.
    I have to manage in current situation. Not expecting query to respond in millisecs but not even 40secs which is happening currently.
    Edited by: Rohit Jadhav on Dec 30, 2012 6:44 PM

  • SQL query very slow on Data warehouse

    Guys,
    Is there any soul who is an expert on SQL ? I do run this query agaist a 2 table and a view which has 30 million rows. Unfortunately the table is partitioned but not the Unique index.
    This query takes about 3 hours to run. Is there anyway of writing this in a better way ??
    select
    a.xcm_consumer_pk,
    b.p_vin_prtn_c,
    b.vin_type_c,
    b.vin_id_c,
    b.cveh_owner_cycle_r,
    b.veh_reg_no_c,
    b.veh_make_c,
    b.veh_model_c,
    b.veh_deriv_c,
    b.veh_reg_y,
    b.cveh_link_start_y,
    b.cveh_prd_rpl_y,
    b.cveh_sl_dlr_c,
    c.cu26_address_x
    from
    xcm_cu01_customer a, xcm_cv01_cons_veh b,
    xcm_view_cons_latest_e_mail c
    where
    a.country_iso3_c = 'GBR'
    and (a.cust_brand_c in ('F','Y'))
    and a.xcm_consumer_pk = b.xcm_consumer_pk(+)
    and b.cveh_owner_cycle_r(+) = 1
    and b.cveh_link_end_y(+) between SYSDATE and '31-Dec-9999'
    and a.xcm_consumer_pk = c.xcm_consumer_pk(+)
    The definition of the view xcm_view_cons_latest_e_mail is as below.
    SELECT
    A.xcm_consumer_pk,
    A.cu26_type_c,
    A.p_update_s,
    A.cu26_address_x
    FROM XCM_CU26_E_MAIL A
    WHERE TO_CHAR(NVL(A.p_update_s, '01-Jan-0001'), 'YYYYMMDD') || NVL(A.cu26_type_c, ' ') =
         (SELECT MAX(TO_CHAR(NVL(b.p_update_s, '01-Jan-0001'), 'YYYYMMDD') || NVL(b.cu26_type_c, ' '))
         FROM XCM_CU26_E_MAIL b
         WHERE A.xcm_consumer_pk = b.xcm_consumer_pk);
    Most of our query uses the same format and ver 9.2.0.2 has totally screwed up our job times.. Any idea please ??

    In addition to Maurice's questions:
    Are you sure you really need the outer joins?
    From your statement "... and ver 9.2.0.2 has totally screwed up our job times" I assume that you have recently upgraded. So:
    Are you sure that all relevant indexes exist on the new version?
    Have you analyzed all the tables involved since the upgrade?
    Are you sure that the init parameters are set appropriately? Note that depending on what version you upgraded from, you may need to make substantial changes to various parameters to get optimal performance.
    John

  • Report region runs very slow, but its sql runs fast

    We have a page with a report region Type :SQL Query (plsq function body returning sql query) which runs very slow, pegging the tach on our db box for almost a minute before returning report rows. However, if we run the generated sql from sql plus, it returns all the rows in under 10 seconds with nary a blip on the box. Any idas how what could be causing this or how to debug?
    Thanks,
    Steve

    OK, here is the bad boy, shortly after our code that returns the data.
    declare
    rc__ number;
    simple_list__ owa_util.vc_arr;
    complex_list__ owa_util.vc_arr;
    begin
    owa.init_cgi_env(:n__,:nm__,:v__);
    htp.HTBUF_LEN := 63;
    null;
    null;
    simple_list__(1) := 'sys.%';
    simple_list__(2) := 'dbms\_%';
    simple_list__(3) := 'utl\_%';
    simple_list__(4) := 'owa\_%';
    simple_list__(5) := 'owa.%';
    simple_list__(6) := 'htp.%';
    simple_list__(7) := 'htf.%';
    simple_list__(8) := 'wpg_docload.%';
    if ((owa_match.match_pattern(p_string =>
    'f'
    /* */,p_simple_pattern =>
    simple_list__
    ,p_complex_pattern =>
    complex_list__
    ,p_use_special_chars =>
    false)))
    then
    rc__ := 2;
    else
    null;
    null;
    f(p=>:p);
    if (wpg_docload.is_file_download) then
    rc__ := 1;
    wpg_docload.get_download_file(:doc_info);
    null;
    null;
    null;
    commit;
    else
    rc__ := 0;
    null;
    null;
    null;
    commit;
    owa.get_page(:data__,:ndata__);
    end if;
    end if;
    :rc__ := rc__;
    end;
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 25.53 26.59 4492 20992 60 1
    Fetch 0 0.00 0.00 0 0 0 0
    total 1 25.53 26.59 4492 20992 60 1

  • SQL apply is very slow on Logical Standby..!!

    Hello all,
    We are having Data Guard setup in our environment where we are having Primary, Physical Standby as well as logical standby databases..
    DB Version : 10.2.0.1 in all databases (Pri, Phy and Logical)
    OS : RHEL4
    Only Oracle is running on this Box..
    Since last month we are facing problems in Logical Standby database where it seems SQL apply has become very slow..
    Archive log files are successfully transferring from Primary but since SQL apply has become slow logical standby is lagging behind primary by two days..
    How do i speed up this SQL apply..?? Any ideas and suggestions are most welcome..
    I checked TOP command to find out which oracle processes are consuming maximum CPU and i have found ora_p000_oracle, ora_p001_oracle, ora_p002_oracle, ora_p003_oracle, ora_p004_oracle, ora_p005_oracle, etc processes are consuming highest CPU and Load Average has always been above 1..
    Any help would be greatly appreciated..
    Thanks - HP

    Hello;
    These Oracle notes might help :
    Slow Performance In Logical Standby Database Due To Lots Of Activity On Sys.Aud$ [ID 862173.1]
    Oracle10g Data Guard SQL Apply Troubleshooting [ID 312434.1]
    Developer and DBA Tips to Optimize SQL Apply [ID 603361.1]
    Best Regards
    mseberg

  • SQL Developer is very slow...

    I'm having performance issues with Oracle SQL Developer. I tried both and 1.5.4 and 2.1.0 (installed in Windows XP Professional) and both work very slow. When I connect to the same database in Apex or just the webconsole, performance is OK, so I think it's SQL Developer that's slow, not the database.
    The problem is that the "Connected To Database..." screen with the "knightrider-bar" appears for some seconds for almost every action I want to perform (retrieving all views, showing constraints, triggers, etc...). Always the waiting screen appears for 3 - 5 seconds, which is very annoying.
    Anybody knows what could be the problem? Working through the SQL Console in APEX is much more performant at this moment, but SQL Developer is more handy (if it would work faster).

    thefurryone wrote:
    Tom,
    As well as the ide/bin folder, there is a sqldeveloper/bin folder, which has a sqldeveloper.exe as well as the one in the root folder.
    Just as another thought - where is SQL Developer installed? Is it local on your PC or on a network drive? Especially when using the version with the included JDK, running off a network drive can be much slower.
    theFurryOneOK, found it now. I opened SQLDeveloper there and the console didn't show any messages. When I connect to the database I got this message in the console:
    Finished parsing = 15+
    UsersCache.fillIn() time = 0  ret==null?: true+
    I don't run SQLDeveloper from a network drive, it's installed locally on my C:\ drive. The database however is on a server, but I have a gigabit connection to it and applications don't have performance issues. So I suppose it's actually SQLDeveloper that's slow. Are there any tools in SQLDeveloper that could cause the bad performance, and that I could switch off?

  • SQL loader load data very slow...

    Hi,
    On my production server have issue of insert. Regular SQL loder load file, it take more time for insert the data in database.
    First 2 and 3 hours one file take 8 to 10 seconds after that it take 5 minutes.
    As per my understanding OS I/O is very slow, First 3 hours DB buffer is free and insert data in buffer normal.
    But when buffer is fill then going for buffer waits and then insert is slow on. If it rite please tell me how to increase I/O.
    Some analysis share here of My server...................
    [root@myserver ~]# iostat
    Linux 2.6.18-194.el5 (myserver) 06/01/2012
    avg-cpu: %user %nice %system %iowait %steal %idle
    3.34 0.00 0.83 6.66 0.00 89.17
    Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
    sda 107.56 2544.64 3140.34 8084953177 9977627424
    sda1 0.00 0.65 0.00 2074066 16
    sda2 21.57 220.59 1833.98 700856482 5827014296
    sda3 0.00 0.00 0.00 12787 5960
    sda4 0.00 0.00 0.00 8 0
    sda5 0.69 2.75 15.07 8739194 47874000
    sda6 0.05 0.00 0.55 5322 1736264
    sda7 0.00 0.00 0.00 2915 16
    sda8 0.50 9.03 5.24 28695700 16642584
    sda9 0.51 0.36 24.81 1128290 78829224
    sda10 0.52 0.00 5.98 9965 19004088
    sda11 83.71 2311.26 1254.71 7343426336 3986520976
    [root@myserver ~]# hdparm -tT /dev/sda11
    /dev/sda11:
    Timing cached reads: 10708 MB in 2.00 seconds = 5359.23 MB/sec
    Timing buffered disk reads: 540 MB in 3.00 seconds = 179.89 MB/sec
    [root@myserver ~]# sar -u -o datafile 1 6
    Linux 2.6.18-194.el5 (mca-webreporting2) 06/01/2012
    09:57:19 AM CPU %user %nice %system %iowait %steal %idle
    09:57:20 AM all 6.97 0.00 1.87 16.31 0.00 74.84
    09:57:21 AM all 6.74 0.00 1.25 17.48 0.00 74.53
    09:57:22 AM all 7.01 0.00 1.75 16.27 0.00 74.97
    09:57:23 AM all 6.75 0.00 1.12 13.88 0.00 78.25
    09:57:24 AM all 6.98 0.00 1.37 16.83 0.00 74.81
    09:57:25 AM all 6.49 0.00 1.25 14.61 0.00 77.65
    Average: all 6.82 0.00 1.44 15.90 0.00 75.84
    [root@myserver ~]# sar -u -o datafile 1 6
    Linux 2.6.18-194.el5 (mca-webreporting2) 06/01/2012
    09:57:19 AM CPU %user %nice %system %iowait %steal %idle
    mca-webreporting2;601;2012-05-27 16:30:01 UTC;2.54;1510.94;3581.85;0.00
    mca-webreporting2;600;2012-05-27 16:40:01 UTC;2.45;1442.78;3883.47;0.04
    mca-webreporting2;599;2012-05-27 16:50:01 UTC;2.44;1466.72;3893.10;0.04
    mca-webreporting2;600;2012-05-27 17:00:01 UTC;2.30;1394.43;3546.26;0.00
    mca-webreporting2;600;2012-05-27 17:10:01 UTC;3.15;1529.72;3978.27;0.04
    mca-webreporting2;601;2012-05-27 17:20:01 UTC;9.83;1268.76;3823.63;0.04
    mca-webreporting2;600;2012-05-27 17:30:01 UTC;32.71;1277.93;3495.32;0.00
    mca-webreporting2;600;2012-05-27 17:40:01 UTC;1.96;1213.10;3845.75;0.04
    mca-webreporting2;600;2012-05-27 17:50:01 UTC;1.89;1247.98;3834.94;0.04
    mca-webreporting2;600;2012-05-27 18:00:01 UTC;2.24;1184.72;3486.10;0.00
    mca-webreporting2;600;2012-05-27 18:10:01 UTC;18.68;1320.73;4088.14;0.18
    mca-webreporting2;600;2012-05-27 18:20:01 UTC;1.82;1137.28;3784.99;0.04
    [root@myserver ~]# vmstat
    procs -----------memory---------- -swap -----io---- system -----cpu------
    r b swpd free buff cache si so bi bo in cs us sy id wa st
    0 1 182356 499444 135348 13801492 0 0 3488 247 0 0 5 2 89 4 0
    [root@myserver ~]# dstat -D sda
    ----total-cpu-usage---- dsk/sda -net/total- -paging -system
    usr sys idl wai hiq siq| read writ| recv send| in out | int csw
    3 1 89 7 0 0|1240k 1544k| 0 0 | 1.9B 1B|2905 6646
    8 1 77 14 0 1|4096B 3616k| 433k 2828B| 0 0 |3347 16k
    10 2 77 12 0 0| 0 1520k| 466k 1332B| 0 0 |3064 15k
    8 2 77 12 0 0| 0 2060k| 395k 1458B| 0 0 |3093 14k
    8 1 78 12 0 0| 0 1688k| 428k 1460B| 0 0 |3260 15k
    8 1 78 12 0 0| 0 1712k| 461k 1822B| 0 0 |3390 15k
    7 1 78 13 0 0|4096B 6372k| 449k 1950B| 0 0 |3322 15k
    AWR sheet output
    Wait Events
    ordered by wait time desc, waits desc (idle events last)
    Event Waits %Time -outs Total Wait Time (s) Avg wait (ms) Waits /txn
    free buffer waits 1,591,125 99.95 19,814 12 129.53
    log file parallel write 31,668 0.00 1,413 45 2.58
    buffer busy waits 846 77.07 653 772 0.07
    control file parallel write 10,166 0.00 636 63 0.83
    log file sync 11,301 0.00 565 50 0.92
    write complete waits 218 94.95 208 955 0.02
    SQL> select 'free in buffer (NOT_DIRTY)',round((( select count(DIRTY) N_D from v$bh where DIRTY='N')*100)/(select count(*) from v$bh),2)||'%' DIRTY_PERCENT from dual
    union
    2 3 select 'keep in buffer (YES_DIRTY)',round((( select count(DIRTY) N_D from v$bh where DIRTY='Y')*100)/(select count(*) from v$bh),2)||'%' DIRTY_PERCENT from dual;
    'FREEINBUFFER(NOT_DIRTY)' DIRTY_PERCENT
    free in buffer (NOT_DIRTY) 10.71%
    keep in buffer (YES_DIRTY) 89.29%
    Rag....

    1)
    Yah This is partition table and on it Local partition index.
    SQL> desc GR_CORE_LOGGING
    Name Null? Type
    APPLICATIONID VARCHAR2(20)
    SERVICEID VARCHAR2(25)
    ENTERPRISENAME VARCHAR2(25)
    MSISDN VARCHAR2(15)
    STATE VARCHAR2(15)
    FROMTIME VARCHAR2(25)
    TOTIME VARCHAR2(25)
    CAMP_ID VARCHAR2(50)
    TRANSID VARCHAR2(25)
    MSI_INDEX NUMBER
    SQL> select index_name,column_name from user_ind_columns where table_name='GR_CORE_LOGGING';
    INDEX_NAME
    COLUMN_NAME
    GR_CORE_LOGGING_IND
    MSISDN
    2) I was try direct but after that i was drop this table and again create new partition table and create fresh index. but still same issue.

  • SQL 2012 DBCC CHECKDB Run Very Slow

    Does anyone experience this? SQL 2012 DBCC CHECKDB runs very slow on one of the server. I monitored the server and it seems DBCC CHECKDB does not hit the disk hard enough.
    It can read 100 mb per second on of my slower server, but on this particular server, it only read 1 mb per second. I saw parallel processes, but it just not read disk hard enough. I am curious what causes this? There is no user using the server when I run
    DBCC command. The full database restore took 3 hours, but DBCC CHECKDB took more than 11 hours.  Thanks for any input.
    Lijun

    Hi,
    Have you made the change of 'cost threshold for parallelism'? The default value of this is 5. Increasing the cost threshold for parallelism would cause most of the queries including CHECKDB to not execute parallel and hence will tend to
    take time to complete. This could be one of the issue contributing to the CHECKDB slow run.
    Also, please check if the antivirus is checking SQL Database files:
    http://support.microsoft.com/kb/309422
    Here is a good article on CHECKDB time taken to complete.
    http://blogs.msdn.com/b/sqlserverstorageengine/archive/2007/01/24/how-long-will-checkdb-take-to-run.aspx
    Thanks.
    Tracy Cai
    TechNet Community Support

  • SQL server is Running Very Slow

    hi,
    I used this following query for finding out how many connection are connected, it is showing that 70 connections,my ram is 16GB,  but still my sql server is running very slow. how can i increase my sql server speed. or how can i analyses that.I checked 
    even when no job was running, but still same speed. I'm using store procedures, SQL jobs no inline queries.
    SELECT
    DB_NAME(dbid) as DBName,
    COUNT(dbid) as NumberOfConnections,
    loginame as LoginName
    FROM
    sys.sysprocesses
    WHERE
    dbid > 0
    GROUP BY
    dbid, loginame

    hi,
    I used this following query for finding out how many connection are connected, it is showing that 30 connections,my ram is 16GB,  but still my sql server is running very slow. how can i increase my sql server speed. or how can i analyses that.I checked 
    even when no job was running, but still same speed.
    SELECT
    DB_NAME(dbid) as DBName,
    COUNT(dbid) as NumberOfConnections,
    loginame as LoginName
    FROM
    sys.sysprocesses
    WHERE
    dbid > 0
    GROUP BY
    dbid, loginame

  • Zimbra login is very slow - SQL query takes 35+ seconds

    Hi,
    my Zimbra login process remains very slow, 35-40 seconds with only a single user using it. I have Beehive set up as directory synchronized, with about 6500 users in it. However, I and a couple of colleagues the only ones making any use of it for testing. With just one person logging in, the following SQL query takes about 35 seconds to execute:
    SELECT /*+ LEADING(rf rf_pp) USE_NL(rf_pp) INDEX_ASC(@rf_connect_by rf@rf_connect_by (ws_real_folders.parent_eid ws_real_folders.eid)) */ RF.ENTERPRISE_ID AS
    ENTERPRISE_ID, RF.SITE_ID AS SITE_ID, RF.ENTITY_TYPE AS ENTITY_TYPE, RF.EID AS EID, RF.LOCK_ID AS LOCK_ID, RF.CACHE_ID AS CACHE_ID, RF.CACHE_TS AS
    CACHE_TS, RF.CACHE_SQ AS CACHE_SQ, FLOOR(RF.SECURE_CHECK/10) AS ACCESS_TYPES, RF.PARENT_ENTITY_TYPE AS PARENT_ENTITY_TYPE, RF.PARENT_EID AS
    PARENT_EID, RF.NAME AS NAME, RF.OWNER_ENTITY_TYPE AS OWNER_ENTITY_TYPE, RF.OWNER_EID AS OWNER_EID, RF.CREATED_ON AS CREATED_ON,
    RF.CREATOR_ENTITY_TYPE AS CREATOR_ENTITY_TYPE, RF.CREATOR_EID AS CREATOR_EID, RF.MODIFIEDON AS MODIFIED_ON, RF.MODIFIED_BY_ENTITY_TYPE AS
    MODIFIED_BY_ENTITY_TYPE, RF.MODIFIED_BY_EID AS MODIFIED_BY_EID, RF.VISIBILITY AS VISIBILITY, CASE WHEN (BITAND(:B13 , :B12 ) = :B12 ) THEN CAST(MULTISET(
    SELECT METADATA_CEN
    FROM OCS_ENTITY_METADATA_CENS_2_V META
    WHERE META.ENTITY_EID = RF.EID ) AS OCS_COLLAB_ID_TBL_T) ELSE CAST(NULL AS OCS_COLLAB_ID_TBL_T) END AS METADATA_CENS, CASE WHEN
    RF_PP.LAST_ACCESSED IS NULL THEN 'N' WHEN RF.MODIFIEDON > RF_PP.LAST_ACCESSED THEN 'U' ELSE NVL(RF_PP.RELATIVE_STATUS, 'N') END AS CHANGE_STATUS,
    RF.PROPERTIES AS PROPERTIES_CLOB, RF_PP.PROPERTIES AS VIEWERPROPERTIES_CLOB, RF.DESCRIPTION AS DESCRIPTION
    FROM (
    SELECT /*+ QB_NAME(rf_connect_by) no_connect_by_cost_based */ RF.ENTERPRISE_ID ENTERPRISE_ID, :B4 SITE_ID, :B3 ENTITY_TYPE, RF.EID EID, RF.LOCK_ID LOCK_ID,
    RF.ORA_ROWSCN CACHE_ID, RF.CACHE_TS CACHE_TS, RF.CACHE_SQ CACHE_SQ, RF.PARENT_TYPE PARENT_ENTITY_TYPE, RF.PARENT_EID PARENT_EID, RF.NAME
    NAME, RF.OWNER_TYPE OWNER_ENTITY_TYPE, RF.OWNER_EID OWNER_EID, RF.CREATED_ON CREATED_ON, RF.CREATOR_TYPE CREATOR_ENTITY_TYPE,
    RF.CREATOR_EID CREATOR_EID, RF.MODIFIED_ON MODIFIEDON, RF.MODIFIED_BY_TYPE MODIFIED_BY_ENTITY_TYPE, RF.MODIFIED_BY_EID MODIFIED_BY_EID,
    RF.VISIBILITY VISIBILITY, RF.PROPERTIES PROPERTIES, RF.DESCRIPTION DESCRIPTION, RF.IS_HIDDEN IS_HIDDEN, LEVEL LEVEL_NUM, COALESCE (
    (SELECT :B10 * 10 + 1
    FROM AC_ENTITIES AEI
    WHERE RF.EID = AEI.EID AND ( 1 = DECODE(AEI.SENSITIVITY_EID, :B9 , 1, 0) AND 1 = DECODE(AEI.OWNER_EID, :B8 , 1, 0) AND 1 = DECODE(AEI.AT_READ, :B7 , 1, 0) AND 1 =
    DECODE(AEI.AT_DISCOVER, :B6 , 1, 0) AND 1 = DECODE(AEI.LOCAL_ACL_ID, :B5 , 1, 0) ) ) ,
    (SELECT ACV.ACCESS_TYPES * 10 + ACV.IS_ALLOWED
    FROM AC_CHECK_ONE_OF_V ACV
    WHERE ACV.EID = RF.EID ) ) SECURE_CHECK
    FROM WS_REAL_FOLDERS RF
    WHERE RF.IS_HIDDEN = :B2 START WITH RF.PARENT_EID = :B1 CONNECT BY PRIOR RF.EID = RF.PARENT_EID ) RF, WS_RF_PRVT_PROPERTIES RF_PP
    WHERE RF.EID = RF_PP.EID (+) AND :B11 = RF_PP.VIEWER_EID (+) AND 1 = BITAND(RF.SECURE_CHECK, 1) ORDER BY RF.LEVEL_NUMIt has ID atrvjdrmz2v6d in Enterprise Manager, and I've tried tuning it with the SQL tuning advisor in EM. I did the statistics gathering mentioned in another thread yesterday, to see if that helped - doesn't seem liked it. I'm running Database 11.1.0.6 and Beehive 1.5.1 in the build from the day it released.
    Any hints? I'll post this to MetaLink as well, unless someone has some immediate idea what's wrong :-)

    No speedup, the 35-40 seconds is for normal logins - and it's very consistent, at least if the database is otherwise idle. Immediately logging out and back in gives me the same wait, and the same query shows up in the Enterprise Manager interface.
    It seems it might be related to Workspaces - from EM:
    "PL/SQL Source (Line Number)          BEE_CODE.WS_REAL_FOLDER_PKG (2998)"

  • SQL Developer in CITRX environment get very slow

    All,
    running version 3.0.02 BuildMAIN-02.37 of SQL Developer on a CITRIX machine.
    We installed that software a while ago and it got very slow. When I ran an SQL statement it took seconds to get the cursor back.
    When I deleted the profile on CITRIX for my user it went back to normal.
    Did anyone experience the same?
    Any remedy?
    Please let me know if you need more details.
    Thank you,
    André

    ok - I see three options:
    1. submit an enhancement request to add such a filter
    2. don't use sql dev for the 'diff' project - do it manually
    3. use a workaround process
    For options #2 or #3 you need to repost a related, but similar, question in the database general forum.
    General Database Discussions
    This would be my recommendation:
    1. Use EXPDP to export the metadata only for the databases you want to work with
    2. Use IMPDP to import that metadata on a server/DB dedicated to your DIFF needs
    3. Use a simple script/procedure to drop users that have no objects (easier than trying customize the import)
    4. Use Sql Dev on the resulting DIFF server/DB
    You can easily export only the metadata. Then just import it somwhere where you can drop what you don't need. Sql Dev can then handle the rest for you.
    Sure - it requires a second DB or two but those will be TINY since you won't have ANY data at all; just the code.
    It also gives you a great sandbox to test any scriptss you might want to execute to make two schemas equal.
    I won't follow up at all on the above in this forum. If you want more help with a workaround repost an appropriate question and provide a link to this thread in it.
    I suggest
    With the requisite licensing you can use Oracle's DBMS_METADATA_DIFF package to do your own comparisons.
    http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_metadiff.htm#CHEGJBCA

  • Sql is running very slow

    hello everyone
    here is my procedure
    in procedure select statement is running very slow it takes 20min
    DECLARE
    y10_pad_sd_1 number;
    y10_sad_sd_1 number;
    y10_sad_oe_1 number;
    y10_she18_avg_1 number;
    y10_she_avg_1 number;
    y10_o_pad_sd_1 number;
    y10_e_pad_sd_1 number;
    y10_o_sad_sd_1 number;
    y10_e_sad_sd_1 number;
    y15_pad_sd_1 number;
    y15_sad_sd_1 number;
    y15_sad_oe_1 number;
    y15_she18_avg_1 number;
    y15_she_avg_1 number;
    y15_o_pad_sd_1 number;
    y15_e_pad_sd_1 number;
    y15_o_sad_sd_1 number;
    y15_e_sad_sd_1 number;
    y20_pad_sd_1 number;
    y20_sad_sd_1 number;
    y20_sad_oe_1 number;
    y20_she18_avg_1 number;
    y20_she_avg_1 number;
    y20_o_pad_sd_1 number;
    y20_e_pad_sd_1 number;
    y20_o_sad_sd_1 number;
    y20_e_sad_sd_1 number;
    CURSOR c_pn IS
    SELECT
    pn_id pn_id
    ,pn_dm pn_dm
    ,arch_id arch_id
    ,o_ink o_ink
    ,o_color o_color
    ,e_ink e_ink
    ,e_color e_color
    FROM pn_list_iqp_95cl;
    type c7 is table of c_pn%rowtype;
    c8 c7;
    BEGIN
    open c_pn;
    fetch c_pn bulk collect into c8;
    close c_pn;
    for i in 1..c8.last loop
    SELECT /*+ use_hash(pmo pme) */
    LEAST(MAX ( pmo.y10_pad_sd ), MAX ( pme.y10_pad_sd ))
    ,LEAST(MAX ( pmo.y10_sad_sd ), MAX ( pme.y10_sad_sd ))
    ,LEAST(MAX ( pmo.y10_sad_oe ), MAX ( pme.y10_sad_oe ))
    ,LEAST(MAX ( pmo.y10_she18_avg), MAX ( pme.y10_she18_avg ))
    ,LEAST(MAX ( pmo.y10_she_avg ), MAX ( pme.y10_she_avg ))
    ,LEAST(MAX ( pmo.y10_o_pad_sd ), MAX ( pme.y10_o_pad_sd ))
    ,LEAST(MAX ( pmo.y10_e_pad_sd ), MAX ( pme.y10_e_pad_sd ))
    ,LEAST(MAX ( pmo.y10_o_sad_sd ), MAX ( pme.y10_o_sad_sd ))
    ,LEAST(MAX ( pmo.y10_e_sad_sd ), MAX ( pme.y10_e_sad_sd ))
    ,LEAST(MAX ( pmo.y15_pad_sd ), MAX ( pme.y15_pad_sd ))
    ,LEAST(MAX ( pmo.y15_sad_sd ), MAX ( pme.y15_sad_sd ))
    ,LEAST(MAX ( pmo.y15_sad_oe ), MAX ( pme.y15_sad_oe ))
    ,LEAST(MAX ( pmo.y15_she18_avg), MAX ( pme.y15_she18_avg ))
    ,LEAST(MAX ( pmo.y15_she_avg ), MAX ( pme.y15_she_avg ))
    ,LEAST(MAX ( pmo.y15_o_pad_sd ), MAX ( pme.y15_o_pad_sd ))
    ,LEAST(MAX ( pmo.y15_e_pad_sd ), MAX ( pme.y15_e_pad_sd ))
    ,LEAST(MAX ( pmo.y15_o_sad_sd ), MAX ( pme.y15_o_sad_sd ))
    ,LEAST(MAX ( pmo.y15_e_sad_sd ), MAX ( pme.y15_e_sad_sd ))
    ,LEAST(MAX ( pmo.y20_pad_sd ), MAX ( pme.y20_pad_sd ))
    ,LEAST(MAX ( pmo.y20_sad_sd ), MAX ( pme.y20_sad_sd ))
    ,LEAST(MAX ( pmo.y20_sad_oe ), MAX ( pme.y20_sad_oe ))
    ,LEAST(MAX ( pmo.y20_she18_avg), MAX ( pme.y20_she18_avg ))
    ,LEAST(MAX ( pmo.y20_she_avg ), MAX ( pme.y20_she_avg ))
    ,LEAST(MAX ( pmo.y20_o_pad_sd ), MAX ( pme.y20_o_pad_sd ))
    ,LEAST(MAX ( pmo.y20_e_pad_sd ), MAX ( pme.y20_e_pad_sd ))
    ,LEAST(MAX ( pmo.y20_o_sad_sd ), MAX ( pme.y20_o_sad_sd ))
    ,LEAST(MAX ( pmo.y20_e_sad_sd ), MAX ( pme.y20_e_sad_sd ))
    INTO
    y10_pad_sd_1
    ,y10_sad_sd_1
    ,y10_sad_oe_1
    ,y10_she18_avg_1
    ,y10_she_avg_1
    ,y10_o_pad_sd_1
    ,y10_e_pad_sd_1
    ,y10_o_sad_sd_1
    ,y10_e_sad_sd_1
    ,y15_pad_sd_1
    ,y15_sad_sd_1
    ,y15_sad_oe_1
    ,y15_she18_avg_1
    ,y15_she_avg_1
    ,y15_o_pad_sd_1
    ,y15_e_pad_sd_1
    ,y15_o_sad_sd_1
    ,y15_e_sad_sd_1
    ,y20_pad_sd_1
    ,y20_sad_sd_1
    ,y20_sad_oe_1
    ,y20_she18_avg_1
    ,y20_she_avg_1
    ,y20_o_pad_sd_1
    ,y20_e_pad_sd_1
    ,y20_o_sad_sd_1
    ,y20_e_sad_sd_1
    FROM pm_list_iqp_95cl pmo ,pm_list_iqp_95cl pme
    WHERE pmo.pn_id = pme.pn_id
    AND pme.pn_id = c8(i).pn_id
    AND pmo.slot_cd = 'O'
    AND pme.slot_cd = 'E';
    END LOOP;
    END;

    EXPLAIN PLAN FOR THIS QUERY
    cached plan :cost all rows(cost:4)
    step name step cost rows
    select statement 6 4
    sort(aggregate) 5 1
    merge join(cartesian) 4 4 1
    tellatel.pm_list_iqp_95cl table access(full) 1 2 1
    buffer(sort) 3 2 1
    tellatel.pm_list_iqp_95cl_table access(full) 2 2 1

  • SQL query from C++ application using ODBC 10.2.0.4 is very slow

    Hi,
    We are using ODBC oracle driver to access 10g Oracle server from C++ apllication. But the performace is very slow.
    Recently we tried with Microsoft Oracle ODBC driver, which we found faster than 10.2.0.4 Oracle ODBC driver.
    Please let me know is anything is ther any issue with this driver or is it better to use Microsoft ODBC driver.
    Thanks,
    Sabbi

    Hi StephenEP,
    As the issue is more related to C++ programming, I would like to recommend you post the question in the Visual C++ forum at
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral  . It is appropriate and more experts will assist you.
    Thanks,
    Lydia Zhang

  • Clob datatype- very slow while appending

    Hi,
    please help on below pl/sql block.
    I have written below code, but the response time is very slow.
    the table - aux_comm_3_to_1 has more than 1 Lakh records.
    and I have append all the record and send the record as clob OUT parameter to GUI.
    Pls suggest me.
    declare
    TEMP_XML clob;
    XML_OW clob;
    begin
    FOR rec IN (SELECT
    FRAMEREFERENCEDATE,
    EU_LEU_ID_OWNER,
    EU_LEU_ID_SUBSIDIARY,
    DIRECT_PERCENT,
    QUALITY_IND_DIRECT_PERCENT,
    SOURCE_DIRECT_PERCENT,
    REF_DATE_DIRECT_PERCENT,
    KIND_OF_CONTROL,
    SOURCE_KIND_OF_CONTROL,
    REF_DATE_KIND_OF_CONTROL,
    DATE_OF_COMMENCEMENT,
    SOURCE_DATE_OF_COMMENCEMENT,
    REF_DATE_OF_COMMENCEMENT,
    DATE_OF_CESSATION,
    SOURCE_DATE_OF_CESSATION,
    REF_DATE_OF_CESSATION,
    SOURCE_TA_OWNERSHIP,
    REF_DATE_TA_OWNERSHIP
    FROM aux_comm_3_to_1 )
    LOOP
    TEMP_XML :=
    '<TARGET_OWNERSHIP="'
    || idcounter
    ||'"FRAMEREFERENCEDATE="'||rec.FRAMEREFERENCEDATE
    ||'"EU_LEU_ID_OWNER="'||rec.EU_LEU_ID_OWNER
    ||'"EU_LEU_ID_SUBSIDIARY="'||rec.EU_LEU_ID_SUBSIDIARY
    ||'"DIRECT_PERCENT="'||rec.DIRECT_PERCENT
    ||'"QUALITY_IND_DIRECT_PERCENT="'||rec.QUALITY_IND_DIRECT_PERCENT
    ||'"SOURCE_DIRECT_PERCENT="'||rec.SOURCE_DIRECT_PERCENT
    ||'"REF_DATE_DIRECT_PERCENT="'||rec.REF_DATE_DIRECT_PERCENT
    ||'"KIND_OF_CONTROL="'||rec.KIND_OF_CONTROL
    ||'"SOURCE_KIND_OF_CONTROL="'||rec.SOURCE_KIND_OF_CONTROL
    ||'"REF_DATE_KIND_OF_CONTROL="'||rec.REF_DATE_KIND_OF_CONTROL
    ||'"DATE_OF_COMMENCEMENT="'||rec.DATE_OF_COMMENCEMENT
    ||'"SOURCE_DATE_OF_COMMENCEMENT="'||rec.SOURCE_DATE_OF_COMMENCEMENT
    ||'"REF_DATE_OF_COMMENCEMENT="'||rec.REF_DATE_OF_COMMENCEMENT
    ||'"DATE_OF_CESSATION="'||rec.DATE_OF_CESSATION
    ||'"SOURCE_DATE_OF_CESSATION="'||rec.SOURCE_DATE_OF_CESSATION
    ||'"REF_DATE_OF_CESSATION="'||rec.REF_DATE_OF_CESSATION
    ||'"SOURCE_TA_OWNERSHIP="'||rec.SOURCE_TA_OWNERSHIP
    ||'"REF_DATE_TA_OWNERSHIP="'||rec.REF_DATE_TA_OWNERSHIP
    || '"/>'
    || CHR (10);
    XML_OW:=XML_OW||CHR(10)||TEMP_XML;
    idcounter := idcounter + 1;
    END LOOP;
    end;
    ----------------------

    Can you extend the test also with dbms_lob.writeappend? I am not on the same machine so so I am repeating all tests again (slightly modified):
    SQL> set timing on
    SQL> declare
       s   clob;
    begin
       s := dbms_random.string ('X', 10000);
       for j in 1 .. 100 * 100 * 10
       loop
          s := s || 'x';
       end loop;
       dbms_output.put_line ('Length: ' || length (s));     
    end;
    Length: 104000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:20.49
    SQL> declare
       s   clob;
    begin
       s := dbms_random.string ('X', 10000);
       for j in 1 .. 100 * 100 * 10
       loop
          dbms_lob.append (s, 'x');
       end loop;
       dbms_output.put_line ('Length: ' || length (s));
    end;
    Length: 104000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:25.49
    SQL> declare
       s        clob;
    begin
       dbms_lob.createtemporary (s, true);
       s := dbms_random.string ('X', 10000);
       for j in 1 .. 100 * 100 * 10
       loop
           dbms_lob.writeappend (s, 1, 'x');
       end loop;
       dbms_output.put_line ('Length: ' || length (s));
       dbms_lob.freetemporary (s);     
    end;
    Length: 104000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:20.32So not much of a difference between first and third run ...

Maybe you are looking for

  • Help needed with itunes

    help needed with itunes please tryed to move my itunes libary to my external hard drive itunes move ok and runs fin but i have none of my music or apps or anything all my stuff is in the itunes folder on my external hard drive but there is nothing on

  • Custom Report Layout in APEX 3.0 PDF

    How much freedom do we have when developing a custom report layout using BI Publisher when we create the template file using the Word XML add-on? Why I am asking is, I am trying to replicate several Crystal based reports that use multiple lines of fo

  • How to activate  INACTIVE produtcs in EBS

    I installed R12 and upgraded it to 12.1.3, After running adutconf.sql ..I found many produtcs as INACTIVE like PO etc. Pls. suggest how to make them active.

  • ATI 3870 Install on MacPro 2.66 Question

    Is there anywhere I can find an online manual to download? I've been to ATI's WWW site and had a hard time finding any manual for download. I've got to figure out how to plug in the power cable and I sure would like a diagram or picture. Anyone out t

  • Hello My account is locked Please help me Thank you

    Hello My account is locked Please help me Thank you