Slow running query --General question

This is just a scenario that you may have come across too. For example there is a query (tables and views) that returned data very quickly until yesterday but slowed down today and takes forever. What do you make out of it and why did it run fine until yesterday?
What would you first look at to resolve this?
This only a general scenario. I understand there could be a lot of factors like data loads but i want to know the best approach. Thanks in advance for your answer. 
svk

First thing I would see is the amount of data. How much of data was I querying yesterday, how much of data am I querying today? Is it a possible situation to have a slow query(just by some minutes but not hours and so on)..
Then, I will look at the query execution plan and try to avoid any table scan's or seeks by creating any possible valid indexes over the tables being joined.
Use necessary tables only in the query, remove any unnecessary LEFT join's and use them only if needed..
Remove ORDER BY in the queries. Not using NOT IN or UNION or DISTINCT such kind of operations if permitted.
Avoid any sort of Bookmark lookups..
These are the primary things I would consider to look at when any query is slow, at first...
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

Similar Messages

  • Problem trying to diagnose slow running query

    Hi, Group.
    I have two versions of the same query. sql1 contains an inner select, sql2 contains the hard-coded values that the inner select returns. Other than that the queries look the exact same.
    sql1 takes over 8 minutes to complete.
    sql2 takes about 250ms to complete.
    I tried running explain plan on both queries and sql1 appears to be the better query based on the plan_table cost columns. I even ran a query that shows the plan hash value for the currently running query. Both times, the slower query appears to be quicker.
    So my problem is that all the diagnosis indicates that sql1 is faster than sql2 but in reality, sql2 is waaaaaaaaaaaaaaaaaaaaay faster than sql1. Does anyone have any other suggestions for tools that I can use that show why the supposedly fast query is actually the slower query?
    Thanks, Max
    EDIT: here is an example of sql1 and sql2 to help you visualize the problem.
    SELECT <column list>
    FROM <table list>
    WHERE column IN (SELECT column FROM table)
    AND <some more predicates>
    SELECT <column list>
    FROM <table list>
    WHERE column IN (value1, value2, value3)
    AND <some more predicates>

    The slow query is listed first.
    PLAN_TABLE_OUTPUT
    Plan hash value: 2494202055
    | Id  | Operation                          | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                   |                                |     1 |   869 |    10  (20)| 00:00:01 |
    |   1 |  SORT UNIQUE                       |                                |     1 |   869 |     9  (12)| 00:00:01 |
    |   2 |   NESTED LOOPS OUTER               |                                |     1 |   869 |     8   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                    |                                |     1 |   749 |     7   (0)| 00:00:01 |
    |   4 |     NESTED LOOPS                   |                                |     1 |   725 |     6   (0)| 00:00:01 |
    |   5 |      NESTED LOOPS                  |                                |     1 |   701 |     6   (0)| 00:00:01 |
    |   6 |       NESTED LOOPS                 |                                |     1 |   685 |     3   (0)| 00:00:01 |
    |   7 |        NESTED LOOPS                |                                |     1 |   645 |     1   (0)| 00:00:01 |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MASTERDATA_ATTRIBUTE           |     1 |   387 |     1   (0)| 00:00:01 |
    |*  9 |          INDEX RANGE SCAN          | I_MSTRRBT_M_VALUE              |     1 |       |     1   (0)| 00:00:01 |
    |* 10 |         TABLE ACCESS BY INDEX ROWID| MASTERDATA_ELEMENT             |     1 |   258 |     0   (0)| 00:00:01 |
    |* 11 |          INDEX UNIQUE SCAN         | I_MSTRMNT_M_VOCABULARYELEMENTI |     1 |       |     0   (0)| 00:00:01 |
    |  12 |        TABLE ACCESS BY INDEX ROWID | EPCIS_EVENT                    |     1 |    40 |     2   (0)| 00:00:01 |
    |* 13 |         INDEX RANGE SCAN           | I_PCS_VNT_M_BUSINESSLOCATIONUR | 65659 |       |     2   (0)| 00:00:01 |
    |* 14 |       TABLE ACCESS BY INDEX ROWID  | EPCIS_EVENT_EPC                |     2 |    32 |     3   (0)| 00:00:01
    |* 15 |        INDEX RANGE SCAN            | I_PCS__PC_EVENT_ID             |     2 |       |     2   (0)| 00:00:01 |
    |  16 |      TABLE ACCESS BY INDEX ROWID   | EPCIS_EVENT_EPC                |     2 |    48 |     0   (0)| 00:00:01
    |* 17 |       INDEX RANGE SCAN             | I_PCS__PC_EVENT_ID             |     2 |       |     2   (0)| 00:00:01 |
    |* 18 |     TABLE ACCESS BY INDEX ROWID    | EPC                            |     1 |    24 |     1   (0)| 00:00:01 |
    |* 19 |      INDEX UNIQUE SCAN             | SYS_C0012080                   |     1 |       |     0   (0)| 00:00:01 |
    |  20 |    TABLE ACCESS BY INDEX ROWID     | EPC                            |     1 |   120 |     1   (0)| 00:00:01 |
    |* 21 |     INDEX UNIQUE SCAN              | SYS_C0012080                   |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       8 - filter("T4"."MD_ATTRIBUTE_META_ID"='urn:epcglobal:epcis:mda:coun
                                try')
       9 - access("T4"."VALUE"='USA')
      10 - filter("T3"."MD_ELEMENT_META_ID"='urn:epcglobal:epcis:vtype:BusinessLo
                              cation')
      11 - access("T3"."MD_ELEMENT_ID"="T4"."PARENT_MD_ELEMENT_ID")
      13 - access("T0"."BUSINESS_LOCATION_URI"="T3"."MD_ELEMENT_ID")
      14 - filter(("T0"."EVENT_TYPE"='AGGREGATION' OR "T0"."EVENT_TYPE"='TRANSACTION') AND
                  "T1"."PARENT_EVENT_EPC_ID" IS NOT NULL OR "T0"."EVENT_TYPE"='OBJECT')
      15 - access("T0"."EVENT_ID"="T1"."EVENT_ID")
      17 - access("T0"."EVENT_ID"="T5"."EVENT_ID")
      18 - filter("T2"."COMPANY_PREFIX"='1' AND "T2"."REFERENCE"='1' AND "T2"."SCHEME"='gid')
      19 - access("T1"."EPC_ID"="T2"."EPC_ID")
      21 - access("T5"."EPC_ID"="T6"."EPC_ID"(+))
    46 rows selected.
    Explained.
    PLAN_TABLE_OUTPUT
    Plan hash value: 3062511058
    | Id  | Operation                        | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                 |                       |     7 |  1568 |    38   (6)| 00:00:01 |
    |   1 |  SORT UNIQUE                     |                       |     7 |  1568 |    37   (3)| 00:00:01 |
    |   2 |   NESTED LOOPS OUTER             |                       |     7 |  1568 |    36   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                  |                       |     7 |   728 |    29   (0)| 00:00:01 |
    |   4 |     NESTED LOOPS                 |                       |     4 |   320 |    17   (0)| 00:00:01 |
    |   5 |      NESTED LOOPS                |                       |     4 |   160 |    13   (0)| 00:00:01 |
    |*  6 |       TABLE ACCESS BY INDEX ROWID| EPC                   |     1 |    24 |    10   (0)| 00:00:01 |
    |*  7 |        INDEX RANGE SCAN          | I_EPC_M_COMPANYPREFIX |   220 |       |     3   (0)| 00:00:01 |
    |   8 |       TABLE ACCESS BY INDEX ROWID| EPCIS_EVENT_EPC       |     6 |    96 |     3   (0)| 00:00:01
    |*  9 |        INDEX RANGE SCAN          | I_PCS__PC_EPC_ID      |     7 |       |     2   (0)| 00:00:01 |
    |* 10 |      TABLE ACCESS BY INDEX ROWID | EPCIS_EVENT           |     1 |    40 |     1   (0)| 00:00:01 |
    |* 11 |       INDEX UNIQUE SCAN          | SYS_C0012082          |     1 |       |     0   (0)| 00:00:01 |
    |  12 |     TABLE ACCESS BY INDEX ROWID  | EPCIS_EVENT_EPC       |     2 |    48 |     3   (0)| 00:00:01
    |* 13 |      INDEX RANGE SCAN            | I_PCS__PC_EVENT_ID    |     2 |       |     2   (0)| 00:00:01 |
    |  14 |    TABLE ACCESS BY INDEX ROWID   | EPC                   |     1 |   120 |     1   (0)| 00:00:01 |
    |* 15 |     INDEX UNIQUE SCAN            | SYS_C0012080          |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       6 - filter("T2"."REFERENCE"='1' AND "T2"."SCHEME"='gid')
       7 - access("T2"."COMPANY_PREFIX"='1')
       9 - access("T1"."EPC_ID"="T2"."EPC_ID")
      10 - filter(("T0"."BUSINESS_LOCATION_URI"='businesslocation_ADD' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_DELETE' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE1' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE10' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE11' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE12' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE2' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE3' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE4' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE5' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE6' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE7' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE8' OR
                  "T0"."BUSINESS_LOCATION_URI"='businesslocation_OBSERVE9') AND (("T0"."EVENT_TYPE"='AGGREGATIO
                  OR "T0"."EVENT_TYPE"='TRANSACTION') AND "T1"."PARENT_EVENT_EPC_ID" IS NOT NULL OR
                  "T0"."EVENT_TYPE"='OBJECT'))
      11 - access("T0"."EVENT_ID"="T1"."EVENT_ID")
      13 - access("T0"."EVENT_ID"="T5"."EVENT_ID")
      15 - access("T5"."EPC_ID"="T6"."EPC_ID"(+))

  • Slow running query after upgrading to Oracle 10.2.0.4

    Hello
    I had posted a query in Database Upgrade section , but all in vian as i have had no replies . So i am posing this in general section as i can now confirm with the exact query issue .
    1. I upgraded my oracle instance windows 64 bit from 10.2.0.1 to 10.2.0.4
    2. All is good except when i use SUM or MAX in queries i get a very slow performance below is the complete example
    Your help is much appreciated .
    Regards
    Harshad
    =====================================================================================================
    Example.
    =====================================================================================================The query runs on a single table of 275,000,000 records, partitioned by Feed_Id in 53 partitions:-
    SELECT *
    FROM Fact_Life
    WHERE Life_Id = 11555269
    AND Feed_Id = 2;
    This returns 18 rows in sub-second response time.
    Explain Plan for it:-
    SELECT *
    FROM Fact_Life
    WHERE Life_Id = 11555269
    AND Feed_Id = 2;
    Statement Id=3 Type=INDEX
    Cost=938 TimeStamp=11-06-09::11::25:55
    (1) SELECT STATEMENT ALL_ROWS
    Est. Rows: 66 Cost: 940
    (4) PARTITION RANGE SINGLE
    Est. Rows: 66 Cost: 940
    (3) TABLE TABLE ACCESS BY GLOBAL INDEX ROWID RDS.FACT_LIFE [Analyzed]
    Blocks: 2,765,931 Est. Rows: 66 of 275,979,985 Cost: 940
    (2) INDEX INDEX SKIP SCAN RDS.PIX_FTLE_1 [Analyzed]
    Est. Rows: 3 Cost: 938
    However, when the query employs an aggregate function:-
    SELECT MAX(Cap_Period_Id)
    FROM Fact_Life
    WHERE Life_Id = 11555269
    AND Feed_Id = 2;
    This takes anything from 200-400 seconds to return.
    Explain plan for it:-
    SELECT MAX(CAP_Period_Id)
    FROM Fact_Life
    WHERE Life_Id = 11555269
    AND Feed_Id = 2;
    Statement Id=3 Type=PARTITION RANGE
    Cost=7 TimeStamp=11-06-09::11::26:50
    (1) SELECT STATEMENT ALL_ROWS
    Est. Rows: 1 Cost: 7
    (5) SORT AGGREGATE
    Est. Rows: 1
    (4) FIRST ROW
    Est. Rows: 66 Cost: 7
    (3) PARTITION RANGE SINGLE
    Est. Rows: 66 Cost: 7
    (2) INDEX INDEX RANGE SCAN (MIN/MAX) RDS.PIX_FTLE_1 [Analyzed]
    Est. Rows: 66 Cost: 7
    However when the query is run with a different Life_Id for the same partition:-
    SELECT MAX(Cap_Period_Id)
    FROM Fact_Life
    WHERE Life_Id = 11555275
    AND Feed_Id = 2;
    Returns sub-second.
    Explain plan for it:-
    SELECT MAX(CAP_Period_Id)
    FROM Fact_Life
    WHERE Life_Id = 11555275
    AND Feed_Id = 2;
    Statement Id=3 Type=PARTITION RANGE
    Cost=7 TimeStamp=11-06-09::11::29:29
    (1) SELECT STATEMENT ALL_ROWS
    Est. Rows: 1 Cost: 7
    (5) SORT AGGREGATE
    Est. Rows: 1
    (4) FIRST ROW
    Est. Rows: 66 Cost: 7
    (3) PARTITION RANGE SINGLE
    Est. Rows: 66 Cost: 7
    (2) INDEX INDEX RANGE SCAN (MIN/MAX) RDS.PIX_FTLE_1 [Analyzed]
    Est. Rows: 66 Cost: 7
    Is this a problem with b-tree indexes? The Life_Id is allocated from a sequence and there are 67,535,682 rows in the partition. The stats are up to date.
    =====================================================================================================
    =====================================================================================================

    Hello Randolf,
    Sorry for the late reply was down with flue and could not mail , as mentioned i below is the DDL for PIX_FTLE_1 & PIX_FTLE_2 . I have used TOAD to extract the script.
    As i cant send the both the DDL in single post i will send it in 2 post , There is a limit of 30000 characters in sigle post .
    Thanks once again for your help .
    Regards
    Harshad
    CREATE INDEX RDS.PIX_FTLE_1 ON RDS.FACT_LIFE
    (FEED_ID, CAP_PERIOD_ID, LIFE_ID, ISO_CURRENCY_ID, LIFE_SCD_ID)
    TABLESPACE RDS_TABLESPACE01
    INITRANS 2
    MAXTRANS 255
    LOGGING
    GLOBAL PARTITION BY RANGE (FEED_ID) (
    PARTITION HA1 VALUES LESS THAN (2)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 1225M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION NU6 VALUES LESS THAN (3)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 2761M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION FP1 VALUES LESS THAN (4)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 971M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION PRU VALUES LESS THAN (5)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 993M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION GAC VALUES LESS THAN (6)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 622M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION NU3 VALUES LESS THAN (7)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 2136M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION LEG VALUES LESS THAN (8)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 847M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RSC VALUES LESS THAN (9)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 144M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SW1 VALUES LESS THAN (10)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 80M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION PRI VALUES LESS THAN (11)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 34M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION BAL VALUES LESS THAN (12)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 128M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION NA1 VALUES LESS THAN (13)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION MID VALUES LESS THAN (14)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION EGS VALUES LESS THAN (15)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION ARK VALUES LESS THAN (16)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 1088M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SKA VALUES LESS THAN (17)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 136M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION NU1 VALUES LESS THAN (18)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 196M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SK2 VALUES LESS THAN (19)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 9M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION CU1 VALUES LESS THAN (20)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 11M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION DLI VALUES LESS THAN (21)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION AEG VALUES LESS THAN (22)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION COM VALUES LESS THAN (23)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION CU2 VALUES LESS THAN (24)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION CUL VALUES LESS THAN (25)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION EAG VALUES LESS THAN (26)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION FP2 VALUES LESS THAN (27)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION HAG VALUES LESS THAN (28)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION HAL VALUES LESS THAN (29)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION JRA VALUES LESS THAN (30)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION LEL VALUES LESS THAN (31)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION MGA VALUES LESS THAN (32)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION MGM VALUES LESS THAN (33)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION NU2 VALUES LESS THAN (34)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION PEG VALUES LESS THAN (35)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RLM VALUES LESS THAN (36)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RL2 VALUES LESS THAN (37)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RL3 VALUES LESS THAN (38)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RL4 VALUES LESS THAN (39)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RL5 VALUES LESS THAN (40)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION BG4 VALUES LESS THAN (41)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION BG5 VALUES LESS THAN (42)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RS2 VALUES LESS THAN (43)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RS3 VALUES LESS THAN (44)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION RS4 VALUES LESS THAN (45)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SA1 VALUES LESS THAN (46)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SAF VALUES LESS THAN (47)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SCA VALUES LESS THAN (48)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SL1 VALUES LESS THAN (49)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SL2 VALUES LESS THAN (50)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SPI VALUES LESS THAN (51)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION SWP VALUES LESS THAN (52)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION VDL VALUES LESS THAN (53)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 240M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION ZUR VALUES LESS THAN (54)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION AR3 VALUES LESS THAN (55)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 360M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    PARTITION ZZZ VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE RDS_TABLESPACE01
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    NOPARALLEL;

  • Slow running query, plan attached

    Oracle Database 10g Release 10.2.0.1.0
    A particular query is taking a rather long time to run. This was something which used to run rather quick until a couple of days back.
    Indexes seem to be used and nothing else seem to have changed muck. The 5.38 sec cpu time is what i am trying to trace down.
    Does the attached plan show anything that indicates an underlying issue?
    SELECT NVL(SUM(NVL(TCR.EMPLOYEEHOURSWORKED, 0) + NVL(TCR.EMPLOYEEOTHOURSWORKED,0)), 0)
    FROM   TYPE TYP, EQUIPMENT EQ, TIMECARD TC, TIMECARDRESOURCE TCR
    WHERE  TYP.TYPEID =   EQ.TYPEID
    AND    TCR.EQUIPMENTID = EQ.EQUIPMENTID
    AND    EQ.TYPEID = :B2
    AND    TCR.EMPLOYEEID = :B1
    AND    TCR.TIMECARDID = TC.TIMECARDID         
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute    218      0.05       0.04          0          0          0           0
    Fetch      218      5.33       5.23          0    2176948          0         218
    total      438      5.38       5.28          0    2176948          0         218
    Misses in library cache during parse: 1
    Misses in library cache during execute: 2
    Optimizer mode: ALL_ROWS
    Parsing user id: 91     (recursive depth: 1)
    Rows     Row Source Operation     
         68  SORT AGGREGATE (cr=679048 pr=0 pw=0 time=1580234 us)     
         56   TABLE ACCESS BY INDEX ROWID TIMECARDRESOURCE (cr=679048 pr=0 pw=0 time=1479170 us)
    743036    NESTED LOOPS  (cr=9656 pr=0 pw=0 time=1507400 us)      
       2788     TABLE ACCESS BY INDEX ROWID EQUIPMENT (cr=1972 pr=0 pw=0 time=15059 us)
       2788      INDEX RANGE SCAN IDX_EQP_TYPEID (cr=204 pr=0 pw=0 time=6075 us)(object id 193877)
    740180     INDEX RANGE SCAN IDX_TCR_EQPID (cr=7684 pr=0 pw=0 time=848397 us)(object id 193878)
    ********************************************************************************

    997026 wrote:
    Oracle Database 10g Release 10.2.0.1.0
    A particular query is taking a rather long time to run. This was something which used to run rather quick until a couple of days back.
    Indexes seem to be used and nothing else seem to have changed muck. The 5.38 sec cpu time is what i am trying to trace down.
    Does the attached plan show anything that indicates an underlying issue?
    SELECT NVL(SUM(NVL(TCR.EMPLOYEEHOURSWORKED, 0) + NVL(TCR.EMPLOYEEOTHOURSWORKED,0)), 0)
    FROM   TYPE TYP, EQUIPMENT EQ, TIMECARD TC, TIMECARDRESOURCE TCR
    WHERE  TYP.TYPEID =   EQ.TYPEID
    AND    TCR.EQUIPMENTID = EQ.EQUIPMENTID
    AND    EQ.TYPEID = :B2
    AND    TCR.EMPLOYEEID = :B1
    AND    TCR.TIMECARDID = TC.TIMECARDID         
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute    218      0.05       0.04          0          0          0           0
    Fetch      218      5.33       5.23          0    2176948          0         218
    total      438      5.38       5.28          0    2176948          0         218
    Misses in library cache during parse: 1
    Misses in library cache during execute: 2
    Optimizer mode: ALL_ROWS
    Parsing user id: 91     (recursive depth: 1)
    Rows     Row Source Operation     
    68  SORT AGGREGATE (cr=679048 pr=0 pw=0 time=1580234 us)     
    56   TABLE ACCESS BY INDEX ROWID TIMECARDRESOURCE (cr=679048 pr=0 pw=0 time=1479170 us)
    743036    NESTED LOOPS  (cr=9656 pr=0 pw=0 time=1507400 us)      
    2788     TABLE ACCESS BY INDEX ROWID EQUIPMENT (cr=1972 pr=0 pw=0 time=15059 us)
    2788      INDEX RANGE SCAN IDX_EQP_TYPEID (cr=204 pr=0 pw=0 time=6075 us)(object id 193877)
    740180     INDEX RANGE SCAN IDX_TCR_EQPID (cr=7684 pr=0 pw=0 time=848397 us)(object id 193878)
    Notice how smart the optimizer has been - you've written a query with 4 tables in it, but the optimizer has recognised that it can eliminate two of the tables because of the primary key and referential integrity constraints.
    From the remaining two tables, you have a query that looks as if it is inherently NON-SCALABLE. You select all timecardresources for a given employee, and all pieces of equiplment of a given type, and join them on the equipment id.
    I am going to guess that the number of timecardresources for an employee will always grow with time - which means the volume of work you need to do will grow with time; moreover that on some regular basis you add rows to timecardresources, which means the number of random block visits per employeeid will grow with time.
    It's possible that hash join that you've engineered in your current solution was the original path, but the optimizer reached the breakpoint where the cost of random visits by employeeid became too great and the decided to use a nested loop from the equipment. (These things happen). However, the point may come when you current solution is also too expensive and the optimizer may then decide to do a tablescan on the timecradresources table.
    This is a fairly classic type of problem - a (relatively) small result set arising from a join with a single predicate on each of the joined tables.
    If my assumptions are correct, you need to find a way to do one of three things
    a) reduce the cost of finding all the timecardresources for an employee - recreating the table as an IOT (index organized table) may be an appropriate mechanism
    b) restructure you indexes to minimise random visits to tables - eliminating data as early as possible.
    c) re-engineer your indexes and SQL so that you don't do random visits to tables unless you need the rows that you're going to find (Here's a link to my blog which let's you access a video made a couple of years ago of a presentation I did on the topic: https://jonathanlewis.wordpress.com/2011/06/23/video/ )
    A couple of other notes:
    a) Christian Antognini's book is probably the best practical book available at present on Oracle Tuning
    b) The index you've dropped in your solution looks like it might be an index created to protect a foreign key constraint from the "foreign key locking" problem.
    Keep an eye open for enqueue waits of type TM, and TM deadlocks.
    Regards
    Jonathan Lewis

  • Help with slow running query

    Hi,
    I am having some performance problems on OBIEE dashboards so I am trying to figure out what is going wrong by looking at the query being generated.
    I have spent time simplifying the query down to a very basic select statement, and trying to see why it still takes about ~5 seconds to run. See the following explain plan:
    SQL> explain plan for
      2  select count(distinct CASES_FACT.CASE_KEY) as CASE_COUNT
      3    from
      4         COMPSTAT_CASES_DIM CASES_DIM /* Dim - COMPSTAT_CASES_DIM */ ,
      5         COMPSTAT_CASES_FACT CASES_FACT /* Fact - COMPSTAT_CASES_FACT */
      6   where (    CASES_FACT.CASE_KEY = CASES_DIM.CASE_KEY  );
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 372393383
    | Id  | Operation              | Name            | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT       |                 |     1 |    12 |       |  2741   (3)| 00:00:33 |
    |   1 |  SORT GROUP BY         |                 |     1 |    12 |       |            |          |
    |*  2 |   HASH JOIN            |                 |   925K|    10M|    15M|  2741   (3)| 00:00:33 |
    |   3 |    INDEX FAST FULL SCAN| CASE_KEY        |   909K|  5327K|       |   674   (3)| 00:00:09 |
    |   4 |    INDEX FAST FULL SCAN| CASES_FACT_IDX4 |   925K|  5421K|       |   466   (4)| 00:00:06 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - access("CASES_FACT"."CASE_KEY"="CASES_DIM"."CASE_KEY")
    16 rows selected.We have the indexes on the columns being joined on, and it appears to use a fast full scan on that index, but still the query takes about 5 seconds to run, just for this very simple query. When I add the rest of the joins and conditions that are in the actual OBIEE query, it's more like a 15 second query. It needs to be much faster.
    Any ideas? Btw I am not a DBA or tuning expert, simply an OBIEE developer that was tasked with fixing this performance.
    Thanks.

    both tables have ~1M rows so no much choice. Assuming the dim table has unique index, nest loop join is usually faster. try the two sql below to see any improvement
    select /*+ use_nl(a b) */ count(distinct a.CASE_KEY)
    from COMPSTAT_CASES_FACT a,
    inner join COMPSTAT_CASES_DIM b on b.CASE_KEY = a.CASE_KEY
    select /*+ use_nl(a b) */ count(*)
    from (select distinct CASE_KEY from COMPSTAT_CASES_FACT) a
    inner join COMPSTAT_CASES_DIM b on b.CASE_KEY = a.CASE_KEY
    ;

  • Slow running query on heavily updating table

    Hi,
    I am working on a live gps tracking project. The project is using SQL Server 2008 web edition. There are thousands of devices which are sending data packets in every 10 seconds or less depending on various settings to the server. On server there is a tcp
    server listener program which reads and parse data and insert it into a "Table-A". Table-A has a trigger which updates Table-B on each insertion (Table-B is used to show live updated status on website). Now Table-A has millions of records per day
    and high insertion rate per second.
    We also need to show the history reports and other reports using "Table-A". The problem is query on "Table-A" is very slow and affacts the insertion on "Table-A". Please help to overcome this problem.

    Since there are frequent inserts ,I believe you are selecting records using NOLOCK hint to avoid shared locks.
    Niting,
    I am pretty much sure in OP scenario NOLOCK will cause blunder. Please don't advise NOLOCK on forum where we have no or minimal information about OP database and infrastructure. Its not a good coding practice.
    Your comment to perform regular stats update also does not makes sense, are you sure stats is the issue I can sense some app design problem.
    Ganesh,
    I guess trigger on Table A is making things slow as it has to complete and I guess this is what taking time , I am not sure.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Select Query--General Question

    Hello All,
    With out using WHERE CLAUSE Can we select first 10 rows from a table in Oracle..??
    This is an interview question I faced recently!!
    Thank you
    Kiran

    How about this...
    SQL> create table xtmp (n number);
    Table created.
    SQL> insert into xtmp select rownum from all_objects where rownum < 11;
    10 rows created.
    SQL> select b.* from xtmp a left join (select rownum rn, c.* from emp c) b on a.n=b.rn;
            RN      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
             1       7369 SMITH      CLERK           7902 17-DEC-80        800                    20
             2       7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
             3       7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
             4       7566 JONES      MANAGER         7839 02-APR-81       2975                    20
             5       7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
             6       7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
             7       7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
             8       7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
             9       7839 KING       PRESIDENT            17-NOV-81       5000                    10
            10       7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
    10 rows selected.you can use pl/sql table instead of above temp table.
    Thanks..

  • Need help tuning slow running query

    Need help tuning below two Oracle queries:
    Query #1:
    ======================
    SELECT "WORK_ORDER_FACT_ALL_YESTERDAY"."WORK_ORDER_HISTORY_ID",
    "WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_NUMBER",
    "ACCOUNT_DIM"."ACCOUNT_NUMBER", "ACCOUNT_DIM"."ACCOUNT_WS_DISC_DATE"
    FROM "CDWD"."WORK_ORDER_FACT_ALL_YESTERDAY" "WORK_ORDER_FACT_ALL_YESTERDAY",
    "CDWD"."ACCOUNT_DIM" "ACCOUNT_DIM"
    WHERE (SUBSTR ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_FIRST_NAME", 1, 1) =
    SUBSTR ("ACCOUNT_DIM"."ACCOUNT_FIRST_NAME", 1, 1)
    AND (SUBSTR ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_LAST_NAME", 1, 4) =
    SUBSTR ("ACCOUNT_DIM"."ACCOUNT_LAST_NAME", 1, 4)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_DL_NUMBER" =
    "ACCOUNT_DIM"."ACCOUNT_DL_NUMBER"
    AND "WORK_ORDER_FACT_ALL_YESTERDAY"."WO_TYPE_CODE" IN ('25', '27')
    AND ("ACCOUNT_DIM"."REVENUE_TYPE_ID" = 1)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."TRANSFER_COUNT" = 0)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."WINBACK_ADD_COUNT" = 0)
    AND ("ACCOUNT_DIM"."ACCOUNT_WS_ENTRY_DATE" <
    (TO_DATE ('2006.05.02', 'yyyy.mm.dd') - 11
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."IS_DERIVED" = 0)
    AND ("ACCOUNT_DIM"."EXPIRATION_DATE" IS NULL)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACT_ACCOUNT_TYPE_CD" <> '50');
    Query #2
    ==================
    UPDATE work_order_fact_all_yesterday g
    SET returns_count = 1
    WHERE EXISTS (SELECT 1
    FROM (SELECT a.phone_dim_key AS transactional_phone_dim_key,
    b.mdn_number AS transactional_mdn_number,
    b.account_number AS transactional_account_number
    FROM work_order_fact_all_yesterday a INNER JOIN phone_dim b ON a.phone_dim_key = b.phone_dim_key
    WHERE a.gross_deactivations_count = 1) e
    INNER JOIN (SELECT c.phone_dim_key AS historical_phone_dim_key,
    d.mdn_number AS historical_mdn_number,
    d.account_number AS historical_account_number
    FROM (SELECT phone_dim_key
    FROM work_order_activity_fact
    WHERE gross_adds_count = 1
    AND report_date >= :b1 - 66
    AND NVL (is_derived, 0 ) = 0
    UNION
    SELECT phone_dim_key
    FROM work_order_fact_all_yesterday
    WHERE gross_adds_count = 1
    AND is_derived = 0) c
    INNER JOIN phone_dim d ON c.phone_dim_key = d.phone_dim_key ) f
    ON e.transactional_mdn_number = f.historical_mdn_number
    AND e.transactional_account_number = f.historical_account_number
    WHERE e.transactional_phone_dim_key = g.phone_dim_key)
    AND g.gross_deactivations_count = 1
    AND g.account_revenue_type_id = 1;
    I ran the DBMS_SQLTUNE on it for 10g and did not get any advice. How can I tune the above queries? Thanks!

    Tune the SQL? Looking at the join criteria of SUBSTR("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_FIRST_NAME", 1, 1) = SUBSTR ("ACCOUNT_DIM"."ACCOUNT_FIRST_NAME", 1, 1) and other substrings, it seems to me that you have basic flaws in your relation design.
    Column must be atomic values. Having to extract a sub-set value from a column to create the intelligence needed to join to another table - that is just plain wrong in relation design. Never mind the performance impact and overheads it causes in the database.

  • Report Builder Question - OA AR Aging - and a general question

    I'm sure this is the wrong forum for this question, but I thought there might be someone here who might be using Oracle Applications and Report Builder who'd be kind enough to help me out.
    We've recently implemented Oracle Applications 11.5.10 and I have to use report builder to change the Accounts Receiveable Aging (7 bucket) to a 5 bucket report. I've already made some changes to the seeded "ARXAGMW.rdf" report, but I'm not a big Oracle Reports guy. I've stumbled through making some changes in various other reports. But this one is just plain nasty! :)
    I was thinking that I could simply add buckets 6 & 7 to bucket 5, then just hide or delete the 6 & 7 buckets. But I'm not sure where to even start. Any help with this would GUARANTEE a Christmas or other holiday card this year! :)
    I really want to keep this simple as possible, so any help would be very....helpful. :)
    Oh, my general question is: Are there any resouces/books for Oracle Reports (Report Builder)? I feel so lost trying to modify existing reports, let alone creating new ones.
    Thanks again!
    Steve

    Hi Steve,
    I am working on the 7-bucket aging report and i want to add a new field in data model.
    As the query is build dynamically, i have modified the function BUILD_CUSTOMER_SELECT to meet my requirements.
    But the problem is that in the data model, the field is not present in my Grouping. and if I try to add the field in the Data Model query (Q_ Customer) section,
    i get the following error: ORA-01789: query block has incorrect number of result columns.
    The query is as shown below:
    select rpad('a',50,'-') short_cust_name,
    0 cust_id,
    rpad('a',30,'-') cust_no,
    rpad('a',500,'-') sort_field1,
    rpad('a',40,'-') sort_field2,
    0 payment_sched_id,
    rpad('a',32,'-') class,
    sysdate due_date,
    0 amt_due_remaining,
    0 days_past_due ,
    0 amount_adjusted,
    0 amount_applied,
    0 amount_credited,
    sysdate gl_date,
    'x' data_converted,
    0 ps_exchange_rate,
    0 b0,
    0 b1,
    0 b2,
    0 b3,
    0 b4,
    0 b5,
    0 b6,
    rpad('a',25,'-') bal_segment_value,
    rpad('a',500,'-') inv_tid,
    rpad('a',32,'-') invoice_type
    , 'y' parent_cust --I WANT A NEW FIELD HERE TO BE VIEWED ON THE REPORT LAYOUT LATER
    from dual
    where 1=2
    UNION ALL
    &common_query_cus
    Did i missed somthing 4 me to be able to add the field here?

  • Long running query--- included steps given by Randolf

    Hi,
    I have done my best to follow Randolf instruction word-by-word and hope to get solution for my
    problem soon. Sometime back I have posted a thread on this problem then got busy with other
    stuff and was not able to follow it. Here I am again with same issue.
    here is link for my previous post
    long running query in database 10gHere is backgroud of my requriemment.
    I am working on Oracle forms 10g which is using package given below. We want to display client information
    with order count basd on different status like Pending, Error, back Order, expedited, std shipping.
    Output will look something like.
    client name   pending    error   backorder   expedited   std shipping
    ABC            24         0       674          6789         78900
    XYZ            35         673    5700           0           798274
    .There are total 40 clients . The long running query are expedited and std shipping.
    When i run package from Oracle Form Developer it takes 3 mintues to run but when I run same query in our application using forms
    (which uses Oracle Application Server) it takes around 1 hour, which is completly unacceptable.
    User wants it be done in less than 1 mintue.
    I have tried combining Pending,error and backorder queries together but as far as I know it will not
    work in Oracle Form as we need a place holder for each status.
    Please dont think it is Forms related question, it is a Performance problem.
    PACKAGE BODY ORDER_COUNT_PKG IS
    PROCEDURE post_query IS
      BEGIN
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.PENDING
                  FROM orders o
              WHERE o.status = 'P'
                   AND (parent_order_id is null
                    OR  (order_type='G'
                         AND parent_order_id=original_order_number))
                      AND  o.client = :ORDER_STATUS.CLIENT_NUMBER;
         EXCEPTION
           WHEN OTHERS THEN
           NULL;
           END;
             BEGIN
                 SELECT  count(*)
                   INTO  :ORDER_STATUS.ERROR
                   FROM  orders o
                  WHERE  o.status = 'E'
                    AND  (parent_order_id is null
                     OR  (order_type='G'
                           AND parent_order_id=original_order_number))
                       AND  o.client = :ORDER_STATUS.CLIENT_NUMBER;
                EXCEPTION
           WHEN OTHERS THEN
           NULL;     
            END;
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.BACK_ORDER
                  FROM orders o
              WHERE o.status = 'B'
                   AND (parent_order_id is null
                    OR (order_type='G'
                         AND parent_order_id=original_order_number))
                      AND o.client = :ORDER_STATUS.CLIENT_NUMBER;
          EXCEPTION
           WHEN OTHERS THEN
           NULL;   
         END;
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.EXPEDITE
                  FROM orders o,shipment_type_methods stm
                 WHERE o.status in ('A','U')
             AND (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND o.client = stm.client
             AND o.shipment_class_code = stm.shipment_class_code
             AND (nvl(o.priority,'1') = '2'
              OR  stm.surcharge_amount <> 0)
                      AND  o.client = :ORDER_STATUS.CLIENT_NUMBER
              GROUP BY  o.client;
              EXCEPTION
           WHEN OTHERS THEN
           NULL;          
         END;           
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.STD_SHIP
                  FROM  orders o,shipment_type_methods stm
                 WHERE o.status in ('A','U')
             AND  (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND nvl(o.priority,'1') <> '2'
             AND o.client = stm.client
             AND o.shipment_class_code = stm.shipment_class_code
             AND stm.surcharge_amount = 0
                      AND o.client = :ORDER_STATUS.CLIENT_NUMBER
              GROUP BY o.client;
          EXCEPTION
           WHEN OTHERS THEN
           NULL;
           END;
      END post_query;
      END ORDER_COUNT_PKG;one of the query which is taking long time is
    SELECT count(*)
                   FROM  orders o,shipment_type_methods stm
                 WHERE o.status in ('A','U')
             AND  (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND nvl(o.priority,'1') <> '2'
             AND o.client = stm.client
             AND o.shipment_class_code = stm.shipment_class_code
             AND stm.surcharge_amount = 0
               AND o.client = :CLIENT_NUMBER
              GROUP BY o.clientThe version of the database is 10.2.1.0.2
    SQL> alter session force parallel dml;These are the parameters relevant to the optimizer:
    SQL> show parameter user_dump_dest
    NAME                                 TYPE        VALUE
    user_dump_dest                       string      /u01/app/oracle/admin/mcgemqa/
                                                     udump
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.4
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     16
    SQL> show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    SQL> show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACTHere is the output of EXPLAIN PLAN:
    SQL> explain plan for
      2  SELECT count(*)
      3         FROM  orders o,shipment_type_methods stm
      4       WHERE o.status in ('A','U')
      5           AND  (o.parent_order_id is null
      6            OR (o.order_type = 'G'
      7           AND o.parent_order_id = o.original_order_number))
      8           AND nvl(o.priority,'1') <> '2'
      9           AND o.client = stm.client
    10           AND o.shipment_class_code = stm.shipment_class_code
    11           AND stm.surcharge_amount = 0
    12     AND o.client = :CLIENT_NUMBER
    13    GROUP BY o.client
    14  /
    Explained.
    Elapsed: 00:00:00.12
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 559278019
    | Id  | Operation                      | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT          |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |   175K|  3431K| 25979   (3)| 00:05:12 |
    |   3 |    NESTED LOOPS                |                         | 25300 |   864K| 46764   (3)| 00:09:22 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |   176K|       |  2371   (8)| 00:00:29 |
    Predicate Information (identified by operation id):
       2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
                  AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    24 rows selected.
    Elapsed: 00:00:00.86
    SQL> rollback;
    Rollback complete.
    Elapsed: 00:00:00.07Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
    SQL> SELECT count(*)
      2         FROM  orders o,shipment_type_methods stm
      3       WHERE o.status in ('A','U')
      4           AND  (o.parent_order_id is null
      5            OR (o.order_type = 'G'
      6           AND o.parent_order_id = o.original_order_number))
      7           AND nvl(o.priority,'1') <> '2'
      8           AND o.client = stm.client
      9           AND o.shipment_class_code = stm.shipment_class_code
    10           AND stm.surcharge_amount = 0
    11     AND o.client = :CLIENT_NUMBER
    12    GROUP BY o.client
    13  /
    Elapsed: 00:00:03.09
    Execution Plan
    Plan hash value: 559278019
    | Id  | Operation                      | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT          |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |   175K|  3431K| 25979   (3)| 00:05:12 |
    |   3 |    NESTED LOOPS                |                         | 25300 |   864K| 46764   (3)| 00:09:22 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |   176K|       |  2371   (8)| 00:00:29 |
    Predicate Information (identified by operation id):
       2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
                  AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    Statistics
             55  recursive calls
              0  db block gets
           7045  consistent gets
              0  physical reads
              0  redo size
            206  bytes sent via SQL*Net to client
            238  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> The TKPROF output for this statement looks like the following:
    SELECT count(*)
           FROM  orders o,shipment_type_methods stm
         WHERE o.status in ('A','U')
             AND  (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND nvl(o.priority,'1') <> '2'
             AND o.client = stm.client
             AND o.shipment_class_code = stm.shipment_class_code
             AND stm.surcharge_amount = 0
       AND o.client = :CLIENT_NUMBER
      GROUP BY o.client
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.04       0.04          0          0          0           0
    Fetch        2      2.96       2.91          0       7039          0           1
    total        4      3.01       2.95          0       7039          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 95 
    Rows     Row Source Operation
          1  SORT GROUP BY NOSORT (cr=7039 pr=0 pw=0 time=2913701 us)
         91   TABLE ACCESS BY INDEX ROWID ORDERS (cr=7039 pr=0 pw=0 time=261997906 us)
         93    NESTED LOOPS  (cr=6976 pr=0 pw=0 time=20740 us)
          1     TABLE ACCESS BY INDEX ROWID SHIPMENT_TYPE_METHODS (cr=2 pr=0 pw=0 time=208 us)
          3      INDEX RANGE SCAN U_SHIPMENT_TYPE_METHODS (cr=1 pr=0 pw=0 time=88 us)(object id 81957)
         91     INDEX RANGE SCAN ORDERS_ORDER_DATE (cr=6974 pr=0 pw=0 time=70 us)(object id 81547)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     2        0.02          0.02
    ********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
    SQL> variable CLIENT_NUMBER varchar2(20)
    SQL> exec :CLIENT_NUMBER := '14'
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.06
    SQL> SELECT /*+ gather_plan_statistics */ count(*)
      2         FROM  orders o,shipment_type_methods stm
      3       WHERE o.status in ('A','U')
      4           AND  (o.parent_order_id is null
      5            OR (o.order_type = 'G'
      6           AND o.parent_order_id = o.original_order_number))
      7           AND nvl(o.priority,'1') <> '2'
      8           AND o.client = stm.client
      9           AND o.shipment_class_code = stm.shipment_class_code
    10           AND stm.surcharge_amount = 0
    11     AND o.client = :CLIENT_NUMBER
    12    GROUP BY o.client
    13  /
      COUNT(*)
            91
    Elapsed: 00:00:02.85
    SQL> set termout on
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  4nfj368y8w6a3, child number 0
    SELECT /*+ gather_plan_statistics */ count(*)        FROM  orders o,shipment_type_methods stm      WHERE
    o.status in ('A','U')          AND  (o.parent_order_id is null           OR (o.order_type = 'G'
    AND o.parent_order_id = o.original_order_number))          AND nvl(o.priority,'1') <> '2'          AND
    o.client = stm.client          AND o.shipment_class_code = stm.shipment_class_code          AND
    stm.surcharge_amount = 0    AND o.client = :CLIENT_NUMBER   GROUP BY o.client
    Plan hash value: 559278019
    | Id  | Operation                      | Name                    | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   1 |  SORT GROUP BY NOSORT          |                         |      1 |      1 |      1 |00:00:02.63 |    7039 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |      1 |    175K|     91 |00:03:56.87 |    7039 |
    |   3 |    NESTED LOOPS                |                         |      1 |  25300 |     93 |00:00:00.02 |    6976 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |      1 |      1 |      1 |00:00:00.01 |       2 |
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |      1 |      2 |      3 |00:00:00.01 |       1 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |      1 |    176K|     91 |00:00:00.01 |    6974 |
    Predicate Information (identified by operation id):
       2 - filter((("O"."PARENT_ORDER_ID" IS NULL OR ("O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER"))) AND NVL("O"."PRIORITY",'1')<>'
                  "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE"))
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter(("O"."STATUS"='A' OR "O"."STATUS"='U'))
    32 rows selected.
    Elapsed: 00:00:01.30
    SQL> I'm looking forward for suggestions how to improve the performance of this statement.
    Thanks
    Sandy

    Please find explain plan for No hint
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 559278019
    | Id  | Operation                      | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT          |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |   175K|  3431K| 25979   (3)| 00:05:12 |
    |   3 |    NESTED LOOPS                |                         | 25300 |   864K| 46764   (3)| 00:09:22 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |   176K|       |  2371   (8)| 00:00:29 |
    Predicate Information (identified by operation id):
       2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
                  AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    24 rows selected.
    Elapsed: 00:00:00.86Explain Plan for Parallel Hint
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 559278019
    | Id  | Operation                      | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT          |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |   175K|  3431K| 25979   (3)| 00:05:12 |
    |   3 |    NESTED LOOPS                |                         | 25300 |   864K| 46764   (3)| 00:09:22 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |   176K|       |  2371   (8)| 00:00:29 |
    Predicate Information (identified by operation id):
       2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
                  AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"='14')
       6 - access("O"."CLIENT"='14')
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    24 rows selected.
    Elapsed: 00:00:08.92Explain Plan for USE_Hash hint
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1465232248
    | Id  | Operation                     | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                         |     1 |    35 | 46786   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT         |                         |     1 |    35 | 46786   (3)| 00:09:22 |
    |*  2 |   HASH JOIN                   |                         | 25300 |   864K| 46786   (3)| 00:09:22 |
    |*  3 |    TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00:0
    |*  4 |     INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  5 |    TABLE ACCESS BY INDEX ROWID| ORDERS                  |   175K|  3431K| 46763   (3)| 00:09:22 |
    |*  6 |     INDEX RANGE SCAN          | ORDERS_ORDER_DATE       |   176K|       |  4268   (8)| 00:00:52 |
    Predicate Information (identified by operation id):
       2 - access("O"."CLIENT"="STM"."CLIENT" AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_COD
                  E")
       3 - filter("STM"."SURCHARGE_AMOUNT"=0)
       4 - access("STM"."CLIENT"='14')
       5 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
       6 - access("O"."CLIENT"='14')
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    25 rows selected.
    Elapsed: 00:00:01.09
    SQL> Thanks
    Sandy

  • Update on Bioinformatics WIKI, scripting challenges, and a general question

    I am waiting for my site to go on-line at Oak Ridge National Labs (USA, Tennessee).  Should be another week or so, maybe less.
    When that happens, you will see a veritable explosion of scripting challenges in my wiki (Emerging Technologies->Bioinformatics.)
    One general question in preparation for these challenges.
    There are a number of standard  bioinformatic programs that can be run interactively via the web at various sites, e.g. "BLAST" and "STRIDE". 
    Although these can also be run locally, this requires that you download large databases and keep them updated.
    So here's my question to the scripting experts:
    Are scripting languages powerful enough to submit queries to web pages and then use regex's to parse the html that is returned?
    Bill Mann has used PERL to do some of the required regex parsing, but there is a lot left to do, and, his stuff only works when a perl program is invoking a bioinformatic program locally, not interactively.
    If so, we all can do some beautiful stuff together , if anyone is interested ...

    ...my wiki on...
    There is by it's very nature no such thing as MY WIKI, except you run your own wiki project in an exclusive mode. Which were...well ... unusual.
    Are scripting languages powerful enough to submit queries to web pages and then use regex's to parse the html that is returned?
    Yes.
    anton

  • Explain for a very long running query

    Dear gurus,
    I have an issue with a long running query which takes around 2 hrs to execute. The tables being used here pertains to 11i, so there is no scope of indexing.
    SELECT peia.expenditure_item_id, DECODE (peia.system_linkage_function, 'ST', 'TIME', 'EXP' ) AS CATEGORY,
    pea.incurred_by_person_id AS employee_id, emp.attribute6 AS q_number, NVL (emp.employee_number, npw_number) AS employee_number, emp.full_name AS employee_name, peia.project_id,
    ppa.segment1, ppa.NAME, func_get_proj_attribute (peia.project_id, NULL, 'PROJECT ENTITY NAME' ) AS project_entity,
    func_get_proj_attribute (peia.project_id, NULL, 'PROJECT MANAGER') AS project_manager,
    DECODE (ppa.distribution_rule, 'WORK/WORK', 'TM', 'WORK/EVENT', 'TM with Milestone' ) AS project_classification,
    ppa.project_type AS funding_type, func_get_proj_attribute(peia.project_id, NULL, 'CUSTOMER GROUP' ) AS customer_group,
    func_get_proj_attribute(peia.project_id, NULL, 'ACCOUNT MANAGER' ) AS account_manager,
    pt.top_task_id, func_get_task_attribute(pt.top_task_id, 'TASK NUMBER' ) AS task_number,
    func_get_task_attribute (pt.top_task_id, 'TASK NAME' ) AS task_name, peia.expenditure_item_date, peia.projfunc_raw_revenue AS func_raw_revenue,
    peia.accrued_revenue AS func_accrued_revenue, peia.projfunc_currency_code,
    DECODE (peia.project_raw_revenue, NULL,
    DECODE (peia.system_linkage_function, 'ST', peia.quantity* NVL (peia.bill_rate, func_get_emp_billrate (pea.incurred_by_person_id, peia.project_id, peia.task_id,
    peia.expenditure_item_date )
    peia.quantity
    peia.project_raw_revenue
    ( peia.accrued_revenue
    / peia.projfunc_raw_revenue
    * peia.project_raw_revenue
    ) AS project_accrued_revenue,
    ppa.project_currency_code,
    NVL(peia.bill_rate, func_get_emp_billrate (pea.incurred_by_person_id, peia.project_id, peia.task_id, peia.expenditure_item_date)
    ) AS bill_rate,
    peia.rev_dist_rejection_code, SYSDATE AS generated_date
    FROM pa_expenditures_all pea
    INNER JOIN (SELECT * FROM per_all_people_f WHERE SYSDATE BETWEEN effective_start_date AND effective_end_date) emp ON NVL(pea.incurred_by_person_id, 61) =emp.person_id
    INNER JOIN (SELECT * FROM pa_expenditure_items_all WHERE billable_flag = 'Y' AND quantity <> 0) peia ON pea.expenditure_id =peia.expenditure_id
    INNER JOIN (SELECT * FROM pa_projects_all WHERE project_status_code = 'APPROVED' AND distribution_rule IN ('WORK/WORK', 'WORK/EVENT')) ppa ON peia.project_id =ppa.project_id
    INNER JOIN pa_tasks pt ON peia.task_id = pt.task_id;
    The explain plan for this is:
    SELECT STATEMENT CHOOSECost: 26,758 Bytes: 53,373,971 Cardinality: 245,963                          
         9 HASH JOIN Cost: 26,758 Bytes: 53,373,971 Cardinality: 245,963                     
              1 TABLE ACCESS FULL TABLE HR.PER_ALL_PEOPLE_F Cost: 67 Bytes: 546,900 Cardinality: 9,115                
              8 HASH JOIN Cost: 26,581 Bytes: 20,174,029 Cardinality: 128,497                
                   2 TABLE ACCESS FULL TABLE PA.PA_TASKS Cost: 596 Bytes: 856,370 Cardinality: 85,637           
                   7 HASH JOIN Cost: 25,691 Bytes: 18,889,059 Cardinality: 128,497           
                        3 TABLE ACCESS FULL TABLE PA.PA_EXPENDITURES_ALL Cost: 1,524 Bytes: 5,220,330 Cardinality: 522,033      
                        6 HASH JOIN Cost: 23,701 Bytes: 17,604,089 Cardinality: 128,497      
                             4 TABLE ACCESS FULL TABLE PA.PA_PROJECTS_ALL Cost: 91 Bytes: 49,059 Cardinality: 621
                             5 TABLE ACCESS FULL TABLE PA.PA_EXPENDITURE_ITEMS_ALL Cost: 23,575 Bytes: 68,913,570 Cardinality: 1,188,165
    Can anyone suggests what can be done to improve this query?
    Thanks in advance
    SA
    Edited by: user593719 on Oct 5, 2010 10:29 AM
    Edited by: user593719 on Oct 5, 2010 10:30 AM

    1) Your inner joins are doing record selections that could be done on the Join's ON clause.
    2) Look at your functions to see if you can get performance improvements using parameterized CURSORs & adding DETERMINISTIC to the definition.
    3) Consider using WITH to first pull your data & then running your functions.
    For example:
    with
    smiths as (
    select *
    from hr.per_all_people_f papf
    where papf.first_name='Smith'
    select *
    from smiths
    where trunc(sysdate) between effective_start_date and effective_end_date;
    In general, pare down your data first. Whatever will restrict your data most, start with selecting that table/view.

  • Newbie question - general question about e-mail sync

    Hi,
    I have a general question about email sync and BlackBerry smartphones.  Are there any devices that allow email syncing with a Microsoft Exchange 2007 system that do not require the BlackBerry Enterprise server?
    Thanks; sorry if this has been asked before but I was unable to find it in the forums, documentation, etc.  Everything I found assumes that for this kind of environment you will be using a BlackBerry Enterprise solution, but I can't assume.
    Thanks again.
    Solved!
    Go to Solution.

    Hi and Welcome to the Forums!
    If the Exchange server has anything that faces the internet (OWA, POP, IMAP), then BIS can be used to handle email (only email...calendar and contacts require BES to sync OTA).
    Or, a PC, inside the network (but with an internet path) and logged into the email server (using Outlook), can be left running, using the RIM Desktop Software's Desktop Redirector capability to forward  messages to the BB.
    Those are basically the options.
    Hope that helps! Let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Studio Creator 2: Query Editor questions

    Having trouble figuring out the Query Editor... 'Help' says there should be four sections; I see two: the SQL and grid results run a test from a Sybase table... I can't select the grid column and specify WHERE clause stuff... also it doesn't seem to let me Save the Query... not sure what's wrong... Any ideas on either question? Thanks

    It could be that an Output Window (the Window at the bottom center)
    is obscuring the view.
    There are a couple of ways of specifying a where clause
    1) Add a constraint - inside the grid view, scroll to the Criteria column, right-click
    and choose Add Criteria
    2) In the text editing pane, just type in the where clause.
    Note: the Query Editor's parser accepts a basic set of SQL syntax keywords.
    If a keyword is not recognized then the graphical view and grid view clear.
    The Run Query feature will still be available.
    This is something we hope to improve.
    Here's some more resources on the Query Editor:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/query-editor.html
    http://developers.sun.com/prodtech/javatools/jscreator/reference/tips/2/queryeditor.html
    John
    Creator team

  • Slow running iMac?

    Does anyone know the best way of fixing a slow running iMac without adding more memory?

    Please describe the problem in as much relevant detail as possible. The better your description, the better the chance of a solution.
    For example, if the computer is slow, which specific actions are slow? Is it slow all the time, or only sometimes? When did it start to be slow? Did you change anything just before it started? Have you seen any alerts or error messages? Have you done anything to try to fix it? Most importantly, do you have a current backup of all data? If the answer to the last question is "no," back up now. Ask if you need guidance. Do nothing else until you have a backup.

Maybe you are looking for