This query is taking a long time:

Hi All,
I need help in tuning this query. The stats are as below:
SQL> show parameter user_dump_dest
NAME                                 TYPE        VALUE
user_dump_dest                       string      /opt/app/oracle/diag/rdbms/ebi
                                                 zfile/EBIZFILE/trace
SQL> show parameter optimizer
NAME                                 TYPE        VALUE
optimizer_capture_sql_plan_baselines boolean     FALSE
optimizer_dynamic_sampling           integer     2
optimizer_features_enable            string      11.2.0.2
optimizer_index_caching              integer     0
optimizer_index_cost_adj             integer     100
optimizer_mode                       string      ALL_ROWS
optimizer_secure_view_merging        boolean     TRUE
optimizer_use_invisible_indexes      boolean     FALSE
optimizer_use_pending_statistics     boolean     FALSE
optimizer_use_sql_plan_baselines     boolean     TRUE
SQL> show parameter db_file_multi
NAME                                 TYPE        VALUE
db_file_multiblock_read_count        integer     128
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      EXACT
SQL>
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL>
SQL> select
  2  sname, pname, pval1, pval2
  3  from
  4  sys.aux_stats$;
SNAME                PNAME                     PVAL1 PVAL2
SYSSTATS_INFO        STATUS                          COMPLETED
SYSSTATS_INFO        DSTART                          11-03-2009 02:33
SYSSTATS_INFO        DSTOP                           11-03-2009 02:33
SYSSTATS_INFO        FLAGS                         1
SYSSTATS_MAIN        CPUSPEEDNW            714.19791
SYSSTATS_MAIN        IOSEEKTIM                    10
SYSSTATS_MAIN        IOTFRSPEED                 4096
SYSSTATS_MAIN        SREADTIM
SYSSTATS_MAIN        MREADTIM
SYSSTATS_MAIN        CPUSPEED
SYSSTATS_MAIN        MBRC
SYSSTATS_MAIN        MAXTHR
SYSSTATS_MAIN        SLAVETHR
13 rows selected.
Elapsed: 00:00:00.03
SQL>
SQL> explain plan for
  2   SELECT   A.TRANS_NO,
  3            A.TRANS_ID,
  4            A.REQUEST_IND,
  5            A.TRANS_STATUS_IND,
  6            A.TRANS_STATUS_DATE,
  7            A.DELIVERY_DATE,
  8            C.EMAIL_ADDR
  9        FROM     IIS_TRANS_MASTER A, M_TRANS B, IIS_REQUEST_TRANS C
10       WHERE
11             C.TRANS_NO = A.TRANS_NO
12            AND A.TRANS_STATUS_IND = 'P'
13            AND A.TRANS_ID = B.TRANS_ID
14            AND A.TRANS_ID <> 'I009'
15            AND A.TRANS_ID <> 'NPKG'
16            AND B.TRANS_CO_TYPE = 'I'
17            AND A.TRANS_ID NOT IN
18                  ('P012', 'P13B', 'P13C', 'P14B', 'P14C', 'P015')
19            AND B.DEPT = 'IRD'
20  ORDER BY     A.CREATED_DATE;
Explained.
Elapsed: 00:00:00.01
SQL>
SQL> set pagesize 1000;
SQL> set linesize 170;
SQL> @/opt/app/oracle/product/11.2.0/rdbms/admin/utlxplp.sql
SQL> Rem
SQL> Rem $Header: utlxplp.sql 23-jan-2002.08:55:23 bdagevil Exp $
SQL> Rem
SQL> Rem utlxplp.sql
SQL> Rem
SQL> Rem Copyright (c) 1998, 2002, Oracle Corporation.     All rights reserved.
SQL> Rem
SQL> Rem    NAME
SQL> Rem      utlxplp.sql - UTiLity eXPLain Parallel plans
SQL> Rem
SQL> Rem    DESCRIPTION
SQL> Rem      script utility to display the explain plan of the last explain plan
SQL> Rem      command. Display also Parallel Query information if the plan happens to
SQL> Rem      run parallel
SQL> Rem
SQL> Rem    NOTES
SQL> Rem      Assume that the table PLAN_TABLE has been created. The script
SQL> Rem      utlxplan.sql should be used to create that table
SQL> Rem
SQL> Rem      With SQL*plus, it is recomended to set linesize and pagesize before
SQL> Rem      running this script. For example:
SQL> Rem      set linesize 130
SQL> Rem      set pagesize 0
SQL> Rem
SQL> Rem    MODIFIED   (MM/DD/YY)
SQL> Rem    bdagevil     01/23/02 - rewrite with new dbms_xplan package
SQL> Rem    bdagevil     04/05/01 - include CPU cost
SQL> Rem    bdagevil     02/27/01 - increase Name column
SQL> Rem    jihuang     06/14/00 - change order by to order siblings by.
SQL> Rem    jihuang     05/10/00 - include plan info for recursive SQL in LE row source
SQL> Rem    bdagevil     01/05/00 - make deterministic with order-by
SQL> Rem    bdagevil     05/07/98 - Explain plan script for parallel plans
SQL> Rem    bdagevil     05/07/98 - Created
SQL> Rem
SQL>
SQL> set markup html preformat on
SQL>
SQL> Rem
SQL> Rem Use the display table function from the dbms_xplan package to display the last
SQL> Rem explain plan. Use default mode which will display only relevant information
SQL> Rem
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
Plan hash value: 3822676895
| Id  | Operation                      | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT               |                   | 38075 |  3123K|       | 22550   (2)| 00:04:31 |
|   1 |  SORT ORDER BY                 |                   | 38075 |  3123K|  3472K| 22550   (2)| 00:04:31 |
|*  2 |   HASH JOIN                    |                   | 38075 |  3123K|  2120K| 21801   (2)| 00:04:22 |
|   3 |    NESTED LOOPS                |                   |       |       |       |            |          |
|   4 |     NESTED LOOPS               |                   | 38075 |  1673K|       |  4177   (1)| 00:00:51 |
|*  5 |      TABLE ACCESS FULL         | M_TRANS           |    10 |    80 |       |     7   (0)| 00:00:01 |
|*  6 |      INDEX RANGE SCAN          | IDX_IIS_TRANS_ID  | 39401 |       |       |   109   (3)| 00:00:02 |
|*  7 |     TABLE ACCESS BY INDEX ROWID| IIS_TRANS_MASTER  |  3940 |   142K|       |  3186   (1)| 00:00:39 |
|   8 |    TABLE ACCESS FULL           | IIS_REQUEST_TRANS |  2114K|    78M|       | 12368   (2)| 00:02:29 |
Predicate Information (identified by operation id):
   2 - access("C"."TRANS_NO"="A"."TRANS_NO")
   5 - filter("B"."DEPT"='IRD' AND "B"."TRANS_CO_TYPE"='I' AND "B"."TRANS_ID"<>'I009' AND
              "B"."TRANS_ID"<>'NPKG' AND "B"."TRANS_ID"<>'P012' AND "B"."TRANS_ID"<>'P13B' AND
              "B"."TRANS_ID"<>'P13C' AND "B"."TRANS_ID"<>'P14B' AND "B"."TRANS_ID"<>'P14C' AND
              "B"."TRANS_ID"<>'P015')
   6 - access("A"."TRANS_ID"="B"."TRANS_ID")
       filter("A"."TRANS_ID"<>'I009' AND "A"."TRANS_ID"<>'NPKG' AND "A"."TRANS_ID"<>'P012' AND
              "A"."TRANS_ID"<>'P13B' AND "A"."TRANS_ID"<>'P13C' AND "A"."TRANS_ID"<>'P14B' AND
              "A"."TRANS_ID"<>'P14C' AND "A"."TRANS_ID"<>'P015')
   7 - filter("A"."TRANS_STATUS_IND"='P')
29 rows selected.
Elapsed: 00:00:00.02
SQL>
SQL> rollback;
Rollback complete.
Elapsed: 00:00:00.00
SQL>
SQL> rem Set the ARRAYSIZE according to your application
SQL> set autotrace traceonly arraysize 100
SQL>
SQL> alter session set tracefile_identifier = 'mytrace1';
Session altered.
Elapsed: 00:00:00.00
SQL>
SQL> rem if you're using bind variables
SQL> rem define them here
SQL>
SQL> rem variable b_var1 number
SQL> rem variable b_var2 varchar2(20)
SQL>
SQL> rem and initialize them
SQL>
SQL> rem exec :b_var1 := 1
SQL> rem exec :b_var2 := 'DIAG'
SQL> set pagesize 1000;
SQL> set linesize 170;
SQL> alter session set events '10046 trace name context forever, level 8';
Session altered.
Elapsed: 00:00:00.00
SQL>  SELECT   A.TRANS_NO,
  2            A.TRANS_ID,
  3            A.REQUEST_IND,
  4            A.TRANS_STATUS_IND,
  5            A.TRANS_STATUS_DATE,
  6            A.DELIVERY_DATE,
  7            C.EMAIL_ADDR
  8        FROM     IIS_TRANS_MASTER A, M_TRANS B, IIS_REQUEST_TRANS C
  9       WHERE
10             C.TRANS_NO = A.TRANS_NO
11            AND A.TRANS_STATUS_IND = 'P'
12            AND A.TRANS_ID = B.TRANS_ID
13            AND A.TRANS_ID <> 'I009'
14            AND A.TRANS_ID <> 'NPKG'
15            AND B.TRANS_CO_TYPE = 'I'
16            AND A.TRANS_ID NOT IN
17                  ('P012', 'P13B', 'P13C', 'P14B', 'P14C', 'P015')
18            AND B.DEPT = 'IRD'
19  ORDER BY     A.CREATED_DATE;
19 rows selected.
Elapsed: 00:00:15.44
Execution Plan
Plan hash value: 3822676895
| Id  | Operation                      | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT               |                   | 38075 |  3123K|       | 22550   (2)| 00:04:31 |
|   1 |  SORT ORDER BY                 |                   | 38075 |  3123K|  3472K| 22550   (2)| 00:04:31 |
|*  2 |   HASH JOIN                    |                   | 38075 |  3123K|  2120K| 21801   (2)| 00:04:22 |
|   3 |    NESTED LOOPS                |                   |       |       |       |            |          |
|   4 |     NESTED LOOPS               |                   | 38075 |  1673K|       |  4177   (1)| 00:00:51 |
|*  5 |      TABLE ACCESS FULL         | M_TRANS           |    10 |    80 |       |     7   (0)| 00:00:01 |
|*  6 |      INDEX RANGE SCAN          | IDX_IIS_TRANS_ID  | 39401 |       |       |   109   (3)| 00:00:02 |
|*  7 |     TABLE ACCESS BY INDEX ROWID| IIS_TRANS_MASTER  |  3940 |   142K|       |  3186   (1)| 00:00:39 |
|   8 |    TABLE ACCESS FULL           | IIS_REQUEST_TRANS |  2114K|    78M|       | 12368   (2)| 00:02:29 |
Predicate Information (identified by operation id):
   2 - access("C"."TRANS_NO"="A"."TRANS_NO")
   5 - filter("B"."DEPT"='IRD' AND "B"."TRANS_CO_TYPE"='I' AND "B"."TRANS_ID"<>'I009' AND
              "B"."TRANS_ID"<>'NPKG' AND "B"."TRANS_ID"<>'P012' AND "B"."TRANS_ID"<>'P13B' AND
              "B"."TRANS_ID"<>'P13C' AND "B"."TRANS_ID"<>'P14B' AND "B"."TRANS_ID"<>'P14C' AND
              "B"."TRANS_ID"<>'P015')
   6 - access("A"."TRANS_ID"="B"."TRANS_ID")
       filter("A"."TRANS_ID"<>'I009' AND "A"."TRANS_ID"<>'NPKG' AND "A"."TRANS_ID"<>'P012' AND
              "A"."TRANS_ID"<>'P13B' AND "A"."TRANS_ID"<>'P13C' AND "A"."TRANS_ID"<>'P14B' AND
              "A"."TRANS_ID"<>'P14C' AND "A"."TRANS_ID"<>'P015')
   7 - filter("A"."TRANS_STATUS_IND"='P')
Statistics
         23  recursive calls
          0  db block gets
     164826  consistent gets
      74235  physical reads
          0  redo size
       1839  bytes sent via SQL*Net to client
        524  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         19  rows processed
SQL>
SQL> disconnect
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Hi Manik,
1) Not really. Order by may not be required.
2) After gathering the stats, below is the result:
NAME_COL_PLUS_SHOW_PARAM                                                         TYPE
VALUE_COL_PLUS_SHOW_PARAM
user_dump_dest                                                                   string
/opt/app/oracle/diag/rdbms/ebizfile/EBIZFILE/trace
SQL> show parameter optimizer
NAME_COL_PLUS_SHOW_PARAM                                                         TYPE
VALUE_COL_PLUS_SHOW_PARAM
Elapsed: 00:00:00.05
SQL>  SELECT   A.TRANS_NO,
  2            A.TRANS_ID,
  3            A.REQUEST_IND,
  4            A.TRANS_STATUS_IND,
  5            A.TRANS_STATUS_DATE,
  6            A.DELIVERY_DATE,
  7            C.EMAIL_ADDR
  8        FROM     IIS_TRANS_MASTER A, M_TRANS B, IIS_REQUEST_TRANS C
  9       WHERE
10             C.TRANS_NO = A.TRANS_NO
11            AND A.TRANS_STATUS_IND = 'P'
12            AND A.TRANS_ID = B.TRANS_ID
13            AND A.TRANS_ID <> 'I009'
14            AND A.TRANS_ID <> 'NPKG'
15            AND B.TRANS_CO_TYPE = 'I'
16            AND A.TRANS_ID NOT IN
17                  ('P012', 'P13B', 'P13C', 'P14B', 'P14C', 'P015')
18            AND B.DEPT = 'IRD'
19  ORDER BY     A.CREATED_DATE;
20 rows selected.
Elapsed: 00:00:06.58
Execution Plan
Plan hash value: 3822676895
| Id  | Operation                      | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT               |                   | 38091 |  3124K|       | 22553   (2)| 00:04:31 |
|   1 |  SORT ORDER BY                 |                   | 38091 |  3124K|  3472K| 22553   (2)| 00:04:31 |
|*  2 |   HASH JOIN                    |                   | 38091 |  3124K|  2128K| 21804   (2)| 00:04:22 |
|   3 |    NESTED LOOPS                |                   |       |       |       |            |          |
|   4 |     NESTED LOOPS               |                   | 38091 |  1673K|       |  4180   (1)| 00:00:51 |
|*  5 |      TABLE ACCESS FULL         | M_TRANS           |    10 |    80 |       |     7   (0)| 00:00:01 |
|*  6 |      INDEX RANGE SCAN          | IDX_IIS_TRANS_ID  | 39418 |       |       |   109   (3)| 00:00:02 |
|*  7 |     TABLE ACCESS BY INDEX ROWID| IIS_TRANS_MASTER  |  3942 |   142K|       |  3189   (1)| 00:00:39 |
|   8 |    TABLE ACCESS FULL           | IIS_REQUEST_TRANS |  2114K|    78M|       | 12368   (2)| 00:02:29 |
Predicate Information (identified by operation id):
   2 - access("C"."TRANS_NO"="A"."TRANS_NO")
   5 - filter("B"."DEPT"='IRD' AND "B"."TRANS_CO_TYPE"='I' AND "B"."TRANS_ID"<>'I009' AND
              "B"."TRANS_ID"<>'NPKG' AND "B"."TRANS_ID"<>'P012' AND "B"."TRANS_ID"<>'P13B' AND
              "B"."TRANS_ID"<>'P13C' AND "B"."TRANS_ID"<>'P14B' AND "B"."TRANS_ID"<>'P14C' AND
              "B"."TRANS_ID"<>'P015')
   6 - access("A"."TRANS_ID"="B"."TRANS_ID")
       filter("A"."TRANS_ID"<>'I009' AND "A"."TRANS_ID"<>'NPKG' AND "A"."TRANS_ID"<>'P012' AND
              "A"."TRANS_ID"<>'P13B' AND "A"."TRANS_ID"<>'P13C' AND "A"."TRANS_ID"<>'P14B' AND
              "A"."TRANS_ID"<>'P14C' AND "A"."TRANS_ID"<>'P015')
   7 - filter("A"."TRANS_STATUS_IND"='P')
Statistics
         17  recursive calls
          0  db block gets
     158643  consistent gets
      49083  physical reads
          0  redo size
       1917  bytes sent via SQL*Net to client
        524  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         20  rows processedI am yet to try the DBMS_SQLTUNE.
Are you able to give me in simplified form the steps in executing this query for the DBMS_SQLTUNE? Thanks!

Similar Messages

  • Why this Query is taking much longer time than expected?

    Hi,
    I need experts support on the below mentioned issue:
    Why this Query is taking much longer time than expected? Sometimes I am getting connection timeout error. Is there any better way to achieve result in shortest time.  Below, please find the DDL & DML:
    DDL
    BHDCollections
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[BHDCollections](
     [BHDCollectionid] [bigint] IDENTITY(1,1) NOT NULL,
     [GroupMemberid] [int] NOT NULL,
     [BHDDate] [datetime] NOT NULL,
     [BHDShift] [varchar](10) NULL,
     [SlipValue] [decimal](18, 3) NOT NULL,
     [ProcessedValue] [decimal](18, 3) NOT NULL,
     [BHDRemarks] [varchar](500) NULL,
     [Createdby] [varchar](50) NULL,
     [Createdon] [datetime] NULL,
     CONSTRAINT [PK_BHDCollections] PRIMARY KEY CLUSTERED
     [BHDCollectionid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    BHDCollectionsDet
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[BHDCollectionsDet](
     [CollectionDetailid] [bigint] IDENTITY(1,1) NOT NULL,
     [BHDCollectionid] [bigint] NOT NULL,
     [Currencyid] [int] NOT NULL,
     [Denomination] [decimal](18, 3) NOT NULL,
     [Quantity] [int] NOT NULL,
     CONSTRAINT [PK_BHDCollectionsDet] PRIMARY KEY CLUSTERED
     [CollectionDetailid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    Banks
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[Banks](
     [Bankid] [int] IDENTITY(1,1) NOT NULL,
     [Bankname] [varchar](50) NOT NULL,
     [Bankabbr] [varchar](50) NULL,
     [BankContact] [varchar](50) NULL,
     [BankTel] [varchar](25) NULL,
     [BankFax] [varchar](25) NULL,
     [BankEmail] [varchar](50) NULL,
     [BankActive] [bit] NULL,
     [Createdby] [varchar](50) NULL,
     [Createdon] [datetime] NULL,
     CONSTRAINT [PK_Banks] PRIMARY KEY CLUSTERED
     [Bankid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    Groupmembers
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[GroupMembers](
     [GroupMemberid] [int] IDENTITY(1,1) NOT NULL,
     [Groupid] [int] NOT NULL,
     [BAID] [int] NOT NULL,
     [Createdby] [varchar](50) NULL,
     [Createdon] [datetime] NULL,
     CONSTRAINT [PK_GroupMembers] PRIMARY KEY CLUSTERED
     [GroupMemberid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    ALTER TABLE [dbo].[GroupMembers]  WITH CHECK ADD  CONSTRAINT [FK_GroupMembers_BankAccounts] FOREIGN KEY([BAID])
    REFERENCES [dbo].[BankAccounts] ([BAID])
    GO
    ALTER TABLE [dbo].[GroupMembers] CHECK CONSTRAINT [FK_GroupMembers_BankAccounts]
    GO
    ALTER TABLE [dbo].[GroupMembers]  WITH CHECK ADD  CONSTRAINT [FK_GroupMembers_Groups] FOREIGN KEY([Groupid])
    REFERENCES [dbo].[Groups] ([Groupid])
    GO
    ALTER TABLE [dbo].[GroupMembers] CHECK CONSTRAINT [FK_GroupMembers_Groups]
    BankAccounts
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[BankAccounts](
     [BAID] [int] IDENTITY(1,1) NOT NULL,
     [CustomerID] [int] NOT NULL,
     [Locationid] [varchar](25) NOT NULL,
     [Bankid] [int] NOT NULL,
     [BankAccountNo] [varchar](50) NOT NULL,
     CONSTRAINT [PK_BankAccounts] PRIMARY KEY CLUSTERED
     [BAID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    ALTER TABLE [dbo].[BankAccounts]  WITH CHECK ADD  CONSTRAINT [FK_BankAccounts_Banks] FOREIGN KEY([Bankid])
    REFERENCES [dbo].[Banks] ([Bankid])
    GO
    ALTER TABLE [dbo].[BankAccounts] CHECK CONSTRAINT [FK_BankAccounts_Banks]
    GO
    ALTER TABLE [dbo].[BankAccounts]  WITH CHECK ADD  CONSTRAINT [FK_BankAccounts_Locations1] FOREIGN KEY([Locationid])
    REFERENCES [dbo].[Locations] ([Locationid])
    GO
    ALTER TABLE [dbo].[BankAccounts] CHECK CONSTRAINT [FK_BankAccounts_Locations1]
    Currency
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[Currency](
     [Currencyid] [int] IDENTITY(1,1) NOT NULL,
     [CurrencyISOCode] [varchar](20) NOT NULL,
     [CurrencyCountry] [varchar](50) NULL,
     [Currency] [varchar](50) NULL,
     CONSTRAINT [PK_Currency] PRIMARY KEY CLUSTERED
     [Currencyid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    CurrencyDetails
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[CurrencyDetails](
     [CurDenid] [int] IDENTITY(1,1) NOT NULL,
     [Currencyid] [int] NOT NULL,
     [Denomination] [decimal](15, 3) NOT NULL,
     [DenominationType] [varchar](25) NOT NULL,
     CONSTRAINT [PK_CurrencyDetails] PRIMARY KEY CLUSTERED
     [CurDenid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    QUERY
    WITH TEMP_TABLE AS
    SELECT     0 AS COINS, BHDCollectionsDet.Quantity AS BN, BHDCollections.BHDDate AS CollectionDate, BHDCollectionsDet.Currencyid,
                          (BHDCollections.BHDCollectionid) AS DSLIPS, Banks.Bankname
    FROM         BHDCollections INNER JOIN
                          BHDCollectionsDet ON BHDCollections.BHDCollectionid = BHDCollectionsDet.BHDCollectionid INNER JOIN
                          GroupMembers ON BHDCollections.GroupMemberid = GroupMembers.GroupMemberid INNER JOIN
                          BankAccounts ON GroupMembers.BAID = BankAccounts.BAID INNER JOIN
                          Currency ON BHDCollectionsDet.Currencyid = Currency.Currencyid INNER JOIN
                          CurrencyDetails ON Currency.Currencyid = CurrencyDetails.Currencyid INNER JOIN
                          Banks ON BankAccounts.Bankid = Banks.Bankid
    GROUP BY BHDCollectionsDet.Quantity, BHDCollections.BHDDate, BankAccounts.Bankid, BHDCollectionsDet.Currencyid, CurrencyDetails.DenominationType,
                          CurrencyDetails.Denomination, BHDCollectionsDet.Denomination, Banks.Bankname,BHDCollections.BHDCollectionid
    HAVING      (BHDCollections.BHDDate BETWEEN @FromDate AND @ToDate) AND (BankAccounts.Bankid = @Bankid) AND (CurrencyDetails.DenominationType = 'Currency') AND
                          (CurrencyDetails.Denomination = BHDCollectionsDet.Denomination)
    UNION ALL
    SELECT     BHDCollectionsDet.Quantity AS COINS, 0 AS BN, BHDCollections.BHDDate AS CollectionDate, BHDCollectionsDet.Currencyid,
                          (BHDCollections.BHDCollectionid) AS DSLIPS, Banks.Bankname
    FROM         BHDCollections INNER JOIN
                          BHDCollectionsDet ON BHDCollections.BHDCollectionid = BHDCollectionsDet.BHDCollectionid INNER JOIN
                          GroupMembers ON BHDCollections.GroupMemberid = GroupMembers.GroupMemberid INNER JOIN
                          BankAccounts ON GroupMembers.BAID = BankAccounts.BAID INNER JOIN
                          Currency ON BHDCollectionsDet.Currencyid = Currency.Currencyid INNER JOIN
                          CurrencyDetails ON Currency.Currencyid = CurrencyDetails.Currencyid INNER JOIN
                          Banks ON BankAccounts.Bankid = Banks.Bankid
    GROUP BY BHDCollectionsDet.Quantity, BHDCollections.BHDDate, BankAccounts.Bankid, BHDCollectionsDet.Currencyid, CurrencyDetails.DenominationType,
                          CurrencyDetails.Denomination, BHDCollectionsDet.Denomination, Banks.Bankname,BHDCollections.BHDCollectionid
    HAVING      (BHDCollections.BHDDate BETWEEN @FromDate AND @ToDate) AND (BankAccounts.Bankid = @Bankid) AND (CurrencyDetails.DenominationType = 'COIN') AND
                          (CurrencyDetails.Denomination = BHDCollectionsDet.Denomination)),
    TEMP_TABLE2 AS
    SELECT CollectionDate,Bankname,DSLIPS AS DSLIPS,SUM(BN) AS BN,SUM(COINS)AS COINS  FROM TEMP_TABLE Group By CollectionDate,DSLIPS,Bankname
    SELECT CollectionDate,Bankname,count(DSLIPS) AS DSLIPS,sum(BN) AS BN,sum(COINS) AS coins FROM TEMP_TABLE2 Group By CollectionDate,Bankname
    HAVING COUNT(DSLIPS)<>0;

    Without seeing an execution plan of the query it is hard to suggest something useful. Try insert the result of UNION ALL to the temporary table and then perform an aggregation on that table, not a CTE.
    Just
    SELECT CollectionDate,Bankname,DSLIPS AS DSLIPS,SUM(BN) AS BN,SUM(COINS)AS COINS  FROM
    #tmp Group By CollectionDate,DSLIPS,Bankname
    HAVING COUNT(DSLIPS)<>0;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • When query is taking too long time

    When query is taking too long time,Where and how to start tuning it?
    Here i've listed few things need to be considered,out of my knowledge and understanding
    1.What the sql is waiting for(wait events)
    2.Parameter modification need to be done at system/session level
    3.The query has to be tuned (using hints )
    4.Gathering/deleting statistics
    List out any other things that need to be taken into account?
    Which approach must be followed and on what basis that approach must be considered?

    When query is taking too long time,Where and how to start tuning it?explain plan will be good start . trace also
    Here i've listed few things need to be considered,out of my knowledge and understanding
    1.What the sql is waiting for(wait events)When Oracle executes an SQL statement, it is not constantly executing. Sometimes it has to wait for a specific event to happen befor it can proceed.
    Read
    http://www.adp-gmbh.ch/ora/tuning/event.html
    2.Parameter modification need to be done at system/session levelDepend on parameter , define parameter , trace done on session level for example
    3.The query has to be tuned (using hints )Could be help you but you must know how to use .
    4.Gathering/deleting statisticsDo it in non working hours , it will impact on database performance , but its good
    List out any other things that need to be taken into account?Which account ?
    Which approach must be followed and on what basis that approach must be considered?you could use lot of tools , Trace , AWR

  • Why is this video render taking a long time?

    OS X Mavericks, Photoshop cc 2014, 2011 core i7 3.4 imac with 32GB ram, 256GB ssd scratch disk, 2GB video card.
    See images for layers setup, etc., and for export settings. Each 'slide' is a jpeg under a MB placed as smart object. Each lower third is about 2 MB placed as smart object.
    Render takes about 24 hours to complete. Why is this taking so long? I've tried this on other machines but they all take about the same time. Is there a better way to do this? Thanks, in advance, for your help!

    How long are the video clips and I see on at least one you have added a camera raw smart filter.   I do not know how a smart filter operates on a video clip. However if Photoshop need to renter a full frame for each video frame and filter each frame image with ACR then  encode the frames into a mp4 video stream it could be a very time consuming process  for nearly 170 thousand frames.  Have you tried encoding the mp4 without using the ACR smart filter adjustment? You also do not show the Timeline palette.

  • Connect by level query is taking too long time to run

    Hello,
    I have a query that returns quarters (YYYYQ) of a begin- and enddate within a specific id, that is built with a connect by level clause, but the query is running to long. I have used explain plan to see what the query is doing, but no silly things to see, just a full table scan, with low costs.
    This is the query:
    select to_char(add_months( cpj.crpj_start_date,3*(level - 1)),'YYYYQ') as sales_quarter
    , cpj.crpj_id as crpj_id
    from mv_gen_cra_projects cpj
    where cpj.crpj_start_date >= to_date('01/01/2009','mm/dd/yyyy')
    and cpj.crpj_start_date <= cpj.crpj_end_date
    and cpj.crpj_routing_type = 'A'
    and ( cpj.crpj_multi_artist_ind = 'N'
    or cpj.crpj_multi_artist_ind is null)
    connect by level <= 1 + ceil(months_between(cpj.crpj_end_date,cpj.crpj_start_date)/3);
    The result have to be like this:
    SALES_QUARTER CRPJ_ID
    20091 100
    20092 100
    20093 100
    20094 100
    20101 100
    20102 100
    Can anyone help me out with this?

    but no silly things to see, just a full table scan, with low costs.Well, maybe an index scan would be faster?
    However:
    You will need to provide us some more details, like:
    - database version (the result of: SQL> select * from v$version;)
    - post the explain plan output (put the tag before and after it, so indentation and formatting are maintained, see the [FAQ|http://forums.oracle.com/forums/help.jspa] for more explanation regarding tags )
    - what are your optimizer settings (the result of: SQL> show parameter optimizer)
    - if applicable: are your table statistics up to date?
    - mv_gen_cra_projects  is a materialized view perhaps?
    Edited by: hoek on Jan 26, 2010 10:50 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Query on Cube jumps to Query on ODS ; Query on ODS takes Long time

    Hi All,
    Perormance Issue:  Query on Cube jumps to Query on ODS.
    Query on ODS taking long time.(JumpQuery)  
    Specific to ODS Query: When i have checked the Query on ODS(individually) also taking longer time
    Actually ODS contains quite huge data. Indexes already maintained.
    I have checked the RSRT- Execute SQL and Debug Option also. Indexes maintained Perfectly .
    Order of objects in ODS indexes are matching the order of Objects in SQL stat of RSRT Trans. Inspite of that taking long time.
    I have checked both the ways jumpquery aswellas individually .
    My question is when the query is jumping from cube to query on ODS how to check the performance, how the query is executing in background when switching over to the second query, Moreover calculated keyfigure has been used for jumping to the target query.
    How can query(ods query)  time is optimized or improve performance when jumping  from query on Cube ?
    can any body help?
    Rgds,
    C.V.
    Message was edited by:
            C.V. P

    What i understand is that you need to optimise the Query jumping time . But this will be very less compared to the time taken by the query on the ODS.
    Ideally you shouldnt be making a BEx Query on the ODS , as this takes a long time. What you can do is try executing the Bex Query on the ODS to find out as to where the issue lies. If this query is taking a long time , there is not muich that you can do here.

  • Hyperion Report taking a long time to process local query

    Hi All,
    I am trying to run a report on Hyperion IR 9.3.1. I am facing a performance issue with this report. I am joining 13 tables using full outer join. Each table is having data about 900 rows and the final output i am getting from the local query is about 11000 rows. This local query is taking a long time to get process about 3 - 5 minutes. I suppose it should run with in 30 sec as number of rows are very few. Can anyone tell me what is the problem with this local query and how the performance of the report can be increased?
    Thanks in advance.
    Regards
    Ujjawal

    Be aware that XP takes approx 1gb of your RAM leaving you with 1gb for whatever else is running. MS Outlook is also a memory hog.
    To check Virtual Memory Settings:
    Control Panel -> System
    System Properties -> Advanced Tab -> Performance Settings
    Performance Options -> Adavanced Tab - Virtual Memory section
    Virtual Memory -
    what are
    * Initial Size
    * Maximum Size
    In a presentation at one of the Hyperion conferences years ago, Mark Ostroff suggested that the initial be set to the same as Max. (Max is typically 2x physical RAM)
    These changes may provide some improvement.

  • Query taking very long time

    DB 11.2.0.3.4
    Server HP-UX IA 11.31
    One big query is taking very long time. I am giving the explain plan along with stats from tkprof. If needed will give the query also. Can sombody tell me how can we improve this.
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1     23.26      23.90          0         20          0           0
    Execute      1   8055.11    9453.52     684215     348696   18750740     1306001
    Fetch        0      0.00       0.00          0          0          0           0
    total        2   8078.37    9477.42     684215     348716   18750740     1306001
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 322  (EDW_DM)   (recursive depth: 1)
    Rows     Row Source Operation
          0  LOAD TABLE CONVENTIONAL  (cr=352254 pr=684215 pw=682074 time=863655932 us)
    1306001   PX COORDINATOR  (cr=15823 pr=682074 pw=682074 time=499947892 us)
          0    PX SEND QC (RANDOM) :TQ20004 (cr=0 pr=0 pw=0 time=0 us cost=276195 size=126736955032 card=9998182)
          0     BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0      VIEW  VW_FCT_PLN_SUMM_ADL_WK_XARH317 (cr=0 pr=0 pw=0 time=0 us cost=276195 size=126736955032 card=9998182)
          0       UNION-ALL  (cr=0 pr=0 pw=0 time=0 us)
          0        SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us cost=9167 size=95469948 card=378849)
          0         PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=9167 size=95469948 card=378849)
          0          PX SEND HASH :TQ20003 (cr=0 pr=0 pw=0 time=0 us cost=9167 size=95469948 card=378849)
          0           SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us cost=9167 size=95469948 card=378849)
          0            HASH JOIN RIGHT SEMI (cr=0 pr=0 pw=0 time=0 us cost=2714 size=95469948 card=378849)
          0             BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0              PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=26 size=16428 card=4107)
          0               PX SEND BROADCAST :TQ20000 (cr=0 pr=0 pw=0 time=0 us cost=26 size=16428 card=4107)
       4857                VIEW  VW_SQ_1 (cr=47 pr=0 pw=0 time=25403 us cost=26 size=16428 card=4107)
       4857                 HASH JOIN  (cr=47 pr=0 pw=0 time=23353 us cost=26 size=229992 card=4107)
       1115                  TABLE ACCESS FULL DMN_PROD (cr=11 pr=0 pw=0 time=863 us cost=6 size=13380 card=1115)
       4873                  HASH JOIN  (cr=36 pr=0 pw=0 time=12991 us cost=20 size=180840 card=4110)
         55                   TABLE ACCESS FULL DMN_MKT_DEFN (cr=3 pr=0 pw=0 time=286 us cost=4 size=1980 card=55)
      18235                   TABLE ACCESS FULL FCT_MKT_PROD_BRDG (cr=33 pr=0 pw=0 time=13550 us cost=15 size=145880 card=18235)
          0             HASH JOIN  (cr=0 pr=0 pw=0 time=0 us cost=2686 size=93954552 card=378849)
          0              BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0               PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=111 size=403328 card=8768)
          0                PX SEND BROADCAST :TQ20001 (cr=0 pr=0 pw=0 time=0 us cost=111 size=403328 card=8768)
       8768                 NESTED LOOPS  (cr=274 pr=0 pw=0 time=15077 us cost=111 size=403328 card=8768)
          1                  NESTED LOOPS  (cr=5 pr=0 pw=0 time=203 us cost=5 size=28 card=1)
          1                   TABLE ACCESS FULL DMN_WK_END (cr=2 pr=0 pw=0 time=81 us cost=3 size=8 card=1)
          1                   TABLE ACCESS BY INDEX ROWID DMN_CALN (cr=3 pr=0 pw=0 time=110 us cost=2 size=20 card=1)
          1                    INDEX RANGE SCAN XNU1_DMN_CALN (cr=2 pr=0 pw=0 time=73 us cost=1 size=0 card=1)(object id 303867)
       8768                  TABLE ACCESS FULL DMN_CALN (cr=269 pr=0 pw=0 time=11719 us cost=106 size=157824 card=8768)
          0              PX BLOCK ITERATOR PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=2573 size=76527498 card=378849)
          0               TABLE ACCESS FULL FCT_NONRET_SLS_CURR_TRANS_WKLY PARTITION: 32 32 (cr=0 pr=0 pw=0 time=0 us cost=2573 size=76527498 card=378849)
          0        BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0         PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=267028 size=2741509905 card=9619333)
          0          PX SEND ROUND-ROBIN :TQ20002 (cr=0 pr=0 pw=0 time=0 us cost=267028 size=2741509905 card=9619333)
    1284599           SORT GROUP BY (cr=15497 pr=682074 pw=682074 time=3839060439 us cost=267028 size=2741509905 card=9619333)
    6439189            FILTER  (cr=15486 pr=0 pw=0 time=57890179 us)
    8986531             PX COORDINATOR  (cr=279 pr=0 pw=0 time=52453034 us)
          0              PX SEND QC (RANDOM) :TQ10001 (cr=0 pr=0 pw=0 time=0 us cost=80940 size=2741509905 card=9619333)
          0               HASH JOIN  (cr=0 pr=0 pw=0 time=0 us cost=80940 size=2741509905 card=9619333)
          0                BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0                 PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=111 size=403328 card=8768)
          0                  PX SEND BROADCAST :TQ10000 (cr=0 pr=0 pw=0 time=0 us cost=111 size=403328 card=8768)
       8768                   NESTED LOOPS  (cr=274 pr=0 pw=0 time=14462 us cost=111 size=403328 card=8768)
          1                    NESTED LOOPS  (cr=5 pr=0 pw=0 time=345 us cost=5 size=28 card=1)
          1                     TABLE ACCESS FULL DMN_WK_END (cr=2 pr=0 pw=0 time=193 us cost=3 size=8 card=1)
          1                     TABLE ACCESS BY INDEX ROWID DMN_CALN (cr=3 pr=0 pw=0 time=136 us cost=2 size=20 card=1)
          1                      INDEX RANGE SCAN XNU1_DMN_CALN (cr=2 pr=0 pw=0 time=76 us cost=1 size=0 card=1)(object id 303867)
       8768                    TABLE ACCESS FULL DMN_CALN (cr=269 pr=0 pw=0 time=9447 us cost=106 size=157824 card=8768)
          0                PX BLOCK ITERATOR PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=80801 size=2299020587 card=9619333)
          0                 TABLE ACCESS FULL FCT_PLN_RET_SLS_CURR_WKLY PARTITION: 30 30 (cr=0 pr=0 pw=0 time=0 us cost=80801 size=2299020587 card=9619333)
        834             NESTED LOOPS  (cr=15207 pr=0 pw=0 time=990747 us)
       2269              NESTED LOOPS  (cr=12938 pr=0 pw=0 time=1090852 us cost=17 size=56 card=1)
       2269               NESTED LOOPS  (cr=12101 pr=0 pw=0 time=1065238 us cost=16 size=20 card=1)
        834                TABLE ACCESS BY INDEX ROWID DMN_PROD (cr=1676 pr=0 pw=0 time=37175 us cost=1 size=12 card=1)
        838                 INDEX UNIQUE SCAN XPKDIMENSION_PRODUCT (cr=838 pr=0 pw=0 time=23645 us cost=0 size=0 card=1)(object id 303870)
       2269                TABLE ACCESS FULL FCT_MKT_PROD_BRDG (cr=10425 pr=0 pw=0 time=1024973 us cost=15 size=8 card=1)
       2269               INDEX UNIQUE SCAN SYS_C0040182 (cr=837 pr=0 pw=0 time=15842 us cost=0 size=0 card=1)(object id 301873)
        834              TABLE ACCESS BY INDEX ROWID DMN_MKT_DEFN (cr=2269 pr=0 pw=0 time=16488 us cost=1 size=36 card=1)
    It would be appreciated if somebody check this.
    Regards,
    Virendra

    Below is with the index on one of the table:
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1     49.33      49.61          0         16          0           0
    Execute      1   8374.08   10745.82     953712     473861   18818854     1306001
    Fetch        0      0.00       0.00          0          0          0           0
    total        2   8423.41   10795.43     953712     473877   18818854     1306001
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 322     (recursive depth: 1)
    Rows     Row Source Operation
          0  LOAD TABLE CONVENTIONAL  (cr=481416 pr=953712 pw=917687 time=2156047932 us)
    1306001   PX COORDINATOR  (cr=131828 pr=917687 pw=917687 time=1528317728 us)
          0    PX SEND QC (RANDOM) :TQ10004 (cr=0 pr=0 pw=0 time=0 us cost=144212 size=16362383616 card=1290816)
          0     BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0      VIEW  VW_FCT_PLN_SUM_ADL_WK_XRH317_1 (cr=0 pr=0 pw=0 time=0 us cost=144212 size=16362383616 card=1290816)
          0       UNION-ALL  (cr=0 pr=0 pw=0 time=0 us)
          0        SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us cost=9568 size=101394468 card=402359)
          0         PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=9568 size=101394468 card=402359)
          0          PX SEND HASH :TQ10003 (cr=0 pr=0 pw=0 time=0 us cost=9568 size=101394468 card=402359)
          0           SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us cost=9568 size=101394468 card=402359)
          0            HASH JOIN RIGHT SEMI (cr=0 pr=0 pw=0 time=0 us cost=2714 size=101394468 card=402359)
          0             BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0              PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=26 size=16428 card=4107)
          0               PX SEND BROADCAST :TQ10000 (cr=0 pr=0 pw=0 time=0 us cost=26 size=16428 card=4107)
       4857                VIEW  VW_SQ_1 (cr=47 pr=0 pw=0 time=25732 us cost=26 size=16428 card=4107)
       4857                 HASH JOIN  (cr=47 pr=0 pw=0 time=23041 us cost=26 size=229992 card=4107)
       1115                  TABLE ACCESS FULL DMN_PROD (cr=11 pr=0 pw=0 time=1040 us cost=6 size=13380 card=1115)
       4873                  HASH JOIN  (cr=36 pr=0 pw=0 time=12797 us cost=20 size=180840 card=4110)
         55                   TABLE ACCESS FULL DMN_MKT_DEFN (cr=3 pr=0 pw=0 time=185 us cost=4 size=1980 card=55)
      18235                   TABLE ACCESS FULL FCT_MKT_PROD_BRDG (cr=33 pr=0 pw=0 time=10014 us cost=15 size=145880 card=18235)
          0             HASH JOIN  (cr=0 pr=0 pw=0 time=0 us cost=2686 size=99785032 card=402359)
          0              BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0               PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=111 size=403328 card=8768)
          0                PX SEND BROADCAST :TQ10001 (cr=0 pr=0 pw=0 time=0 us cost=111 size=403328 card=8768)
       8768                 NESTED LOOPS  (cr=274 pr=0 pw=0 time=13429 us cost=111 size=403328 card=8768)
          1                  NESTED LOOPS  (cr=5 pr=0 pw=0 time=206 us cost=5 size=28 card=1)
          1                   TABLE ACCESS FULL DMN_WK_END (cr=2 pr=0 pw=0 time=82 us cost=3 size=8 card=1)
          1                   TABLE ACCESS BY INDEX ROWID DMN_CALN (cr=3 pr=0 pw=0 time=111 us cost=2 size=20 card=1)
          1                    INDEX RANGE SCAN XNU1_DMN_CALN (cr=2 pr=0 pw=0 time=80 us cost=1 size=0 card=1)(object id 303867)
       8768                  TABLE ACCESS FULL DMN_CALN (cr=269 pr=0 pw=0 time=9306 us cost=106 size=157824 card=8768)
          0              PX BLOCK ITERATOR PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us cost=2573 size=81276518 card=402359)
          0               TABLE ACCESS FULL FCT_NONRET_SLS_CURR_TRANS_WKLY PARTITION: 32 32 (cr=0 pr=0 pw=0 time=0 us cost=2573 size=81276518 card=402359)
          0        BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
          0         PX RECEIVE  (cr=0 pr=0 pw=0 time=0 us cost=134645 size=256764073 card=888457)
          0          PX SEND ROUND-ROBIN :TQ10002 (cr=0 pr=0 pw=0 time=0 us cost=134645 size=256764073 card=888457)
    1284599           HASH GROUP BY (cr=131502 pr=917687 pw=917687 time=1052831032 us cost=134645 size=256764073 card=888457)
    6439189            HASH JOIN RIGHT SEMI (cr=131490 pr=138092 pw=138092 time=374140098 us cost=100193 size=256764073 card=888457)
       4857             VIEW  VW_SQ_2 (cr=47 pr=0 pw=0 time=22869 us cost=26 size=16428 card=4107)
       4857              HASH JOIN  (cr=47 pr=0 pw=0 time=21073 us cost=26 size=229992 card=4107)
       1115               TABLE ACCESS FULL DMN_PROD (cr=11 pr=0 pw=0 time=687 us cost=6 size=13380 card=1115)
       4873               HASH JOIN  (cr=36 pr=0 pw=0 time=12522 us cost=20 size=180840 card=4110)
         55                TABLE ACCESS FULL DMN_MKT_DEFN (cr=3 pr=0 pw=0 time=242 us cost=4 size=1980 card=55)
      18235                TABLE ACCESS FULL FCT_MKT_PROD_BRDG (cr=33 pr=0 pw=0 time=9883 us cost=15 size=145880 card=18235)
    8986531             HASH JOIN  (cr=131443 pr=138092 pw=138092 time=402921160 us cost=100161 size=253210245 card=888457)
       8768              TABLE ACCESS FULL DMN_CALN (cr=269 pr=0 pw=0 time=11228 us cost=106 size=157824 card=8768)
    8986531              MERGE JOIN CARTESIAN (cr=131174 pr=138092 pw=138092 time=382931385 us cost=100049 size=237218019 card=888457)
          1               NESTED LOOPS  (cr=5 pr=0 pw=0 time=251 us)
          1                NESTED LOOPS  (cr=4 pr=0 pw=0 time=225 us cost=5 size=28 card=1)
          1                 TABLE ACCESS FULL DMN_WK_END (cr=2 pr=0 pw=0 time=127 us cost=3 size=8 card=1)
          1                 INDEX RANGE SCAN XNU1_DMN_CALN (cr=2 pr=0 pw=0 time=88 us cost=1 size=0 card=1)(object id 303867)
          1                TABLE ACCESS BY INDEX ROWID DMN_CALN (cr=1 pr=0 pw=0 time=17 us cost=2 size=20 card=1)
    8986531               BUFFER SORT (cr=131169 pr=138092 pw=138092 time=378126634 us cost=100047 size=212341223 card=888457)
    8986531                TABLE ACCESS BY GLOBAL INDEX ROWID FCT_PLN_RET_SLS_CURR_WKLY PARTITION: 30 30 (cr=131157 pr=0 pw=0 time=144384133 us cost=100044 size=212341223 card=888457)
    9066976                 INDEX RANGE SCAN SUBSTR_FCT_RET_SLS_CUR_WLY (cr=84385 pr=0 pw=0 time=93762049 us cost=83615 size=0 card=2856894)(object id 311617)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      os thread startup                               2        0.08          0.15
      PX Deq: Join ACK                                4        0.00          0.00
      PX Deq Credit: send blkd                      455        2.21         55.10
      PX Deq: Parse Reply                             4        0.01          0.01
      PX Deq: Execute Reply                      250046      247.89        439.12
      asynch descriptor resize                        9        0.00          0.00
      PX Deq Credit: need buffer                    549        1.54         15.84
      PX qref latch                                 235        0.01          0.18
      Disk file operations I/O                       42        0.00          0.00
      direct path write temp                      62665        0.25        365.50
      direct path read temp                       99442        0.46       1024.89
      db file sequential read                     36025        0.15        186.86
      latch: object queue header operation           17        0.00          0.00
      latch free                                      2        0.00          0.00
      log file switch (private strand flush incomplete)
                                                      1        0.07          0.07
      latch: messages                                 1        0.00          0.00
      log file switch completion                     14        0.08          0.79
      latch: cache buffers chains                     2        0.00          0.00
      latch: redo allocation                          1        0.00          0.00
      PX Deq: Signal ACK RSG                          4        0.06          0.07
      PX Deq: Signal ACK EXT                          4        0.00          0.01
      PX Deq: Slave Session Stats                     4        0.00          0.00
      enq: PS - contention                            1        0.00          0.00

  • Sql Query taking very long time to complete

    Hi All,
    DB:oracle 9i R2
    OS:sun solaris 8
    Below is the Sql Query taking very long time to complete
    Could any one help me out regarding this.
    SELECT MAX (md1.ID) ID, md1.request_id, md1.jlpp_transaction_id,
    md1.transaction_version
    FROM transaction_data_arc md1
    WHERE md1.transaction_name = :b2
    AND md1.transaction_type = 'REQUEST'
    AND md1.message_type_code = :b1
    AND NOT EXISTS (
    SELECT NULL
    FROM transaction_data_arc tdar2
    WHERE tdar2.request_id = md1.request_id
    AND tdar2.jlpp_transaction_id != md1.jlpp_transaction_id
    AND tdar2.ID > md1.ID)
    GROUP BY md1.request_id,
    md1.jlpp_transaction_id,
    md1.transaction_version
    Any alternate query to get the same results?
    kindly let me know if any one knows.
    regards,
    kk.
    Edited by: kk001 on Apr 27, 2011 11:23 AM

    Dear
    /* Formatted on 2011/04/27 08:32 (Formatter Plus v4.8.8) */
    SELECT   MAX (md1.ID) ID, md1.request_id, md1.jlpp_transaction_id,
             md1.transaction_version
        FROM transaction_data_arc md1
       WHERE md1.transaction_name = :b2
         AND md1.transaction_type = 'REQUEST'
         AND md1.message_type_code = :b1
         AND NOT EXISTS (
                SELECT NULL
                  FROM transaction_data_arc tdar2
                 WHERE tdar2.request_id = md1.request_id
                   AND tdar2.jlpp_transaction_id != md1.jlpp_transaction_id
                   AND tdar2.ID > md1.ID)
    GROUP BY md1.request_id
            ,md1.jlpp_transaction_id
            ,md1.transaction_versionCould you please post here :
    (a) the available indexes on transaction_data_arc table
    (b) the description of transaction_data_arc table
    (c) and the formatted explain plan you will get after executing the query and issuing:
    select * from table (dbms_xplan.display_cursor);Hope this helps
    Mohamed Houri

  • Transferring to my new iMac from my MacBook is taking a long time. Is this normal?

    Transferring from my old MacBook to my me iMac is taking a long time. Is this normal?

    See Pondini's Setup New Mac guide for starters.

  • Simple query taking so long time to run

    Below are the queries which are taking very long time to run. It pulls 4 million records approx on first query.
    How can it run fast?
    Thank you.
    SELECTPerson_DEID[CP1] ,
    Admit_DT,
    Discharge_DT, DRG_CD,
    cast (LineAllowedAmount
    AS money)
    as FacAA
    into
    FOET
    FROMdbo.mh_fac_claims_final[CP2] 
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    LineAllowedAmount;
    go
    select
    Person_DEID,
    Admit_DT, Discharge_DT,
    DRG_CD, sum(facAA)
    as FacAA_SUM[CP3] 
    from
    dbo.FOET
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    facAA;

    Below are the queries which are taking very long time to run. It pulls 4 million records approx on first query.
    How can it run fast?
    Thank you.
    SELECTPerson_DEID[CP1] ,
    Admit_DT,
    Discharge_DT, DRG_CD,
    cast (LineAllowedAmount
    AS money)
    as FacAA
    into
    FOET
    FROMdbo.mh_fac_claims_final[CP2] 
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    LineAllowedAmount;
    go
    select
    Person_DEID,
    Admit_DT, Discharge_DT,
    DRG_CD, sum(facAA)
    as FacAA_SUM[CP3] 
    from
    dbo.FOET
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    facAA;
    select    Person_DEID,Admit_DT,Discharge_DT,DRG_CD, convert(money,sum(LineAllowedAmount)) as FacAA_SUM[CP3] 
    into FOET
    FROM dbo.mh_fac_claims_final[CP2] 
    group by Person_DEID, Admit_DT, Discharge_DT, DRG_CD
    There is no grouping, u are calculating 4m records in second query. Maybe try above instead (already suggested)? Can u check how long above query takes to run?

  • Discoverer reports taking a long time!!!

    Hi all,
    One of our clients is complaining that the discoverer reports are taking a long time to run for the last few days, the report used to take 30 minutes before but now is running for hours!!
    I have checked the SGA and I have killed the idle sessions but still there was no improvement in the performance.
    The version of BI discoverer is 10 and database also is 10g and the platform is win server 2003.
    I have checked the forums and they talk about explain plan and tkprof and other commands, but my problem is that i am unable to find the query that discoverer is running i mean once the report is clicked the query runs and gives the estimate time it would take. can some one tell me where this query is stored so that i can check this query,
    Also there were no changes made in the query or to the database.
    The temp space fills up 100%, i increased the size of temp space but still it goes to 100% also i noticed that the CPU utilisation goes to 100%
    i also increased the SGA but still no go.
    can someone kindly help me as to what could be causing this problem
    also kindly guide me to some good documents for tuning the discoverer.
    thanks in advance,
    regards,
    Edited by: user10243788 on Jan 4, 2010 12:47 AM

    Hi,
    The fact that the report used to work fast and now not can be related to many things but my guess is that the database statistics were changed and so the explain plan has changed.
    This can be done due to change in the volume of the data that crossed a level were oracle optimizer change the behavior but it can be other things as well.
    Anyway it is not relevant since it will be easier to tune the SQL than to find what have changed.
    In order to find whether the problem is with the discoverer or in the SQL extract the SQL as described above and run it in SQL tool (SQL Plus, TOAD, SQL Developer and so on).
    The best way to get to the problem is run a trace on your session and then use the TKPROF command to translate it to a text file you can analyze - you can assist your DBA team they should have no problem doing that.
    By doing that you will get the problematic statements/ functions/ procedures that the report uses.
    From there you can start working on improving the performance.
    Performance is expertise for itself so i'm sorry i don't know to tell you where to start from, I guess the start will be from understanding the meaning of the explain plan.
    Hope I helped a little although I wish Ii had a magic answer for you
    BTW, until you resolve that problem you can use the discoverer scheduler to run the reports in the background and so the users will get the data.
    Tamir

  • Rank Function taking a long time to execute in SAP HANA

    Hi All,
    I have a couple of reports with rank function which is timing out/ or taking a really long time to execute, Is there any way to get the result in less time when rank functions are involved?
    the following is a sample of how the Query looks,
    SQL 1:
    select      a.column1,
                    b.column1,
                    rank () over(partition by a.column1 order by sum(b.column2) asc)
    from         "_SYS_BIC"."Analyticview1"         b
                    join          "Table1"            a
                      on          (a.column2 = b.column3)
    group by  a.column1,
    b.column1;
    SQL 2:
    select    a.column1,
                    b.column1,
                    rank () over( order by min(b.column1) asc) WJXBFS1
    from         "_SYS_BIC"."Analytic view2"         b
                    cross join                "Table 2"               a
    where      (a.column2  like '%a%'
    and b.column1  between 100 and 200)
    group by  a.column1,
                    b.column1
    when I visualize the execution plan,the rank function is the one taking up a longer time frame. so I executed the same SQL without the rank() or partition or order by(only with Sum() in SQL1 and Min() in SQL 2) even that took a around an hour to get the result.
    1.Does anyone have an any idea to make these queries to execute faster?
    2. Does the latency have anything to do with the rank function or could it be size of the result set?
    3. is there any workaround to implement these rank function/partition inside the Analytic view itself? if yes, will this make it give the result faster?
    Thank you for your help!!
    -Gayathri

    Krishna,
    I tried both of them, Graphical and CE function,
    It is also taking a long time to execute
    Graphical view giving me the following error after 2 hr and 36 minutes
    Could not execute 'SELECT ORDER_ID,ITEM_ID,RANK from "_SYS_BIC"."EMMAPERF/ORDER_FACT_HANA_CV" group by ...' in 2:36:23.411 hours .
    SAP DBTech JDBC: [2048]: column store error: search table error:  [2620] executor: plan operation failed
    CE function - I aborted after 40 mins
    Do you know the syntax to declare local variable to use in CE function?

  • Explain plan generating it self taking very long time !!! What to do ?

    Hi,
    I am trying to generate explain plan for a query which is running more than 2 hours. I am trying to generate explain plan for query by "explin plan for select ..." but it self is taking very long time.
    Kindly suggest me how to reduce time for explain plan ? Secondly why explain plan itself taking very long time ?
    thanks & regards
    PKP

    Just guessing here, but I've experienced this behaviour when I did two explain's within a second. This is because a plan is identified by a statement_id or, if you don't provide a statement_id, by the timestamp (of DATE datatype). So if you execute two explain plans within the second (using a script), it has two sets of data with the same primary key. The hierarchical query that needs to be executed to provide you the nicely indented text, will exponentially expand in this case.
    Maybe time to clean up your plan_table ?
    Hope this helps.
    Regards,
    Rob.

  • Discoverer report taking too long time to open.

    HI,
    Discovere reports are taking too long time to open. Please help to resolve this.
    Regards,
    Bhatia

    What is the Dicoverer and the Application release?
    Please refer to the following links (For both Discoverer 4i and 10g). Please note that some Discoverer 4i notes also apply to Discoverer 10g.
    Note: 362851.1 - Guidelines to setup the JVM in Apps Ebusiness Suite 11i and R12
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=362851.1
    Note: 68100.1 - Discoverer Performance When Running On Oracle Applications
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=68100.1
    Note: 465234.1 - Recommended Client Java Plug-in (JVM/JRE) For Discoverer Plus 10g (10.1.2)
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=465234.1
    Note: 329674.1 - Slow Performance When Opening Plus Workbooks from Oracle 11.5.10 Applications Home Page
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=329674.1
    Note: 190326.1 - Ideas for Improving Discoverer 4i Performance in an Applications 11i Environment
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=190326.1
    Note: 331435.1 - Slow Perfomance Using Disco 4.1 Admin/Desktop in Oracle Applications Mode EUL
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=331435.1
    Note: 217669.1 - Refreshing Folders and opening workbooks is slow in Apps 11i environment
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=217669.1

Maybe you are looking for