Query too long

Hi,
I try to optimze this statement but i find no way.
SQL> select * from v$version;
BANNER
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 1
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 1
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
==============
Statement to optimize
==============
SELECT /*+ ALL_ROWS */
T28.CONFLICT_ID,
T28.LAST_UPD,
T28.CREATED,
T28.LAST_UPD_BY,
T28.CREATED_BY,
T28.MODIFICATION_NUM,
T28.ROW_ID,
T19.ACTL_START_DT,
T19.ACTL_END_DT,
T19.PLAN_START_DT,
T19.PLAN_END_DT,
T18.BL_CLASS_CD,
T28.PR_ORDER_ID,
T21.FORMAT_TYPE_CD,
T28.TARGET_OU_ADDR_ID,
T28.TODO_AFTER_DT,
T4.FST_NAME,
T4.LAST_NAME,
T28.ACTIVITY_UID,
T28.PROJ_ID,
T18.NAME,
T28.PREV_ACT_ID,
T28.PR_ATT_ID,
T2.STAGE_ID,
T25.SEBL_APPT_FLG,
T28.APPT_START_DT,
T27.NAME,
T28.TODO_ACTL_START_DT,
T28.CAL_DISP_FLG,
T28.APPT_REPT_FLG,
T28.APPT_REPT_END_DT,
T28.SRA_SR_ID,
T28.ALARM_FLAG,
T28.SRA_DEFECT_ID,
T28.OPTY_ID,
T28.NAME,
T28.TODO_PLAN_START_DT,
T28.TODO_ACTL_END_DT,
T28.PAR_EVT_ID,
T28.SRC_ID,
T28.COST_CURCY_CD,
T28.TARGET_PER_ID,
T28.APPT_REPT_APPT_ID,
T28.APPT_REPT_REPL_CD,
T28.TODO_PLAN_END_DT,
T28.PCT_COMPLETE,
T28.DONE_FLG,
T28.BILLABLE_FLG,
T28.AGREEMENT_ID,
T28.APPT_ALARM_TM_MIN,
T28.TARGET_OU_ID,
T13.LOC,
T13.X_NAME,
T28.APPT_DURATION_MIN,
T25.PIM_APPT_FLG,
T25.UNSPRTD_REPT_FLG,
T2.ACTIVE_FLG,
T2.SRM_REQUEST_ID,
T28.TEMPLATE_FLG,
T28.ASSET_ID,
T28.PR_SYMPTOM_CD,
T5.FST_NAME,
T5.LAST_NAME,
T28.OWNER_LOGIN,
T28.OWNER_PER_ID,
T28.WORK_TM_MIN,
T9.OWN_INST_ID,
T9.INTEGRATION_ID,
T18.PROJ_NUM,
T13.BASE_CURCY_CD,
T18.BL_CURCY_CD,
T27.CURCY_CD,
T24.SRV_REGN_ID,
T28.X_NUMBER_DAYS,
T1.X_DAILY_WORK_TIME,
T28.X_CALC_DURATION_FLG,
T8.STD_SRV_CAL_ID,
T3.ATTRIB_09,
T24.SRV_REGN_ID,
T10.AGREE_ID,
T16.PAR_AGREE_ID,
T7.AGREE_NUM,
T7.TARGET_OU_ID,
T14.X_NAME,
T28.X_TEAM_LEAD_FLG,
T28.X_SUB_INV_FLG,
T1.X_LUNCH_TIME,
T26.PR_PER_ADDR_ID,
T12.CITY,
T7.INTEGRATION_ID,
T28.X_PERFORMING_BU_ID,
T7.CON_PER_ID,
T10.PAR_SR_ID,
T10.CST_OU_ID,
T28.X_WORK_TM,
T16.AGREE_ITEM_ID,
T5.EMAIL_ADDR,
T13.X_MOBILE_FLG,
T28.X_ACTUAL_AST_DUR,
T28.X_RECERTIF_TO_AWI_FLG,
T28.X_ASSET_GROUP_FLG,
T28.X_RECURRING_FLG,
T28.X_REPORT_DUE_IN_DAYS,
T28.X_REPORT_NEEDED_FLG,
T28.X_REVIEW_NEEDED_FLG,
T10.SRV_REGN_ID,
T28.X_ADDITIONAL_ROLE,
T28.CAL_TYPE_CD,
T28.EVT_STAT_CD,
T28.APPT_REPT_TYPE,
T28.TODO_CD,
T7.STAT_CD,
T28.X_SUB_TYPE,
T12.COUNTRY,
T14.CUST_STAT_CD,
T11.ROW_STATUS,
T22.LOGIN,
T23.ROW_ID,
T15.WORK_PH_NUM,
T2.ROW_ID,
T2.PAR_ROW_ID,
T2.MODIFICATION_NUM,
T2.CREATED_BY,
T2.LAST_UPD_BY,
T2.CREATED,
T2.LAST_UPD,
T2.CONFLICT_ID,
T2.PAR_ROW_ID,
T21.ROW_ID,
T21.PAR_ROW_ID,
T21.MODIFICATION_NUM,
T21.CREATED_BY,
T21.LAST_UPD_BY,
T21.CREATED,
T21.LAST_UPD,
T21.CONFLICT_ID,
T21.PAR_ROW_ID,
T9.ROW_ID,
T9.PAR_ROW_ID,
T9.MODIFICATION_NUM,
T9.CREATED_BY,
T9.LAST_UPD_BY,
T9.CREATED,
T9.LAST_UPD,
T9.CONFLICT_ID,
T9.PAR_ROW_ID,
T25.ROW_ID,
T25.PAR_ROW_ID,
T25.MODIFICATION_NUM,
T25.CREATED_BY,
T25.LAST_UPD_BY,
T25.CREATED,
T25.LAST_UPD,
T25.CONFLICT_ID,
T25.PAR_ROW_ID,
T11.ROW_ID,
T23.ROW_ID,
T20.ROW_ID
FROM
SIEBEL.S_SCHED_CAL T1,
SIEBEL.S_EVT_MKTG T2,
SIEBEL.S_ORG_EXT_X T3,
SIEBEL.S_CONTACT T4,
SIEBEL.S_CONTACT T5,
SIEBEL.S_LST_OF_VAL T6,
SIEBEL.S_DOC_AGREE T7,
SIEBEL.S_SRV_REGN T8,
SIEBEL.S_EVT_ACT_SS T9,
SIEBEL.S_SRV_REQ T10,
SIEBEL.S_ACT_EMP T11,
SIEBEL.S_ADDR_PER T12,
SIEBEL.S_ORG_EXT T13,
SIEBEL.S_ORG_EXT T14,
SIEBEL.S_CONTACT T15,
SIEBEL.S_ENTLMNT T16,
SIEBEL.S_POSTN T17,
SIEBEL.S_PROJ T18,
SIEBEL.S_PROJITEM T19,
SIEBEL.S_PARTY T20,
SIEBEL.S_EVT_MAIL T21,
SIEBEL.S_USER T22,
SIEBEL.S_PARTY T23,
SIEBEL.S_EMP_PER T24,
SIEBEL.S_EVT_CAL T25,
SIEBEL.S_CONTACT T26,
SIEBEL.S_OPTY T27,
SIEBEL.S_EVT_ACT T28
WHERE
T28.PROJ_ITEM_ID = T19.ROW_ID (+) AND
T28.OWNER_PER_ID = T5.PAR_ROW_ID (+) AND
T28.OWNER_PER_ID = T24.PAR_ROW_ID (+) AND
T10.AGREE_ID = T16.ROW_ID (+) AND
T28.AGREEMENT_ID = T7.ROW_ID (+) AND
T7.TARGET_OU_ID = T14.PAR_ROW_ID (+) AND
T28.OWNER_PER_ID = T26.ROW_ID (+) AND
T26.PR_PER_ADDR_ID = T12.ROW_ID (+) AND
T28.TARGET_OU_ID = T13.PAR_ROW_ID (+) AND
T28.OPTY_ID = T27.ROW_ID (+) AND
T28.TARGET_PER_ID = T4.PAR_ROW_ID (+) AND
T28.SRA_SR_ID = T10.ROW_ID (+) AND
T28.PROJ_ID = T18.ROW_ID (+) AND
T24.SRV_REGN_ID = T8.ROW_ID (+) AND
T8.STD_SRV_CAL_ID = T1.ROW_ID (+) AND
T5.PR_HELD_POSTN_ID = T17.ROW_ID (+) AND
T17.OU_ID = T3.PAR_ROW_ID (+) AND
T28.ROW_ID = T2.PAR_ROW_ID (+) AND
T28.ROW_ID = T21.PAR_ROW_ID (+) AND
T28.ROW_ID = T9.PAR_ROW_ID (+) AND
T28.ROW_ID = T25.PAR_ROW_ID (+) AND
T28.CAL_TYPE_CD = T6.NAME (+) AND T6.TYPE (+) = 'ACTIVITY_DISPLAY_CODE' AND T6.LANG_ID (+) = 'ENU' AND
T28.OWNER_PER_ID = T11.EMP_ID (+) AND T28.ROW_ID = T11.ACTIVITY_ID (+) AND
T28.OWNER_PER_ID = T23.ROW_ID (+) AND
T28.OWNER_PER_ID = T22.PAR_ROW_ID (+) AND
T28.TARGET_PER_ID = T20.ROW_ID (+) AND
T28.TARGET_PER_ID = T15.PAR_ROW_ID (+) AND
((T28.APPT_REPT_FLG = 'Y' AND (T28.APPT_REPT_END_DT IS NULL OR T28.APPT_REPT_END_DT >= TO_DATE('01/22/2010 00:00:00','MM/DD/YYYY HH24:MI:SS')) AND
T28.TODO_PLAN_START_DT < TO_DATE('01/28/2010 02:00:00','MM/DD/YYYY HH24:MI:SS') OR
T28.TODO_PLAN_START_DT >= TO_DATE('01/22/2010 02:00:00','MM/DD/YYYY HH24:MI:SS') AND
T28.TODO_PLAN_START_DT < TO_DATE('01/28/2010 02:00:00','MM/DD/YYYY HH24:MI:SS') AND
T28.APPT_REPT_FLG = 'N' OR T28.TODO_PLAN_START_DT < TO_DATE('01/22/2010 02:00:00','MM/DD/YYYY HH24:MI:SS') AND
T28.TODO_PLAN_END_DT >= TO_DATE('01/22/2010 02:00:00','MM/DD/YYYY HH24:MI:SS') AND T28.APPT_REPT_FLG = 'N') AND
(T28.TEMPLATE_FLG != 'Y' AND T28.TEMPLATE_FLG != 'P' OR T28.TEMPLATE_FLG IS NULL))
ORDER BY
T6.VAL, T28.TODO_PLAN_START_DT, T28.TODO_PLAN_END_DT;
========
Last analyzed
========
TABLE_NAME     NUM_ROWS     LAST_ANALYZED
S_OPTY          
S_EVT_ACT_SS          
S_PROJITEM          
S_PARTY     454296     21/01/2010 11:35:25
S_EVT_ACT     376973     21/01/2010 03:15:34
S_ACT_EMP     368667     21/01/2010 03:25:26
S_ORG_EXT     236749     21/01/2010 11:24:11
S_SRV_REQ     211987     21/01/2010 03:05:40
S_CONTACT     203236     21/01/2010 11:36:30
S_EVT_CAL     202947     21/01/2010 03:15:17
S_EVT_MKTG     202233     21/01/2010 03:15:11
S_ENTLMNT     200500     21/01/2010 13:40:07
S_LST_OF_VAL     87300     21/01/2010 03:12:21
S_DOC_AGREE     40545     21/01/2010 13:40:20
S_EVT_MAIL     9133     21/01/2010 03:15:15
S_EMP_PER     3160     21/01/2010 11:37:05
S_POSTN     2342     21/01/2010 11:35:42
S_ADDR_PER     2228     21/01/2010 03:24:23
=========
Execution plan
=========
10:47:30 SQL> 10:47:30 SQL> 10:47:30 2 Plan hash value: 261232047
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 53393 | 109M| | 41224 (1)| 00:08:15 |
| 1 | SORT ORDER BY | | 53393 | 109M| 278M| 41224 (1)| 00:08:15 |
|* 2 | HASH JOIN RIGHT OUTER | | 53393 | 109M| | 17215 (2)| 00:03:27 |
| 3 | TABLE ACCESS FULL | S_ADDR_PER | 2228 | 57928 | | 17 (0)| 00:00:01 |
| 4 | NESTED LOOPS OUTER | | 53393 | 108M| | 17197 (2)| 00:03:27 |
| 5 | NESTED LOOPS OUTER | | 53393 | 107M| | 16168 (2)| 00:03:15 |
| 6 | NESTED LOOPS OUTER | | 53393 | 105M| | 15451 (3)| 00:03:06 |
| 7 | NESTED LOOPS OUTER | | 53393 | 103M| | 14936 (3)| 00:03:00 |
|* 8 | HASH JOIN RIGHT OUTER | | 53393 | 101M| | 13908 (3)| 00:02:47 |
| 9 | TABLE ACCESS FULL | S_ORG_EXT_X | 825 | 12375 | | 7 (0)| 00:00:01 |
|* 10 | HASH JOIN RIGHT OUTER | | 53393 | 101M| | 13900 (3)| 00:02:47 |
| 11 | VIEW | index$_join$_017 | 2342 | 46840 | | 3 (0)| 00:00:01 |
|* 12 | HASH JOIN | | | | | | |
| 13 | INDEX FAST FULL SCAN | S_POSTN_F3 | 2342 | 46840 | | 1 (0)| 00:00:01 |
| 14 | INDEX FAST FULL SCAN | S_POSTN_P1 | 2342 | 46840 | | 1 (0)| 00:00:01 |
| 15 | NESTED LOOPS OUTER | | 53393 | 100M| | 13895 (3)| 00:02:47 |
| 16 | NESTED LOOPS OUTER | | 53393 | 98M| | 12867 (3)| 00:02:35 |
| 17 | NESTED LOOPS OUTER | | 53393 | 97M| | 12352 (3)| 00:02:29 |
| 18 | NESTED LOOPS OUTER | | 53393 | 95M| | 11283 (3)| 00:02:16 |
|* 19 | HASH JOIN RIGHT OUTER | | 53393 | 94M| | 10769 (3)| 00:02:10 |
| 20 | TABLE ACCESS FULL | S_SCHED_CAL | 80 | 1120 | | 3 (0)| 00:00:01 |
|* 21 | HASH JOIN RIGHT OUTER | | 53393 | 93M| | 10765 (3)| 00:02:10 |
| 22 | TABLE ACCESS FULL | S_EVT_MAIL | 9133 | 535K| | 198 (1)| 00:00:03 |
| 23 | NESTED LOOPS OUTER | | 53393 | 90M| | 10566 (3)| 00:02:07 |
| 24 | NESTED LOOPS OUTER | | 53393 | 87M| | 8963 (4)| 00:01:48 |
|* 25 | HASH JOIN RIGHT OUTER | | 53393 | 83M| | 7360 (5)| 00:01:29 |
| 26 | VIEW | index$_join$_022 | 2177 | 41363 | | 3 (0)| 00:00:01 |
|* 27 | HASH JOIN | | | | | | |
| 28 | INDEX FAST FULL SCAN | S_USER_M1 | 2177 | 41363 | | 1 (0)| 00:00:01 |
| 29 | INDEX FAST FULL SCAN | S_USER_U2 | 2177 | 41363 | | 1 (0)| 00:00:01 |
|* 30 | HASH JOIN RIGHT OUTER | | 53393 | 82M| | 7355 (5)| 00:01:29 |
| 31 | TABLE ACCESS FULL | S_SRV_REGN | 146 | 2482 | | 3 (0)| 00:00:01 |
|* 32 | HASH JOIN RIGHT OUTER | | 53393 | 82M| | 7351 (5)| 00:01:29 |
| 33 | TABLE ACCESS FULL | S_EMP_PER | 3160 | 47400 | | 23 (5)| 00:00:01 |
| 34 | NESTED LOOPS OUTER | | 53393 | 81M| | 7328 (5)| 00:01:28 |
| 35 | NESTED LOOPS OUTER | | 53393 | 79M| | 6338 (5)| 00:01:17 |
| 36 | NESTED LOOPS OUTER | | 53393 | 76M| | 5973 (6)| 00:01:12 |
| 37 | NESTED LOOPS OUTER | | 53393 | 75M| | 5232 (6)| 00:01:03 |
|* 38 | HASH JOIN RIGHT OUTER | | 53393 | 73M| | 3689 (9)| 00:00:45 |
| 39 | TABLE ACCESS FULL | S_EVT_ACT_SS | 82 | 34850 | | 2 (0)| 00:00:01 |
| 40 | NESTED LOOPS OUTER | | 53393 | 51M| | 3686 (9)| 00:00:45 |
| 41 | NESTED LOOPS OUTER | | 53393 | 49M| | 3685 (9)| 00:00:45 |
| 42 | NESTED LOOPS OUTER | | 53393 | 35M| | 3684 (9)| 00:00:45 |
|* 43 | HASH JOIN RIGHT OUTER | | 53393 | 32M| | 3683 (9)| 00:00:45 |
| 44 | TABLE ACCESS BY INDEX ROWID | S_LST_OF_VAL | 10 | 480 | | 1 (0)| 00:00:01 |
|* 45 | INDEX RANGE SCAN | S_LST_OF_VAL_U1 | 10 | | | 1 (0)| 00:00:01 |
|* 46 | TABLE ACCESS BY INDEX ROWID | S_EVT_ACT | 53393 | 29M| | 3681 (9)| 00:00:45 |
| 47 | BITMAP CONVERSION TO ROWIDS | | | | | | |
| 48 | BITMAP OR | | | | | | |
| 49 | BITMAP CONVERSION FROM ROWIDS| | | | | | |
| 50 | SORT ORDER BY | | | | 9896K| | |
|* 51 | INDEX RANGE SCAN | S_EVT_ACT_M8 | | | | 12 (0)| 00:00:01 |
| 52 | BITMAP CONVERSION FROM ROWIDS| | | | | | |
| 53 | SORT ORDER BY | | | | | | |
|* 54 | INDEX RANGE SCAN | S_EVT_ACT_M8 | | | | 1 (0)| 00:00:01 |
| 55 | BITMAP CONVERSION FROM ROWIDS| | | | | | |
| 56 | SORT ORDER BY | | | | 9960K| | |
|* 57 | INDEX RANGE SCAN | S_EVT_ACT_M8 | | | | 12 (0)| 00:00:01 |
| 58 | TABLE ACCESS BY INDEX ROWID | S_PROJITEM | 1 | 68 | | 1 (0)| 00:00:01 |
|* 59 | INDEX UNIQUE SCAN | S_PROJITEM_P1 | 1 | | | 1 (0)| 00:00:01 |
| 60 | TABLE ACCESS BY INDEX ROWID | S_OPTY | 1 | 276 | | 1 (0)| 00:00:01 |
|* 61 | INDEX UNIQUE SCAN | S_OPTY_P1 | 1 | | | 1 (0)| 00:00:01 |
| 62 | TABLE ACCESS BY INDEX ROWID | S_PROJ | 1 | 44 | | 1 (0)| 00:00:01 |
|* 63 | INDEX UNIQUE SCAN | S_PROJ_P1 | 1 | | | 1 (0)| 00:00:01 |
| 64 | TABLE ACCESS BY INDEX ROWID | S_ACT_EMP | 1 | 31 | | 1 (0)| 00:00:01 |
|* 65 | INDEX RANGE SCAN | S_ACT_EMP_U1 | 1 | | | 1 (0)| 00:00:01 |
| 66 | TABLE ACCESS BY INDEX ROWID | S_SRV_REQ | 1 | 37 | | 1 (0)| 00:00:01 |
|* 67 | INDEX UNIQUE SCAN | S_SRV_REQ_P1 | 1 | | | 1 (0)| 00:00:01 |
| 68 | TABLE ACCESS BY INDEX ROWID | S_DOC_AGREE | 1 | 55 | | 1 (0)| 00:00:01 |
|* 69 | INDEX UNIQUE SCAN | S_DOC_AGREE_P1 | 1 | | | 1 (0)| 00:00:01 |
| 70 | TABLE ACCESS BY INDEX ROWID | S_ENTLMNT | 1 | 29 | | 1 (0)| 00:00:01 |
|* 71 | INDEX UNIQUE SCAN | S_ENTLMNT_P1 | 1 | | | 1 (0)| 00:00:01 |
| 72 | TABLE ACCESS BY INDEX ROWID | S_EVT_CAL | 1 | 67 | | 1 (0)| 00:00:01 |
|* 73 | INDEX RANGE SCAN | S_EVT_CAL_U1 | 1 | | | 1 (0)| 00:00:01 |
| 74 | TABLE ACCESS BY INDEX ROWID | S_EVT_MKTG | 1 | 72 | | 1 (0)| 00:00:01 |
|* 75 | INDEX RANGE SCAN | S_EVT_MKTG_U1 | 1 | | | 1 (0)| 00:00:01 |
|* 76 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1 | 11 | | 1 (0)| 00:00:01 |
| 77 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 47 | | 1 (0)| 00:00:01 |
|* 78 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | | 1 (0)| 00:00:01 |
|* 79 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1 | 11 | | 1 (0)| 00:00:01 |
| 80 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 1 | 39 | | 1 (0)| 00:00:01 |
|* 81 | INDEX UNIQUE SCAN | S_CONTACT_U2 | 1 | | | 1 (0)| 00:00:01 |
| 82 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 1 | 31 | | 1 (0)| 00:00:01 |
|* 83 | INDEX UNIQUE SCAN | S_CONTACT_U2 | 1 | | | 1 (0)| 00:00:01 |
| 84 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 1 | 34 | | 1 (0)| 00:00:01 |
|* 85 | INDEX UNIQUE SCAN | S_CONTACT_U2 | 1 | | | 1 (0)| 00:00:01 |
| 86 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 47 | | 1 (0)| 00:00:01 |
|* 87 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | | 1 (0)| 00:00:01 |
| 88 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 1 | 11 | | 1 (0)| 00:00:01 |
|* 89 | INDEX UNIQUE SCAN | S_CONTACT_P1 | 1 | | | 1 (0)| 00:00:01 |
I work with SIEBEL ERP and i can't calculate statistics on table where lines < 30.
Thanks for your help

optimizer_index_cost_adj integer 1This init parameter looks rather to be unconventional value (default is 100). Did you try to leave the default value ?
i can't calculate statistics on table where lines < 30.What do you mean ? No statistics gathered on tables with less than 30 rows ?
In that case you may want to test to set optimizer_dynamic_sampling init parameter to the default value (=2) where you have 1.
Nicolas.

Similar Messages

  • Form query too long running

    I am dealing with an issue that I believe I have boiled it down to being a Forms issue. One of my developers has a form that is taking 40+ minutes to run a pretty complicated query. At first I believed that it was a query or development issue, however the same query can be ran from Toad or from SQLPlus in under a few seconds. I have even ran the query from SQLPlus on the forms server with the same speedy performance. The only environment in which this query takes almost an hour to run is if it is ran from her .FMX ... I am soooooo at a loss right now as to what I could do to fix this. Has anyone experienced something of this nature?
    Additionally the query returns ZERO results and this is an expected outcome so I don't believe it has to do with Toad buffering or SQLPlus return the rows as they are fetched. Anyway I'm at a loss and any help what-so-ever will be greatly appreciated.

    To show what can go wrong look at this simple example.
    HR@> CREATE TABLE a (ID VARCHAR2(10) PRIMARY KEY);
    Table created.
    HR@>
    HR@> insert into a select rownum from dual connect by rownum <= 1e6;
    1000000 rows created.
    HR@>
    HR@> set timing on
    HR@>
    HR@> select * from a where id = 100;
    ID
    100
    Elapsed: 00:00:00.34
    HR@>
    HR@> select * from a where id = '100';
    ID
    100
    Elapsed: 00:00:00.00
    HR@> explain plan for
      2* select * from a where id = 100
    HR@>
    HR@> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2248738933
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     7 |   522  (12)| 00:00:07 |
    |*  1 |  TABLE ACCESS FULL| A    |     1 |     7 |   522  (12)| 00:00:07 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(TO_NUMBER("ID")=100)Because of implicit conversion (as explain plan shows) select * from a where id = 100 takes longer than select * from a where id = '100'.

  • Loop with WMI Query taking too long, need to break out if time exceeds 5 min

    I've written a script that will loop through a list of computers and run a WMI query using the Win32_Product class. I am pinging the host first to ensure its online which eliminates wasting time but the issue I'm facing is that some of the machines
    are online but the WMI Query takes too long and holds up the script. I wanted to add a timeout to the WMI query so if a particular host will not respond to the query or gets stuck the loop will break out an go to the next computer object. I've added my code
    below:
    $Computers = @()
    $computers += "BES10-BH"
    $computers += "AUTSUP-VSUS"
    $computers += "AppClus06-BH"
    $computers += "Aut01-BH"
    $computers += "AutLH-VSUS"
    $computers += "AW-MGMT01-VSUS"
    $computers += "BAMBOOAGT-VSUS"
    ## Loop through all computer objects found in $Computes Array
    $JavaInfo = @()
    FOREACH($Client in $Computers)
    ## Gather WMI installed Software info from each client queried
    Clear-Host
    Write-Host "Querying: $Client" -foregroundcolor "yellow"
    $HostCount++
    $Online = (test-connection -ComputerName ADRAP-VSUS -Count 1 -Quiet)
    IF($Online -eq "True")
    $ColItem = Get-WmiObject -Class Win32_Product -ComputerName $Client -ErrorAction SilentlyContinue | `
    Where {(($_.name -match "Java") -and (!($_.name -match "Auto|Visual")))} | `
    Select-Object Name,Version
    FOREACH($Item in $ColItem)
    ## Write Host Name as variable
    $HostNm = ($Client).ToUpper()
    ## Query Named Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVerName = $Item.name
    IF([string]::IsNullOrEmpty($JavaVerName))
    {$JavaVerName = "No Installed"}
    ## Query Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVer = $Item.Version
    IF([string]::IsNullOrEmpty($JavaVer))
    {$JavaVer = "Not Installed"}
    ## Create new object to organize Host,JavaName & Version
    $JavaProp = New-Object -TypeName PSObject -Property @{
    "HostName" = $HostNm
    "JavaVerName" = $JavaVerName
    "JavaVer" = $JavaVer
    ## Add new object data "JavaProp" from loop into array "JavaInfo"
    $JavaInfo += $JavaProp
    Else
    {Write-Host "$Client didn't respond, Skipping..." -foregroundcolor "Red"}

    Let me give you a bigger picture of the script. I've included the emailed table the script produces and the actual script. While running the script certain hosts get hung up when running the WMI query which causes the script to never complete. From one of
    the posts I was able to use the Get-WmiCustom function to add a timeout 0f 15 seconds and then the script will continue if it is stuck. The problem is when a host is skipped I am not aware of it because my script is not reporting the server that timed out.
    If you look at ZLBH02-VSUS highlighted in the report you can see that its reporting not installed when it should say something to the effect query hung.
    How can I add a variable in the function that will be available outside the function that I can key off of to differentiate between a host that does not have the software installed and one that failed to query?
    Script Output:
    Script:
    ## Name: JavaReportWMI.ps1 ##
    ## Requires: Power Shell 2.0 ##
    ## Created: January 06, 2015 ##
    <##> $Version = "Script Version: 1.0" <##>
    <##> $LastUpdate = "Updated: January 06, 2015" <##>
    ## Configure Compliant Java Versions Below ##
    <##> $java6 = "6.0.430" <##>
    <##> $javaSEDEVKit6 = "1.6.0.430" <##>
    <##> $java7 = "7.0.710" <##>
    <##> $javaSEDEVKit7 = "1.7.0.710" <##>
    <##> $java8 = "8.0.250" <##>
    <##> $javaSEDDEVKit8 = "1.8.0.250" <##>
    ## Import Active Directory Module
    Import-Module ActiveDirectory
    $Timeout = "False"
    Function Get-WmiCustom([string]$computername,[string]$namespace,[string]$class,[int]$timeout=15)
    $ConnectionOptions = new-object System.Management.ConnectionOptions
    $EnumerationOptions = new-object System.Management.EnumerationOptions
    $timeoutseconds = new-timespan -seconds $timeout
    $EnumerationOptions.set_timeout($timeoutseconds)
    $assembledpath = "\\" + $computername + "\" + $namespace
    #write-host $assembledpath -foregroundcolor yellow
    $Scope = new-object System.Management.ManagementScope $assembledpath, $ConnectionOptions
    $Scope.Connect()
    $querystring = "SELECT * FROM " + $class
    #write-host $querystring
    $query = new-object System.Management.ObjectQuery $querystring
    $searcher = new-object System.Management.ManagementObjectSearcher
    $searcher.set_options($EnumerationOptions)
    $searcher.Query = $querystring
    $searcher.Scope = $Scope
    trap { $_ } $result = $searcher.get()
    return $result
    ## Log time for duration clock
    $Start = Get-Date
    $StartTime = "StartTime: " + $Start.ToShortTimeString()
    ## Environmental Variables
    $QueryMode = $Args #parameter for either "Desktops" / "Servers"
    $CsvPath = "C:\Scripts\JavaReport\JavaReport" + "$QueryMode" + ".csv"
    $Date = Get-Date
    $Domain = $env:UserDomain
    $HostName = ($env:ComputerName).ToLower()
    ## Regional Settings
    ## Used for testing
    IF ($Domain -eq "abc") {$Region = "US"; $SMTPDomain = "abc.com"; `
    $ToAddress = "[email protected]"; `
    $ReplyDomain = "abc.com"; $smtpServer = "relay.abc.com"}
    ## Control Variables
    $FromAddress = "JavaReport@$Hostname.na.$SMTPDomain"
    $EmailSubject = "Java Report - $Region"
    $computers = @()
    $computers += "ZLBH02-VSUS"
    $computers += "AUTSUP-VSUS"
    $computers += "AppClus06-BH"
    $computers += "Aut01-BH"
    $computers += "AutLH-VSUS"
    $computers += "AW-MGMT01-VSUS"
    $computers += "BAMBOOAGT-VSUS"
    #>
    ## Loop through all computer objects found in $Computes Array
    $JavaInfo = @()
    FOREACH($Client in $Computers)
    ## Gather WMI installed Software info from each client queried
    Clear-Host
    Write-Host "Querying: $Client" -foregroundcolor "yellow"
    $HostCount++
    $Online = (test-connection -ComputerName ADRAP-VSUS -Count 1 -Quiet)
    IF($Online -eq "True")
    $ColItem = Get-WmiCustom -Class Win32_Product -Namespace "root\cimv2" -ComputerName $Client -ErrorAction SilentlyContinue | `
    Where {(($_.name -match "Java") -and (!($_.name -match "Auto|Visual")))} | `
    Select-Object Name,Version
    FOREACH($Item in $ColItem)
    ## Write Host Name as variable
    $HostNm = ($Client).ToUpper()
    ## Query Named Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVerName = $Item.name
    IF([string]::IsNullOrEmpty($JavaVerName))
    {$JavaVerName = "No Installed"}
    ## Query Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVer = $Item.Version
    IF([string]::IsNullOrEmpty($JavaVer))
    {$JavaVer = "Not Installed"}
    ## Create new object to organize Host,JavaName & Version
    $JavaProp = New-Object -TypeName PSObject -Property @{
    "HostName" = $HostNm
    "JavaVerName" = $JavaVerName
    "JavaVer" = $JavaVer
    ## Add new object data "JavaProp" from loop into array "JavaInfo"
    $JavaInfo += $JavaProp
    Else
    {Write-Host "$Client didn't respond, Skipping..." -foregroundcolor "Red"}
    #Write-Host "Host Query Count: $LoopCount" -foregroundcolor "yellow"
    ## Sort Array
    Write-Host "Starting Array" -foregroundcolor "yellow"
    $JavaInfoSorted = $JavaInfo | Sort-object HostName
    Write-Host "Starting Export CSV" -foregroundcolor "yellow"
    ## Export CSV file
    $JavaInfoSorted | export-csv -NoType $CsvPath -Force
    $Att = new-object Net.Mail.Attachment($CsvPath)
    Write-Host "Building Table Header" -foregroundcolor "yellow"
    ## Table Header
    $list = "<table border=1><font size=1.5 face=verdana color=black>"
    $list += "<tr><th><b>Host Name</b></th><th><b>Java Ver Name</b></th><th><b>Ver Number</b></th></tr>"
    Write-Host "Building HTML Table" -foregroundcolor "yellow"
    FOREACH($Item in $JavaInfoSorted)
    Write-Host "$UniqueHost" -foregroundcolor "Yellow"
    ## Alternate Table Shading between Green and White
    IF($LoopCount++ % 2 -eq 0)
    {$BK = "bgcolor='E5F5D7'"}
    ELSE
    {$BK = "bgcolor='FFFFFF'"}
    ## Set Variables
    $JVer = $Item.JavaVer
    $Jname = $Item.JavaVerName
    ## Change Non-Compliant Java Versions to red in table
    IF((($jVer -like "6.0*") -and (!($jVer -match $java6))) -or `
    (($jName -like "*Java(TM) SE Development Kit 6*") -and (!($jName -match $javaSEDEVKit6))) -or `
    (($jVer -like "7.0*") -and (!($jVer -match $java7))) -or `
    (($jName -like "*Java SE Development Kit 7*") -and (!($jName -match $javaSEDEVKit7))))
    $list += "<tr $BK style='color: #ff0000'>"
    ## Compliant Java version are displayed in black
    ELSE
    $list += "<tr $BK style='color: #000000'>"
    ## Populate table with host name variable
    $list += "<td>" + $Item."HostName" + "</td>"
    ## Populate table with Java Version Name variable
    $list += "<td>" + $Item."JavaVerName" + "</td>"
    ## Populate table with Java Versionvariable
    $list += "<td>" + $Item."JavaVer" + "</td>"
    $list += "</tr>"
    $list += "</table></font>"
    $End = Get-Date
    $EndTime = "EndTime: " + $End.ToShortTimeString()
    #$TimeDiff = New-TimeSpan -Start $StartTime -End $EndTime
    $StartTime
    $EndTime
    $TimeDiff
    Write-Host "Total Hosts:$HostCount"
    ## Email Function
    Function SendEmail
    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg.From = ($FromAddress)
    $msg.ReplyTo =($ToAddress)
    $msg.To.Add($ToAddress)
    #$msg.BCC.Add($BCCAddress)
    $msg.Attachments.Add($Att)
    $msg.Subject = ($EmailSubject)
    $msg.Body = $Body
    $msg.IsBodyHTML = $true
    $smtp.Send($msg)
    $msg.Dispose()
    ## Email Body
    $Body = $Body + @"
    <html><body><font face="verdana" size="2.5" color="black">
    <p><b>Java Report - $Region</b></p>
    <p>$list</p>
    </html></body></font>
    <html><body><font face="verdana" size="1.0" color="red">
    <p><b> Note: Items in red do not have the latest version of Java installed. Please open a ticket to have an engineer address the issue.</b></p>
    </html></body></font>
    <html><body><font face="verdana" size="2.5" color="black">
    <p>
    $StartTime<br>
    $EndTime<br>
    $TimeDiff<br>
    $HostCount<br>
    </p>
    <p>
    Run date: $Date<br>
    $Version<br>
    $LastUpdate<br>
    </p>
    </html></body></font>
    ## Send Email
    SendEmail

  • Time_out Dump on this query take too long time

    hi experts,
    in my report a query taking too long time
    pl. provide performance tips or suggestions
    select mkpf~mblnr  mkpf~mjahr  mkpf~usnam  mkpf~vgart    
           mkpf~xabln  mkpf~xblnr  mkpf~zshift mkpf~frbnr    
           mkpf~bktxt  mkpf~bldat  mkpf~budat  mkpf~cpudt    
           mkpf~cputm  mseg~anln1  mseg~anln2  mseg~aplzl    
           mseg~aufnr  mseg~aufpl  mseg~bpmng  mseg~bprme    
           mseg~bstme  mseg~bstmg  mseg~bukrs  mseg~bwart    
           mseg~bwtar  mseg~charg  mseg~dmbtr  mseg~ebeln    
           mseg~ebelp  mseg~erfme  mseg~erfmg  mseg~exbwr    
           mseg~exvkw  mseg~grund  mseg~kdauf  mseg~kdein    
           mseg~kdpos  mseg~kostl  mseg~kunnr  mseg~kzbew    
           mseg~kzvbr  mseg~kzzug  mseg~lgort  mseg~lifnr    
           mseg~matnr  mseg~meins  mseg~menge  mseg~lsmng    
           mseg~nplnr  mseg~ps_psp_pnr  mseg~rsnum  mseg~rspos
           mseg~shkzg  mseg~sobkz  mseg~vkwrt  mseg~waers    
           mseg~werks  mseg~xauto  mseg~zeile  mseg~SGTXT    
        into table itab                                      
           from mkpf as mkpf                                 
            inner join mseg as mseg                          
                    on mkpf~MBLNR = mseg~mblnr               
                   and mkpf~mjahr = mseg~mjahr

    no the original query is, i use where clouse with conditions.
    select mkpf~mblnr  mkpf~mjahr  mkpf~usnam  mkpf~vgart
           mkpf~xabln  mkpf~xblnr  mkpf~zshift mkpf~frbnr
           mkpf~bktxt  mkpf~bldat  mkpf~budat  mkpf~cpudt
           mkpf~cputm  mseg~anln1  mseg~anln2  mseg~aplzl
           mseg~aufnr  mseg~aufpl  mseg~bpmng  mseg~bprme
           mseg~bstme  mseg~bstmg  mseg~bukrs  mseg~bwart
           mseg~bwtar  mseg~charg  mseg~dmbtr  mseg~ebeln
           mseg~ebelp  mseg~erfme  mseg~erfmg  mseg~exbwr
           mseg~exvkw  mseg~grund  mseg~kdauf  mseg~kdein
           mseg~kdpos  mseg~kostl  mseg~kunnr  mseg~kzbew
           mseg~kzvbr  mseg~kzzug  mseg~lgort  mseg~lifnr
           mseg~matnr  mseg~meins  mseg~menge  mseg~lsmng
           mseg~nplnr  mseg~ps_psp_pnr  mseg~rsnum  mseg~rspos
           mseg~shkzg  mseg~sobkz  mseg~vkwrt  mseg~waers
           mseg~werks  mseg~xauto  mseg~zeile  mseg~SGTXT
        into table itab
           from mkpf as mkpf
            inner join mseg as mseg
                    on mkpf~MBLNR = mseg~mblnr
                   and mkpf~mjahr = mseg~mjahr
        WHERE mkpf~budat IN budat
          AND mkpf~usnam IN usnam
          AND mkpf~vgart IN vgart
          AND mkpf~xblnr IN xblnr
          AND mkpf~zshift IN p_shift
          AND mseg~bwart IN bwart
          AND mseg~matnr IN matnr
          AND mseg~werks IN werks
          AND mseg~lgort IN lgort
          AND mseg~charg IN charg
          AND mseg~sobkz IN sobkz
          AND mseg~lifnr IN lifnr
          AND mseg~kunnr IN kunnr.

  • 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

  • Ora-06502: variable length too long on report query xml schema download

    on shared components/report queries/edit report query/
    and downloading my queries in xml schema format (radio button).
    Get
    ORA-06502: PL/SQL: numeric or value error: raw variable length too long
    when i click the download button.
    EDIT:
    i want to add that i recently changed several columns in the database from 150 to 3000 chars long.
    Edited by: Manny Rodriguez on Oct 11, 2011 7:19 AM

    "4000 bytes is the ultimate maximum. you can say 4000 *characters* , but it'll always be limited to 4000 *bytes* . "
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1224836384599#201073000346459201\
    "The maximum length of the column is determined by the national character set definition. Width specifications of character data type NVARCHAR2 refer to the number of characters. The maximum column size allowed is 4000 bytes."
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements001.htm#SQLRF50976
    By the way, you're treating your numbers as STRINGS, remove the quotes around your zero's.

  • My Query takes too long ...

    Hi ,
    Env   , DB 10G , O/S Linux Redhat , My DB size is about 80G
    My query takes too long ,  about 5 days to get results , can you please help to rewrite this query in a better way ,
    declare
    x number;
    y date;
    START_DATE DATE;
    MDN VARCHAR2(12);
    TOPUP VARCHAR2(50);
    begin
    for first_bundle in
    select min(date_time_of_event) date_time_of_event ,account_identifier  ,top_up_profile_name
    from bundlepur
    where account_profile='Basic'
    AND account_identifier='665004664'
    and in_service_result_indicator=0
    and network_cause_result_indicator=0
    and   DATE_TIME_OF_EVENT >= to_date('16/07/2013','dd/mm/yyyy')
    group by account_identifier,top_up_profile_name
    order by date_time_of_event
    loop
    select sum(units_per_tariff_rum2) ,max(date_time_of_event)
    into x,y
    from OLD_LTE_CDR
    where account_identifier=(select first_bundle.account_identifier from dual)
    and date_time_of_event >= (select first_bundle.date_time_of_event from dual)
    and -- no more than a month
    date_time_of_event < ( select add_months(first_bundle.date_time_of_event,1) from dual)
    and -- finished his bundle then buy a new one
      date_time_of_event < ( SELECT MIN(DATE_TIME_OF_EVENT)
                             FROM OLD_LTE_CDR
                             WHERE DATE_TIME_OF_EVENT > (select (first_bundle.date_time_of_event)+1/24 from dual)
                             AND IN_SERVICE_RESULT_INDICATOR=26);
    select first_bundle.account_identifier ,first_bundle.top_up_profile_name
    ,FIRST_BUNDLE.date_time_of_event
    INTO MDN,TOPUP,START_DATE
    from dual;
    insert into consumed1 VALUES(X,topup,MDN,START_DATE,Y);
    end loop;
    COMMIT;
    end;

    > where account_identifier=(select first_bundle.account_identifier from dual)
    Why are you doing this?  It's a completely unnecessary subquery.
    Just do this:
    where account_identifier = first_bundle.account_identifier
    Same for all your other FROM DUAL subqueries.  Get rid of them.
    More importantly, don't use a cursor for loop.  Just write one big INSERT statement that does what you want.

  • Streamline query ? Taking too long

    First I wanted to say thanks to all in this forum, its been a huge help learning sql.
    Hoping someone can take a look at this query. It works but it takes a very long time to run.
    maybe there is a way to streamline it. right now its using one project number, but typically I would put in 60 or 70 project numbers here..
    select proj_id from project_master where status='A' and project_number IN(
    '502998'
    )))c,
    if someone knows a better way to run this please let me know , I will try anything. currently it takes about an hour to run it for 1 project number.
    select * from(
    select
    b.doc_folder_id,c.project_number,b.name,a.doc_file_name,a.rec_update_date,a.rec_create_date,d.rnk
    from
    select doc_id,proj_id, doc_file_name,rec_create_date,rec_update_date from document_master where doc_status ='A'
    and doc_file_extension like 'pdf' or doc_file_extension like 'jpg'
    or doc_file_extension like 'xls' or doc_file_extension like 'doc'
    or doc_file_extension like 'txt' or doc_file_extension like 'png'
    or doc_file_extension like 'tif' or doc_file_extension like 'ppt'
    or doc_file_extension like 'pps' or doc_file_extension like 'msg'
    ) a,
    (select * from doc_folder_master
    where upper(name) LIKE '%DAILY REPORTS%'
    OR upper(name) LIKE '%MANPOWER REPORTS%'
    OR upper(name) LIKE '%SITE PURCHASES%'
    OR upper(name) LIKE '%SETE EHS ISSUES%'
    OR upper(name) LIKE '%TURNOVER PACKAGES%'
    OR upper(name) LIKE '11.04.01 PAD%'
    OR upper(name) LIKE '%EDSR%'
    OR upper(name) LIKE '%COQ WORKFLOW%'
    and status='A'
    ) b,
    (select proj_id,project_number from project_master where proj_id IN (
    select proj_id from project_master where status='A' and project_number IN(
    '502998'
    )))c,
    (select child_doc_type,
    parent_doc_id,child_doc_id,to_char(rec_create_date,'mm/dd/yyyy hh24:mi:ss'),
    row_number() over (partition by parent_doc_id,child_doc_type order by rec_create_date desc) rnk
    from document_relations)d
    where a.proj_id=b.proj_id
    and c.proj_id=a.proj_id
    and c.proj_id=b.proj_id
    and d.parent_doc_id=b.doc_folder_id
    and a.doc_id=d.child_doc_id)
    where rnk <3
    thanks for any assistance.
    Edited by: Jay on Dec 29, 2010 12:08 PM

    Hi,
    Please, you might want to read this post:
    When your query takes too long ...
    Providing further information is key to obtaining quality answers.
    Now on to the actual subject:
    It seems you want some sort of top-n query. Depending on the cardinality and the data that you have, you probably would want to prune the rows from the DOCUMENT_RELATIONS table early, before joining to the other tables. This way you can avoid the database wasting effort of looking up matches on the other tables to only then discard those joined rows. You can do that by pushing the WHERE rnk < 3 predicate into the inline view.
    SELECT *
      FROM (SELECT b.doc_folder_id, c.project_number, b.name, a.doc_file_name, a.rec_update_date, a.rec_create_date, d.rnk
              FROM (SELECT doc_id, proj_id, doc_file_name, rec_create_date, rec_update_date
                      FROM document_master
                     WHERE doc_status = 'A'
                           AND doc_file_extension IN ('pdf', 'jpg', 'xls', 'doc', 'txt', 'png', 'tif', 'ppt', 'pps', 'msg')) a,
                   (SELECT *
                      FROM doc_folder_master
                     WHERE upper(NAME) LIKE '%DAILY REPORTS%'
                           OR upper(NAME) LIKE '%MANPOWER REPORTS%'
                           OR upper(NAME) LIKE '%SITE PURCHASES%'
                           OR upper(NAME) LIKE '%SETE EHS ISSUES%'
                           OR upper(NAME) LIKE '%TURNOVER PACKAGES%'
                           OR upper(NAME) LIKE '11.04.01 PAD%'
                           OR upper(NAME) LIKE '%EDSR%'
                           OR upper(NAME) LIKE '%COQ WORKFLOW%'
                           AND status = 'A') b,
                   (SELECT proj_id, project_number
                      FROM project_master
                     WHERE proj_id IN (SELECT proj_id
                                         FROM project_master
                                        WHERE status = 'A'
                                              AND project_number IN ('502998'))) c,
                   (SELECT *
                      FROM (SELECT child_doc_type,
                                   parent_doc_id,
                                   child_doc_id,
                                   to_char(rec_create_date, 'mm/dd/yyyy hh24:mi:ss'),
                                   row_number() over(PARTITION BY parent_doc_id, child_doc_type ORDER BY rec_create_date DESC) rnk
                              FROM document_relations)
                     WHERE rnk < 3) d
             WHERE a.proj_id = b.proj_id
                   AND c.proj_id = a.proj_id
                   AND c.proj_id = b.proj_id
                   AND d.parent_doc_id = b.doc_folder_id
                   AND a.doc_id = d.child_doc_id)Like Toon said, if not needed you should avoid the 2nd scan in the PROJECT_MASTER table.
    Perhaps you should check the possibility of creating a function-based index on the doc_folder_master table, with the upper(NAME) expression, to improve those Like conditions.
    Docs on Function-based Indexes:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/data_acc.htm#PFGRF94785

  • Oracle - Query taking too long (Materialized view)

    Hi,
    I am extracting billing informaiton and storing in 3 different tables... in order to show total billing (80 to 90 columns, 1 million rows per month), I've used a materialized view... I do not have indexes on 3 billing tables - do have 3 indexes on Materialized view...
    at the moment it's taking too long to query the data (running a query via toad fails and shows "Out of Memory" error message; runing a query via APEX though is providing results but taking way too long)...
    Please advice how to make the query efficient...

    tparvaiz,
    Is it possible when building your materialized view to summarize and consolidate the data?
    Out of a million rows, what would your typical user do with that amount data if they could retrieve it readily? The answer to this question may indicate if and how to summarize the data within the materialized view.
    Jeff
    Edited by: jwellsnh on Mar 25, 2010 7:02 AM

  • Deletion Query takes too long

    I have two tables with exactly the same structure. The table 1 gets data and one procedure reads that data and inserts them into another table (table2) for processing them. I have a delete query which is taking too long to execute.
    The query is as follows
    delete
    from events.temp_act a
    where a.chess_ts < (select max(chess_ts) from events.temp_act b
    where a.db_type = b.db_type
    and a.order_no = b.order_no
    and a.acv_no = b.acv_no
    There is a composite index in this table which is (db_type,order_no,acv_no)
    In my procedure, I drop and create the index for faster processing and also analyze the index.
    The above deletion query approximately deletes half the number of total records.
    There is no primary key in the table for the reason that there can be no unique record identifier.
    The query takes nearly 2 hours for deleting about 1100000 records.
    Is there a way to make this query run faster?

    What is the explain plan for this statement? Is the index even being used?
    Is the table analyzed as well as the index?
    Dropping/re-creating the index - not likely to help. I would leave this out.
    Have you tried other variations, like:
    delete
      from events.temp_act
    where (db_type, order_no, acv_vo, chess_ts)
           not in (select db_type, order_no, acv_vo, max(chess_ts)
                     from events.temp_act b
                    group by db_type, order_no, acv_vo);

  • Sql Query takes too long to enter into the first line

    Hi Friends,
      I am using SQLServer 2008. I am running the query for fetching the data from database. when i am running first time after executed the "DBCC FREEPROCCACHE" query for clear cache memory, it takes too long (7 to 9 second) to enter into first
    line of the stored procedure. After its enter into the first statement of the SP, its fetching the data within a second. I think there is no problem with Sqlquery.  Kindly let me know if you know the reason behind this.
    Sample Example:
    Create Sp Sp_Name
    as
     Begin
     print Getdate()
      Sql statements for fetching datas
     Print Getdate()
     End
    In the above example, there is no difference between first date and second date.
    Please help me to trouble shooting this problem.
    Thanks & Regards,
    Rajkumar.R

     i am running first time after executed the "DBCC FREEPROCCACHE" query for clear cache memory, it takes too long (7 to 9 second)
    Additional to Manoj: A
    DBCC FREEPROCCACHE clears the procedure cache, so all store procedure must be newly compilied on the first call.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Query designer takes too long to save a query

    Hi dear SDN friends.
    I´m working with query designer in BI 7 and sometimes it takes too long to save a query, about ten minutes. Sometimes it never ends saving and some other times it saves the same query in 1 minute.
    Can anybody please give an advice about this behavior of the query designer?
    We have recently update BI to sp18. In query designer I have sp5 revision 529
    Best regards,
    Karim Reyes

    Hello Karim,
    I would suggest testing this again in the latest Frontend Patch available (FEP 602).  In FEPs 600, 601, & 602 there were some performance and stability improvements made which may correct your issue.  If the issue persists, I would suggest then opening a Customer Message via Service Marketplace.
    It can be downloaded from:
        http://service.sap.com/swdc
    u2192Download
    u2192Support Packages and Patches
    u2192Entry by Application Group
    u2192SAP Frontend Components
    u2192BI ADDON FOR SAPGUI
    u2192 BI 7.0 ADDON FOR SAPGUI 7.10
    u2192 BI 7.0 ADDON FOR SAPGUI 7.10
    u2192Win32
    See SAP Note 1085218 for planned FEP releases.
    I hope that helps.
    Regards,
    Tanner Spaulding
    SAP NetWeaver RIG Americas, BI

  • Query running for too long

    Hi All,
    Can someone pls help me in finding how long will it take to execute the below query.
    I have a query that is taking too long to execute.
    SELECT   CPU_TIME/1000000/60 CPUTIME, ELAPSED_TIME/1000000/60 ELAPSEDTIME, PROGRAM_LINE#, OPTIMIZER_COST,
    USER_IO_WAIT_TIME/1000000/60 IOWAITTIME,  DISK_READS, DIRECT_WRITES, BUFFER_GETS, to_char(Q.SQL_FULLTEXT), OPTIMIZER_MODE,  SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM, SORTS, FETCHES, EXECUTIONS, END_OF_FETCH_COUNT, USERS_EXECUTING, LOADS,
    FIRST_LOAD_TIME,  INVALIDATIONS, PARSE_CALLS, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, CLUSTER_WAIT_TIME,
    PLSQL_EXEC_TIME, JAVA_EXEC_TIME, ROWS_PROCESSED, COMMAND_TYPE, PARSING_USER_ID, PARSING_SCHEMA_ID, PARSING_SCHEMA_NAME, OBJECT_STATUS
         FROM     v$session S, v$sqlarea Q
         WHERE    S.SQL_ADDRESS = Q.ADDRESS
         AND      s.username = 'SCHEMA_NAME'
         AND       s.osuser = 'OSUSER_NAME';I can see CPU_TIME increasing. Is there any way that I can find how lmuch more time will it take for the query to execute.
    The query creates a table that has a sub query and inner query.
    rgds
    saaz

    http://www.gplivna.eu/papers/v$session_longops.htm
    There is a dynamic performance view v$session_longops that is populated for many long running operations in Oracle. The primary criterion for any operation to appear in v$session_longops is to run more than 6 seconds. Although this isn’t the only criterion as well as not all operations that take more than 6 seconds are shown in this view. For example one can find hash joins in v$session_longops, but you won’t find there nested loop joins even if they are longer than 6 seconds and are joining very big data sets.

  • Query is taking too long to execute - contd

    I am unable to post the entire explain plan in one post as it exceeds maximum length.
    Please advise on how to post this.
    Previous post Link : Link: Query is taking too long to execute
    Regards,
    Sreekanth Munagala.
    Edited by: Sreekanth Munagala on Oct 27, 2009 8:31 AM
    Edited by: Sreekanth Munagala on Oct 27, 2009 8:34 AM

    Hi Tubby,
    Today i executed only the first query in the view and it took almost 2.5 hrs.
    Here is the explain plan for this query
    SQL> SET SERVEROUTPUT ON
    SQL> set linesize 200
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    | Id  | Operation                                        |  Name                         | Rows  | Bytes | Cost  |                                                                                     
    |   0 | SELECT STATEMENT                                 |                               |     1 |   766 |  2448 |                                                                                     
    |   1 |  TABLE ACCESS BY INDEX ROWID                     | PO_VENDORS                    |     1 |    13 |     3 |                                                                                     
    |*  2 |   INDEX UNIQUE SCAN                              | PO_VENDORS_U1                 |     1 |       |     2 |                                                                                     
    |   3 |  TABLE ACCESS BY INDEX ROWID                     | PO_VENDORS                    |     1 |    29 |     3 |                                                                                     
    |*  4 |   INDEX UNIQUE SCAN                              | PO_VENDORS_U1                 |     1 |       |     2 |                                                                                     
    |   5 |  VIEW                                            | POC_ASN_PICKUP_LOCATIONS_V    |     2 |  2426 |    17 |                                                                                     
    |   6 |   UNION-ALL                                      |                               |       |       |       |                                                                                     
    |   7 |    NESTED LOOPS                                  |                               |     1 |    85 |     4 |                                                                                     
    |   8 |     NESTED LOOPS                                 |                               |     1 |    78 |     4 |                                                                                     
    |*  9 |      TABLE ACCESS BY INDEX ROWID                 | PO_VENDOR_SITES_ALL           |     1 |    73 |     3 |                                                                                     
    |* 10 |       INDEX UNIQUE SCAN                          | PO_VENDOR_SITES_U2            |     1 |       |     2 |                                                                                     
    |* 11 |      INDEX UNIQUE SCAN                           | PO_VENDORS_U1                 |     1 |     5 |     1 |                                                                                     
    |* 12 |     INDEX UNIQUE SCAN                            | FND_TERRITORIES_TL_U1         |     1 |     7 |       |                                                                                     
    |  13 |    NESTED LOOPS                                  |                               |     1 |    91 |    13 |                                                                                     
    |  14 |     NESTED LOOPS                                 |                               |     1 |    84 |    13 |                                                                                     
    |  15 |      TABLE ACCESS BY INDEX ROWID                 | PO_VENDORS                    |     1 |    13 |     3 |                                                                                     
    |* 16 |       INDEX UNIQUE SCAN                          | PO_VENDORS_U1                 |     1 |       |     2 |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |* 17 |      TABLE ACCESS BY INDEX ROWID                 | FND_LOOKUP_VALUES             |     1 |    71 |    10 |                                                                                     
    |* 18 |       INDEX RANGE SCAN                           | FND_LOOKUP_VALUES_U2          |    13 |       |     2 |                                                                                     
    |* 19 |     INDEX UNIQUE SCAN                            | FND_TERRITORIES_TL_U1         |     1 |     7 |       |                                                                                     
    |* 20 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    |  21 |   TABLE ACCESS BY INDEX ROWID                    | MTL_SYSTEM_ITEMS_B            |     8 |   136 |    12 |                                                                                     
    |* 22 |    INDEX RANGE SCAN                              | MTL_SYSTEM_ITEMS_B_U1         |     8 |       |     3 |                                                                                     
    |* 23 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    |  24 |   TABLE ACCESS BY INDEX ROWID                    | MTL_SYSTEM_ITEMS_B            |     8 |   288 |    12 |                                                                                     
    |* 25 |    INDEX RANGE SCAN                              | MTL_SYSTEM_ITEMS_B_U1         |     8 |       |     3 |                                                                                     
    |  26 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 27 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |  28 |  NESTED LOOPS                                    |                               |     1 |    40 |     5 |                                                                                     
    |  29 |   TABLE ACCESS BY INDEX ROWID                    | HZ_CUST_ACCOUNTS              |     1 |    11 |     3 |                                                                                     
    |* 30 |    INDEX UNIQUE SCAN                             | HZ_CUST_ACCOUNTS_U1           |     1 |       |     2 |                                                                                     
    |  31 |   TABLE ACCESS BY INDEX ROWID                    | HZ_PARTIES                    |     1 |    29 |     2 |                                                                                     
    |* 32 |    INDEX UNIQUE SCAN                             | HZ_PARTIES_U1                 |     1 |       |     1 |                                                                                     
    |  33 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 34 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |  35 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 36 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |* 37 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |* 38 |   TABLE ACCESS BY INDEX ROWID                    | ONTC_MTC_PROFORMA_HEADERS     |     1 |    21 |     3 |                                                                                     
    |* 39 |    INDEX RANGE SCAN                              | ONTC_MTC_PROFORMA_HEADERS_U2  |     1 |       |     2 |                                                                                     
    |  40 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 41 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |* 42 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    |* 43 |   TABLE ACCESS BY INDEX ROWID                    | ONTC_MTC_PROFORMA_HEADERS     |     1 |    21 |     3 |                                                                                     
    |* 44 |    INDEX RANGE SCAN                              | ONTC_MTC_PROFORMA_HEADERS_U2  |     1 |       |     2 |                                                                                     
    |  45 |  SORT AGGREGATE                                  |                               |     1 |    39 |       |                                                                                     
    |  46 |   NESTED LOOPS OUTER                             |                               |     2 |    78 |  1828 |                                                                                     
    |* 47 |    TABLE ACCESS FULL                             | ONTC_MTC_PROFORMA_HEADERS     |     1 |    24 |  1825 |                                                                                     
    |  48 |    TABLE ACCESS BY INDEX ROWID                   | ONTC_MTC_PROFORMA_LINES       |     5 |    75 |     3 |                                                                                     
    |* 49 |     INDEX RANGE SCAN                             | ONTC_MTC_PROFORMA_LINES_PK    |    11 |       |     2 |                                                                                     
    |  50 |  NESTED LOOPS                                    |                               |     1 |   766 |  2448 |                                                                                     
    |  51 |   NESTED LOOPS                                   |                               |     1 |   761 |  2447 |                                                                                     
    |  52 |    NESTED LOOPS                                  |                               |     1 |   746 |  2445 |                                                                                     
    |  53 |     NESTED LOOPS                                 |                               |     1 |   694 |  2443 |                                                                                     
    |  54 |      NESTED LOOPS                                |                               |     1 |   682 |  2441 |                                                                                     
    |  55 |       NESTED LOOPS                               |                               |     1 |   671 |  2439 |                                                                                     
    |  56 |        NESTED LOOPS                              |                               |     1 |   612 |  2437 |                                                                                     
    |  57 |         NESTED LOOPS                             |                               |     1 |   600 |  2435 |                                                                                     
    |  58 |          NESTED LOOPS                            |                               |     1 |   575 |  2433 |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |  59 |           NESTED LOOPS                           |                               |     1 |   552 |  2431 |                                                                                     
    |  60 |            NESTED LOOPS                          |                               |     1 |   533 |  2429 |                                                                                     
    |  61 |             NESTED LOOPS                         |                               |     1 |   524 |  2428 |                                                                                     
    |  62 |              NESTED LOOPS                        |                               |     1 |   455 |  2427 |                                                                                     
    |  63 |               NESTED LOOPS                       |                               |     1 |   429 |  2426 |                                                                                     
    |  64 |                NESTED LOOPS                      |                               |     1 |   389 |  2424 |                                                                                     
    |  65 |                 NESTED LOOPS                     |                               |     1 |   368 |  2422 |                                                                                     
    |  66 |                  NESTED LOOPS                    |                               |     1 |   308 |  2421 |                                                                                     
    |  67 |                   NESTED LOOPS                   |                               |     1 |   281 |  2419 |                                                                                     
    |  68 |                    NESTED LOOPS                  |                               |     1 |   253 |  2418 |                                                                                     
    |  69 |                     NESTED LOOPS                 |                               |     1 |   214 |  2416 |                                                                                     
    |  70 |                      NESTED LOOPS                |                               |    39 |  7371 |  2338 |                                                                                     
    |* 71 |                       TABLE ACCESS FULL          | RCV_SHIPMENT_HEADERS          |    39 |  5070 |  2221 |                                                                                     
    |* 72 |                       TABLE ACCESS BY INDEX ROWID| RCV_SHIPMENT_LINES            |     1 |    59 |     3 |                                                                                     
    |* 73 |                        INDEX RANGE SCAN          | RCV_SHIPMENT_LINES_U2         |     1 |       |     2 |                                                                                     
    |* 74 |                      TABLE ACCESS BY INDEX ROWID | PO_LINES_ALL                  |     1 |    25 |     2 |                                                                                     
    |* 75 |                       INDEX UNIQUE SCAN          | PO_LINES_U1                   |     1 |       |     1 |                                                                                     
    |* 76 |                     TABLE ACCESS BY INDEX ROWID  | PO_LINE_LOCATIONS_ALL         |     1 |    39 |     2 |                                                                                     
    |* 77 |                      INDEX UNIQUE SCAN           | PO_LINE_LOCATIONS_U1          |     1 |       |     1 |                                                                                     
    |* 78 |                    TABLE ACCESS BY INDEX ROWID   | PO_HEADERS_ALL                |     1 |    28 |     1 |                                                                                     
    |* 79 |                     INDEX UNIQUE SCAN            | PO_HEADERS_U1                 |     1 |       |       |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |* 80 |                   TABLE ACCESS BY INDEX ROWID    | OE_ORDER_LINES_ALL            |     1 |    27 |     2 |                                                                                     
    |* 81 |                    INDEX UNIQUE SCAN             | OE_ORDER_LINES_U1             |     1 |       |     1 |                                                                                     
    |  82 |                  TABLE ACCESS BY INDEX ROWID     | OE_ORDER_HEADERS_ALL          |     1 |    60 |     1 |                                                                                     
    |* 83 |                   INDEX UNIQUE SCAN              | OE_ORDER_HEADERS_U1           |     1 |       |       |                                                                                     
    |* 84 |                 TABLE ACCESS BY INDEX ROWID      | HZ_CUST_SITE_USES_ALL         |     1 |    21 |     2 |                                                                                     
    |* 85 |                  INDEX UNIQUE SCAN               | HZ_CUST_SITE_USES_U1          |     1 |       |     1 |                                                                                     
    |* 86 |                TABLE ACCESS BY INDEX ROWID       | HZ_CUST_SITE_USES_ALL         |     1 |    40 |     2 |                                                                                     
    |* 87 |                 INDEX UNIQUE SCAN                | HZ_CUST_SITE_USES_U1          |     1 |       |     1 |                                                                                     
    |  88 |               TABLE ACCESS BY INDEX ROWID        | WSH_CARRIERS                  |     1 |    26 |     1 |                                                                                     
    |* 89 |                INDEX UNIQUE SCAN                 | WSH_CARRIERS_U2               |     1 |       |       |                                                                                     
    |* 90 |              TABLE ACCESS BY INDEX ROWID         | WSH_CARRIER_SERVICES          |     1 |    69 |     1 |                                                                                     
    |* 91 |               INDEX RANGE SCAN                   | WSH_CARRIER_SERVICES_N1       |     2 |       |       |                                                                                     
    |* 92 |             TABLE ACCESS BY INDEX ROWID          | WSH_ORG_CARRIER_SERVICES      |     1 |     9 |     1 |                                                                                     
    |* 93 |              INDEX RANGE SCAN                    | WSH_ORG_CARRIER_SERVICES_N1   |     1 |       |       |                                                                                     
    |  94 |            TABLE ACCESS BY INDEX ROWID           | HZ_CUST_ACCOUNTS              |     1 |    19 |     2 |                                                                                     
    |* 95 |             INDEX UNIQUE SCAN                    | HZ_CUST_ACCOUNTS_U1           |     1 |       |     1 |                                                                                     
    |* 96 |           TABLE ACCESS BY INDEX ROWID            | HZ_CUST_ACCT_SITES_ALL        |     1 |    23 |     2 |                                                                                     
    |* 97 |            INDEX UNIQUE SCAN                     | HZ_CUST_ACCT_SITES_U1         |     1 |       |     1 |                                                                                     
    |* 98 |          TABLE ACCESS BY INDEX ROWID             | HZ_CUST_ACCT_SITES_ALL        |     1 |    25 |     2 |                                                                                     
    |* 99 |           INDEX UNIQUE SCAN                      | HZ_CUST_ACCT_SITES_U1         |     1 |       |     1 |                                                                                     
    | 100 |         TABLE ACCESS BY INDEX ROWID              | HZ_PARTY_SITES                |     1 |    12 |     2 |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |*101 |          INDEX UNIQUE SCAN                       | HZ_PARTY_SITES_U1             |     1 |       |     1 |                                                                                     
    | 102 |        TABLE ACCESS BY INDEX ROWID               | HZ_LOCATIONS                  |     1 |    59 |     2 |                                                                                     
    |*103 |         INDEX UNIQUE SCAN                        | HZ_LOCATIONS_U1               |     1 |       |     1 |                                                                                     
    |*104 |       INDEX RANGE SCAN                           | HZ_LOC_ASSIGNMENTS_N1         |     1 |    11 |     2 |                                                                                     
    | 105 |      TABLE ACCESS BY INDEX ROWID                 | HZ_PARTY_SITES                |     1 |    12 |     2 |                                                                                     
    |*106 |       INDEX UNIQUE SCAN                          | HZ_PARTY_SITES_U1             |     1 |       |     1 |                                                                                     
    | 107 |     TABLE ACCESS BY INDEX ROWID                  | HZ_LOCATIONS                  |     1 |    52 |     2 |                                                                                     
    |*108 |      INDEX UNIQUE SCAN                           | HZ_LOCATIONS_U1               |     1 |       |     1 |                                                                                     
    |*109 |    INDEX RANGE SCAN                              | HZ_LOC_ASSIGNMENTS_N1         |     1 |    15 |     2 |                                                                                     
    |*110 |   INDEX UNIQUE SCAN                              | HZ_PARTIES_U1                 |     1 |     5 |     1 |                                                                                     
    I will put the predicate information in another post.
    193 rows selected.
    SQL> spool offPlease suggest on how can we improve the performance.
    Regards,
    Sreekanth Munagala.

  • Query taking way too long

    Hello,
    Can somebody please help.
    I am wanting to change this query so that it does not take too long. How can I do it please?
    select count(*), t.tel_no, t.prospect_id, a.ACCOUNT_NO, a.account_title
    from tel_nos t, account a
    where t.tel_type = 'S'
    AND t.prospect_id = a.prospect_id
    AND SYSDATE BETWEEN t.start_date AND NVL(t.end_date, SYSDATE)
    group by t.tel_no, t.prospect_id, a.ACCOUNT_NO, a.account_title
    having count(*) > 1
    Thanks in advance.

    Tuning is a science not a parlour guessing game. It's hard for us to diagnose the problem you have here as you have given us almost no information. For instance, are you using rule based or cost based optimizer? How big are these two tables? What indexes do they have? What percentage of rows are you expecting the query to return?
    Tuning is such a big area that it's hard to know where to begin. I suggest you start at the Oracle docs. Chapters 1, 4 and 5 will set you going.
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76992/toc.htm
    Having said all that you may well find this runs faster:
    SELECT count(*), t.tel_no, t.prospect_id, a.account_no, a.account_title
    FROM   account a, tel_nos t
    WHERE  t.tel_type = 'S'
    AND    sysdate BETWEEN t.start_date AND nvl(t.end_date, sysdate)
    AND    t.prospect_id = a.prospect_id
    GROUP  BY t.tel_no, t.prospect_id, a.account_no, a.account_title
    HAVING count(*) > 1
    /I leave it to you to work out why (it's nothing to do with clearer layout).
    Cheers, APC

Maybe you are looking for

  • Reg :Production order cost  report day wise.

    Dear Expert, 1.We want a report for a particular Production order cost  day wise. The scenario is like this Production order is Released for 100 Qty. Today they confirmed only 50 Qty. Tomorrow they will confirm 50 qty. Now they want to see the cost f

  • IPhone 4 in Recovery Mode--will I get my photos&videos back when I restore?

    Last night, after syncing my iPhone 4, I attempted to download and install the latest iPhone software. It downloaded (after 3 hours which was crazy especially since download and successful installation took less than an hour with my husband's iPhone

  • Call Forwarding Number on 3G Not Retained as it was on Original iPhone

    On the original iPhone I could turn call forwarding on and off and the number I had set to have calls forwarded to was retained when I turned forwarding back on. With the 3G the number to be forwarded to needs to re-entered each time I turn call forw

  • AP: Discounts

    Hi I've a question on discounts for incoming invoices. The business practise is for any incoming invoice, we break it to two parts based on percentages (80-20), for which one is paid directly to the vendor, but the other one is blocked for payment. C

  • While executing applyServerBehaviour in ShowifRSNotEmpty.htm, a JavaScript error occurred?

    Hi forum, Long time no post! Well, I've been trying out mySQL and Dreamweaver. I've found a book called Dreamweaver MX 2004 Design Projects and I am trying to write and get working Allan Kent's News Portal site as it seems to have all the things I wa