Query taking long to execute
Hello
One of my report taking long to execute. i have range base partition on table and indexes by month. following are the details
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 7 13:41:04 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
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.1
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 10
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 64
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 16384
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL>
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS AUTOGATHERING
SYSSTATS_INFO DSTART 10-07-2011 14:12
SYSSTATS_INFO DSTOP 10-07-2011 14:42
SYSSTATS_INFO FLAGS 0
SYSSTATS_MAIN CPUSPEEDNW 2526.08695652174
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
SYSSTATS_TEMP SBLKRDS 640991392
SYSSTATS_TEMP SBLKRDTIM 23353628654370
SYSSTATS_TEMP MBLKRDS 128258266
SYSSTATS_TEMP MBLKRDTIM 6812382430610
SYSSTATS_TEMP CPUCYCLES 75032664
SYSSTATS_TEMP CPUTIM 29682662
SYSSTATS_TEMP JOB 12769
SYSSTATS_TEMP CACHE_JOB 12770
SYSSTATS_TEMP MBRTOTAL 3373935275
22 rows selected Any help or suggestion to improve its performance ?
Execution plan is
PLAN_TABLE_OUTPUT
Plan hash value: 2727856908
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
| 0 | SELECT STATEMENT | | 1 | 1183 | 138K (1)| 00:32:21 | | | | | |
|* 1 | COUNT STOPKEY | | | | | | | | | | |
| 2 | PX COORDINATOR | | | | | | | | | | |
| 3 | PX SEND QC (ORDER) | :TQ10008 | 1 | 1183 | 138K (1)| 00:32:21 | | | Q1,08 | P->S | QC (ORDER) |
| 4 | VIEW | | 1 | 1183 | 138K (1)| 00:32:21 | | | Q1,08 | PCWP | |
|* 5 | SORT ORDER BY STOPKEY | | 1 | 400 | 138K (1)| 00:32:21 | | | Q1,08 | PCWP | |
| 6 | PX RECEIVE | | 1 | 1183 | | | | | Q1,08 | PCWP | |
| 7 | PX SEND RANGE | :TQ10007 | 1 | 1183 | | | | | Q1,07 | P->P | RANGE |
|* 8 | SORT ORDER BY STOPKEY | | 1 | 1183 | | | | | Q1,07 | PCWP | |
| 9 | NESTED LOOPS | | | | | | | | Q1,07 | PCWP | |
| 10 | NESTED LOOPS | | 1 | 400 | 138K (1)| 00:32:21 | | | Q1,07 | PCWP | |
| 11 | NESTED LOOPS | | 1 | 377 | 138K (1)| 00:32:21 | | | Q1,07 | PCWP | |
| 12 | NESTED LOOPS | | 1 | 341 | 138K (1)| 00:32:21 | | | Q1,07 | PCWP | |
|* 13 | HASH JOIN | | 1 | 324 | 138K (1)| 00:32:21 | | | Q1,07 | PCWP | |
| 14 | PX RECEIVE | | 1 | 289 | 123K (1)| 00:28:53 | | | Q1,07 | PCWP | |
| 15 | PX SEND BROADCAST | :TQ10006 | 1 | 289 | 123K (1)| 00:28:53 | | | Q1,06 | P->P | BROADCAST |
|* 16 | HASH JOIN | | 1 | 289 | 123K (1)| 00:28:53 | | | Q1,06 | PCWP | |
| 17 | PX RECEIVE | | 4 | 1016 | 123K (1)| 00:28:51 | | | Q1,06 | PCWP | |
| 18 | PX SEND BROADCAST | :TQ10005 | 4 | 1016 | 123K (1)| 00:28:51 | | | Q1,05 | P->P | BROADCAST |
|* 19 | HASH JOIN OUTER BUFFERED | | 4 | 1016 | 123K (1)| 00:28:51 | | | Q1,05 | PCWP | |
| 20 | PX RECEIVE | | | | | | | | Q1,05 | PCWP | |
| 21 | PX SEND HASH | :TQ10003 | | | | | | | Q1,03 | P->P | HASH |
| 22 | NESTED LOOPS | | | | | | | | Q1,03 | PCWP | |
| 23 | NESTED LOOPS | | 4 | 892 | 123K (1)| 00:28:51 | | | Q1,03 | PCWP | |
| 24 | NESTED LOOPS | | 6 | 948 | 123K (1)| 00:28:51 | | | Q1,03 | PCWP | |
| 25 | NESTED LOOPS | | 7 | 1043 | 123K (1)| 00:28:51 | | | Q1,03 | PCWP | |
|* 26 | HASH JOIN | | 5784 | 728K| 118K (1)| 00:27:45 | | | Q1,03 | PCWP | |
| 27 | PX RECEIVE | | 667K| 26M| 11597 (1)| 00:02:43 | | | Q1,03 | PCWP | |
| 28 | PX SEND BROADCAST | :TQ10000 | 667K| 26M| 11597 (1)| 00:02:43 | | | Q1,00 | P->P | BROADCAST |
| 29 | PX PARTITION RANGE ALL | | 667K| 26M| 11597 (1)| 00:02:43 | 1 | 14 | Q1,00 | PCWC | |
| 30 | WID TABLE ACCESS BY LOCAL INDEX RO | PAH01V1_DG1 | 667K| 26M| 11597 (1)| 00:02:43 | 1 | 14 | Q1,00 | PCWP | |
| 31 | BITMAP CONVERSION TO ROWIDS | | | | | | | | Q1,00 | PCWP | |
|* 32 | BITMAP INDEX SINGLE VALUE | MINDX_PAH01V1_DG1_14 | | | | | 1 | 14 | Q1,00 | PCWP | |
|* 33 | HASH JOIN | | 1826K| 151M| 107K (1)| 00:25:03 | | | Q1,03 | PCWP | |
| 34 | PX RECEIVE | | 2682 | 18774 | 58 (0)| 00:00:01 | | | Q1,03 | PCWP | |
| 35 | PX SEND BROADCAST | :TQ10001 | 2682 | 18774 | 58 (0)| 00:00:01 | | | Q1,01 | P->P | BROADCAST |
| 36 | PX BLOCK ITERATOR | | 2682 | 18774 | 58 (0)| 00:00:01 | 1 | 14 | Q1,01 | PCWC | |
| 37 | TABLE ACCESS FULL | PAH01V1_DG3 | 2682 | 18774 | 58 (0)| 00:00:01 | 1 | 14 | Q1,01 | PCWP | |
|* 38 | HASH JOIN | | 2409K| 183M| 107K (1)| 00:25:02 | | | Q1,03 | PCWP | |
| 39 | PX RECEIVE | | 476K| 19M| 5904 (1)| 00:01:23 | | | Q1,03 | PCWP | |
| 40 | PX SEND BROADCAST | :TQ10002 | 476K| 19M| 5904 (1)| 00:01:23 | | | Q1,02 | P->P | BROADCAST |
| 41 | PX PARTITION RANGE ALL | | 476K| 19M| 5904 (1)| 00:01:23 | 1 | 14 | Q1,02 | PCWC | |
| 42 | ROWID TABLE ACCESS BY LOCAL INDEX | PAH01V1_DG5 | 476K| 19M| 5904 (1)| 00:01:23 | 1 | 14 | Q1,02 | PCWP | |
| 43 | BITMAP CONVERSION TO ROWIDS | | | | | | | | Q1,02 | PCWP | |
| 44 | BITMAP MINUS | | | | | | | | Q1,02 | PCWP | |
| 45 | BITMAP MINUS | | | | | | | | Q1,02 | PCWP | |
| 46 | BITMAP MERGE | | | | | | | | Q1,02 | PCWP | |
| 47 | BITMAP INDEX FULL SCAN | MINDX_PAH01V1_DG517 | | | | | 1 | 14 | Q1,02 | PCWP | |
|* 48 | E BITMAP INDEX SINGLE VALU | MINDX_PAH01V1_DG5_3 | | | | | 1 | 14 | Q1,02 | PCWP | |
|* 49 | BITMAP INDEX SINGLE VALUE | MINDX_PAH01V1_DG5_3 | | | | | 1 | 14 | Q1,02 | PCWP | |
| 50 | PX BLOCK ITERATOR | | 275M| 9G| 101K (1)| 00:23:37 | 1 | 14 | Q1,03 | PCWC | |
|* 51 | TABLE ACCESS FULL | PAH01V1_JT | 275M| 9G| 101K (1)| 00:23:37 | 1 | 14 | Q1,03 | PCWP | |
| 52 | PARTITION RANGE ALL | | 1 | 20 | 1 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
|* 53 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG2 | 1 | 20 | 1 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
|* 54 | INDEX RANGE SCAN | PKINDX_PAH01V1_DG2_28 | 1 | | 1 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
| 55 | PARTITION RANGE ALL | | 1 | 9 | 0 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
| 56 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG4 | 1 | 9 | 0 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
|* 57 | INDEX RANGE SCAN | PKINDX_PAH01V1_DG4 | 1 | | 0 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
| 58 | PARTITION RANGE ALL | | 1 | | 1 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
|* 59 | INDEX RANGE SCAN | PKINDX_PAH01V1_DG0 | 1 | | 1 (0)| 00:00:01 | 1 | 14 | Q1,03 | PCWP | |
| 60 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG0 | 1 | 65 | 1 (0)| 00:00:01 | 1 | 1 | Q1,03 | PCWP | |
| 61 | PX RECEIVE | | 296 | 9176 | 2 (0)| 00:00:01 | | | Q1,05 | PCWP | |
| 62 | PX SEND HASH | :TQ10004 | 296 | 9176 | 2 (0)| 00:00:01 | | | Q1,04 | P->P | HASH |
| 63 | PX BLOCK ITERATOR | | 296 | 9176 | 2 (0)| 00:00:01 | | | Q1,04 | PCWC | |
| 64 | TABLE ACCESS FULL | PAH01V1_STORE_LKP | 296 | 9176 | 2 (0)| 00:00:01 | | | Q1,04 | PCWP | |
| 65 | PX PARTITION RANGE ITERATOR | | 1571K| 52M| 167 (1)| 00:00:03 | KEY | 14 | Q1,06 | PCWC | |
| 66 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG0 | 1571K| 52M| 167 (1)| 00:00:03 | KEY | 14 | Q1,06 | PCWP | |
| 67 | BITMAP CONVERSION TO ROWIDS | | | | | | | | Q1,06 | PCWP | |
| 68 | BITMAP AND | | | | | | | | Q1,06 | PCWP | |
| 69 | BITMAP MERGE | | | | | | | | Q1,06 | PCWP | |
|* 70 | BITMAP INDEX RANGE SCAN | MINDX_PAH01V1_DG022 | | | | | KEY | 14 | Q1,06 | PCWP | |
| 71 | BITMAP MERGE | | | | | | | | Q1,06 | PCWP | |
|* 72 | BITMAP INDEX RANGE SCAN | MINDX_PAH01V1_DG0_8 | | | | | KEY | 14 | Q1,06 | PCWP | |
| 73 | PX PARTITION RANGE ITERATOR | | 2594K| 86M| 14858 (1)| 00:03:29 | KEY | 14 | Q1,07 | PCWC | |
| 74 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_JT | 2594K| 86M| 14858 (1)| 00:03:29 | KEY | 14 | Q1,07 | PCWP | |
| 75 | BITMAP CONVERSION TO ROWIDS | | | | | | | | Q1,07 | PCWP | |
|* 76 | BITMAP INDEX RANGE SCAN | MINDX_PAH01V1_JT_PF_ | | | | | KEY | 14 | Q1,07 | PCWP | |
| 77 | PARTITION RANGE ITERATOR | | 1 | 17 | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
|* 78 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG2 | 1 | 17 | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
|* 79 | INDEX RANGE SCAN | PKINDX_PAH01V1_DG2_28 | 1 | | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
| 80 | PARTITION RANGE ITERATOR | | 1 | 36 | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
| 81 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG5 | 1 | 36 | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
|* 82 | INDEX RANGE SCAN | PKINDX_PAH01V1_DG5_18 | 1 | | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
| 83 | PARTITION RANGE ITERATOR | | 1 | | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
|* 84 | INDEX RANGE SCAN | PKINDX_PAH01V1_DG1_22 | 1 | | 1 (0)| 00:00:01 | KEY | 14 | Q1,07 | PCWP | |
|* 85 | TABLE ACCESS BY LOCAL INDEX ROWID | PAH01V1_DG1 | 1 | 23 | 1 (0)| 00:00:01 | 1 | 1 | Q1,07 | PCWP | |
135 rows selected
Similar Messages
-
Query taking longer to execute the second time.
Hello,
I have a query joing few tables and views and when i execute it the first them, it executes within a seconds, immediately if i execute it the second time it takes about 40 seconds to execute. I am using Oracle 11g [11.2.0.1.0].
Please find the TKPROF output.
call count cpu elapsed disk query current rows
Parse 1 0.26 0.24 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 23 0.81 0.82 0 5610 0 326
total 25 1.07 1.07 0 5610 0 326
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 127
call count cpu elapsed disk query current rows
Parse 1 0.23 0.23 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 23 41.01 41.00 0 38218 0 326
total 25 41.24 41.24 0 38218 0 326
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 127Hi Nicholay,
VPD is not being used in our application. ArcSDE Multi-Versionsed View uses some functions in VW_ objects. In Oracle 10g I dont have this issue.
Here is the output from V$SQL_SHARED_CURSOR.
"SQL_ID" "ADDRESS" "CHILD_ADDRESS" "CHILD_NUMBER" "UNBOUND_CURSOR" "SQL_TYPE_MISMATCH" "OPTIMIZER_MISMATCH" "OUTLINE_MISMATCH" "STATS_ROW_MISMATCH" "LITERAL_MISMATCH" "FORCE_HARD_PARSE" "EXPLAIN_PLAN_CURSOR" "BUFFERED_DML_MISMATCH" "PDML_ENV_MISMATCH" "INST_DRTLD_MISMATCH" "SLAVE_QC_MISMATCH" "TYPECHECK_MISMATCH" "AUTH_CHECK_MISMATCH" "BIND_MISMATCH" "DESCRIBE_MISMATCH" "LANGUAGE_MISMATCH" "TRANSLATION_MISMATCH" "BIND_EQUIV_FAILURE" "INSUFF_PRIVS" "INSUFF_PRIVS_REM" "REMOTE_TRANS_MISMATCH" "LOGMINER_SESSION_MISMATCH" "INCOMP_LTRL_MISMATCH" "OVERLAP_TIME_MISMATCH" "EDITION_MISMATCH" "MV_QUERY_GEN_MISMATCH" "USER_BIND_PEEK_MISMATCH" "TYPCHK_DEP_MISMATCH" "NO_TRIGGER_MISMATCH" "FLASHBACK_CURSOR" "ANYDATA_TRANSFORMATION" "INCOMPLETE_CURSOR" "TOP_LEVEL_RPI_CURSOR" "DIFFERENT_LONG_LENGTH" "LOGICAL_STANDBY_APPLY" "DIFF_CALL_DURN" "BIND_UACS_DIFF" "PLSQL_CMP_SWITCHS_DIFF" "CURSOR_PARTS_MISMATCH" "STB_OBJECT_MISMATCH" "CROSSEDITION_TRIGGER_MISMATCH""PQ_SLAVE_MISMATCH" "TOP_LEVEL_DDL_MISMATCH" "MULTI_PX_MISMATCH" "BIND_PEEKED_PQ_MISMATCH" "MV_REWRITE_MISMATCH" "ROLL_INVALID_MISMATCH" "OPTIMIZER_MODE_MISMATCH" "PX_MISMATCH" "MV_STALEOBJ_MISMATCH" "FLASHBACK_TABLE_MISMATCH" "LITREP_COMP_MISMATCH" "PLSQL_DEBUG" "LOAD_OPTIMIZER_STATS" "ACL_MISMATCH" "FLASHBACK_ARCHIVE_MISMATCH" "LOCK_USER_SCHEMA_FAILED" "REMOTE_MAPPING_MISMATCH" "LOAD_RUNTIME_HEAP_FAILED" "HASH_MATCH_FAILED" "PURGED_CURSOR" "BIND_LENGTH_UPGRADEABLE"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD49C88" "1" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD3A7B8" "0" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD46A40" "2" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD3A7B8" "0" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD49C88" "1" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD46A40" "2" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD3A7B8" "0" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD49C88" "1" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N"
"7rtqvjtyp06k9" "000007FFABD3A918" "000007FFABD46A40" "2" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" "N" Edited by: 955237 on 29 Aug, 2012 1:57 AM -
Query taking long time for EXTRACTING the data more than 24 hours
Hi ,
Query taking long time for EXTRACTING the data more than 24 hours please find the query and explain plan details below even indexes avilable on table's goe's to FULL TABLE SCAN. please suggest me.......
SQL> explain plan for select a.account_id,round(a.account_balance,2) account_balance,
2 nvl(ah.invoice_id,ah.adjustment_id) transaction_id,
to_char(ah.effective_start_date,'DD-MON-YYYY') transaction_date,
to_char(nvl(i.payment_due_date,
to_date('30-12-9999','dd-mm-yyyy')),'DD-MON-YYYY')
due_date, ah.current_balance-ah.previous_balance amount,
decode(ah.invoice_id,null,'A','I') transaction_type
3 4 5 6 7 8 from account a,account_history ah,invoice i_+
where a.account_id=ah.account_id
and a.account_type_id=1000002
and round(a.account_balance,2) > 0
and (ah.invoice_id is not null or ah.adjustment_id is not null)
and ah.CURRENT_BALANCE > ah.previous_balance
and ah.invoice_id=i.invoice_id(+)
AND a.account_balance > 0
order by a.account_id,ah.effective_start_date desc; 9 10 11 12 13 14 15 16
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | SELECT STATEMENT | | 544K| 30M| | 693K (20)|
| 1 | SORT ORDER BY | | 544K| 30M| 75M| 693K (20)|
|* 2 | HASH JOIN | | 544K| 30M| | 689K (20)|
|* 3 | TABLE ACCESS FULL | ACCOUNT | 20080 | 294K| | 6220 (18)|
|* 4 | HASH JOIN OUTER | | 131M| 5532M| 5155M| 678K (20)|
|* 5 | TABLE ACCESS FULL| ACCOUNT_HISTORY | 131M| 3646M| | 197K (25)|
| 6 | TABLE ACCESS FULL| INVOICE | 262M| 3758M| | 306K (18)|
Predicate Information (identified by operation id):
2 - access("A"."ACCOUNT_ID"="AH"."ACCOUNT_ID")
3 - filter("A"."ACCOUNT_TYPE_ID"=1000002 AND "A"."ACCOUNT_BALANCE">0 AND
ROUND("A"."ACCOUNT_BALANCE",2)>0)
4 - access("AH"."INVOICE_ID"="I"."INVOICE_ID"(+))
5 - filter("AH"."CURRENT_BALANCE">"AH"."PREVIOUS_BALANCE" AND ("AH"."INVOICE_ID"
IS NOT NULL OR "AH"."ADJUSTMENT_ID" IS NOT NULL))
22 rows selected.
Index Details:+_
SQL> select INDEX_OWNER,INDEX_NAME,COLUMN_NAME,TABLE_NAME from dba_ind_columns where
2 table_name in ('INVOICE','ACCOUNT','ACCOUNT_HISTORY') order by 4;
INDEX_OWNER INDEX_NAME COLUMN_NAME TABLE_NAME
OPS$SVM_SRV4 P_ACCOUNT ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME ACCOUNT_NAME ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT CUSTOMER_NODE_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT ACCOUNT_TYPE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_ACCOUNT_TYPE ACCOUNT_TYPE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_INVOICE INVOICE_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_PREVIOUS_INVOICE PREVIOUS_INVOICE_ID ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_NAME ACCOUNT
OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 I_LAST_MODIFIED_ACCOUNT LAST_MODIFIED ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_INVOICE_ACCOUNT INVOICE_ACCOUNT_ID ACCOUNT
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT ACCOUNT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT SEQNR ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_INVOICE INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA CURRENT_BALANCE ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA INVOICE_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ACCOUNT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_LMOD LAST_MODIFIED ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_PAYMENT PAYMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADJUSTMENT ADJUSTMENT_ID ACCOUNT_HISTORY
OPS$SVM_SRV4 I_ACCOUNT_HISTORY_APPLIED_DT APPLIED_DATE ACCOUNT_HISTORY
OPS$SVM_SRV4 P_INVOICE INVOICE_ID INVOICE
OPS$SVM_SRV4 U_INVOICE CUSTOMER_INVOICE_STR INVOICE
OPS$SVM_SRV4 I_LAST_MODIFIED_INVOICE LAST_MODIFIED INVOICE
OPS$SVM_SRV4 U_INVOICE_ACCOUNT ACCOUNT_ID INVOICE
OPS$SVM_SRV4 U_INVOICE_ACCOUNT BILL_RUN_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_BILL_RUN BILL_RUN_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_INVOICE_TYPE INVOICE_TYPE_ID INVOICE
OPS$SVM_SRV4 I_INVOICE_CUSTOMER_NODE CUSTOMER_NODE_ID INVOICE
32 rows selected.
Regards,
Bathula
Oracle-DBAI have some suggestions. But first, you realize that you have some redundant indexes, right? You have an index on account(account_name) and also account(account_name, account_id), and also account_history(invoice_id) and account_history(invoice_id, adjustment_id). No matter, I will suggest some new composite indexes.
Also, you do not need two lines for these conditions:
and round(a.account_balance, 2) > 0
AND a.account_balance > 0
You can just use: and a.account_balance >= 0.005
So the formatted query isselect a.account_id,
round(a.account_balance, 2) account_balance,
nvl(ah.invoice_id, ah.adjustment_id) transaction_id,
to_char(ah.effective_start_date, 'DD-MON-YYYY') transaction_date,
to_char(nvl(i.payment_due_date, to_date('30-12-9999', 'dd-mm-yyyy')),
'DD-MON-YYYY') due_date,
ah.current_balance - ah.previous_balance amount,
decode(ah.invoice_id, null, 'A', 'I') transaction_type
from account a, account_history ah, invoice i
where a.account_id = ah.account_id
and a.account_type_id = 1000002
and (ah.invoice_id is not null or ah.adjustment_id is not null)
and ah.CURRENT_BALANCE > ah.previous_balance
and ah.invoice_id = i.invoice_id(+)
AND a.account_balance >= .005
order by a.account_id, ah.effective_start_date desc;You will probably want to select:
1. From ACCOUNT first (your smaller table), for which you supply a literal on account_type_id. That should limit the accounts retrieved from ACCOUNT_HISTORY
2. From ACCOUNT_HISTORY. We want to limit the records as much as possible on this table because of the outer join.
3. INVOICE we want to access last because it seems to be least restricted, it is the biggest, and it has the outer join condition so it will manufacture rows to match as many rows as come back from account_history.
Try the query above after creating the following composite indexes. The order of the columns is important:create index account_composite_i on account(account_type_id, account_balance, account_id);
create index acct_history_comp_i on account_history(account_id, invoice_id, adjustment_id, current_balance, previous_balance, effective_start_date);
create index invoice_composite_i on invoice(invoice_id, payment_due_date);All the columns used in the where clause will be indexed, in a logical order suited to the needs of the query. Plus each selected column is indexed as well so that we should not need to touch the tables at all to satisfy the query.
Try the query after creating these indexes.
A final suggestion is to try larger sort and hash area sizes and a manual workarea policy.alter session set workarea_size_policy = manual;
alter session set sort_area_size = 2147483647;
alter session set hash_area_size = 2147483647; -
SQL Query taking longer time as seen from Trace file
Below Query Execution timings:
Any help will be benefitial as its affecting business needs.
SELECT MATERIAL_DETAIL_ID
FROM
GME_MATERIAL_DETAILS WHERE BATCH_ID = :B1 FOR UPDATE OF ACTUAL_QTY NOWAIT
call count cpu elapsed disk query current rows
Parse 1 0.00 0.70 0 0 0 0
Execute 2256 8100.00 24033.51 627 12298 31739 0
Fetch 2256 900.00 949.82 0 12187 0 30547
total 4513 9000.00 24984.03 627 24485 31739 30547
Thanks and RegardsThanks Buddy.
Data Collected from Trace file:
SELECT STEP_CLOSE_DATE
FROM
GME_BATCH_STEPS WHERE BATCH_ID
IN (SELECT
DISTINCT BATCH_ID FROM
GME_MATERIAL_DETAILS START WITH BATCH_ID = :B2 CONNECT BY PRIOR PHANTOM_ID=BATCH_ID)
AND NVL(STEP_CLOSE_DATE, :B1) > :B1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.54 0 0 0 0
Execute 2256 800.00 1120.32 0 0 0 0
Fetch 2256 9100.00 13551.45 396 77718 0 0
total 4513 9900.00 14672.31 396 77718 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 66 (recursive depth: 1)
Rows Row Source Operation
0 TABLE ACCESS BY INDEX ROWID GME_BATCH_STEPS
13160 NESTED LOOPS
6518 VIEW
6518 SORT UNIQUE
53736 CONNECT BY WITH FILTERING
30547 NESTED LOOPS
30547 INDEX RANGE SCAN GME_MATERIAL_DETAILS_U1 (object id 146151)
30547 TABLE ACCESS BY USER ROWID GME_MATERIAL_DETAILS
23189 NESTED LOOPS
53736 BUFFER SORT
53736 CONNECT BY PUMP
23189 TABLE ACCESS BY INDEX ROWID GME_MATERIAL_DETAILS
23189 INDEX RANGE SCAN GME_MATERIAL_DETAILS_U1 (object id 146151)
4386 INDEX RANGE SCAN GME_BATCH_STEPS_U1 (object id 146144)
In the Package there are lots of SQL Statements using CONNECT BY CLAUSE.
Does the use of CONNECT BY Clause degrades performance?
As you can see the Rows Section is 0 but the Query and elapsed time is taking longer
Regards -
Hello,
i have created one query based on inventory cube 0IC_C03. when i am executing the infocube based on a particular date i am able to see the output but when i am executing the query on the basis of that particular date given while executing the cube the query is taking long time to execute and throwing a message of time limit exceed.
could anyone suggest me why the query is showing such nessage along with resolution.
Thanks,
Kumkum
Edited by: kumkum basu on Nov 29, 2010 2:33 PMHi,
There can be number of reason.
What you can do is:-
put the unwanted characteristics in Free Characteristics
Remove unwanted cell reference
Try using partitions in cubes
Use aggregates for summarised data.
f the above options doesnt work, then try pre-caching.This will definitely help!
Use proper selections to get small subset of data.
Goto RSRT>> type your query name>> Query properties>> select cache mode=4
In addition to RSRT, ST05 (sql trace), SE30 (runtime analysis) and system statistics (ST03) may help you in identifying performance issues with a report.
Thanks,.
Saveen Kumar -
Query taking long time to run.
The following query is taking long time to run, is there anything can be done to make it run faster by changing the sql etc.
select distinct
A.DEPTID,
A.POSITION_NBR,
A.EMPLID,
A.EMPL_RCD_NBR,
A.EFFDT,
B.NAME,
A.EMPL_STATUS,
A.JOBCODE,
A.ANNUAL_RT,
A.STD_HOURS,
A.PRIMARY_JOB,
C.POSN_STATUS,
case when A.POSITION_NBR = ' ' then 0 else C.STD_HOURS end,
case when A.POSITION_NBR = ' ' then ' ' else C.DEPTID end
from PS_JOB A,
PS_PERSONAL_DATA B,
PS_POSITION_DATA C
where A.EMPLID = B.EMPLID
and
((A.POSITION_NBR = C.POSITION_NBR
and A.EFFSEQ = (select max(D.EFFSEQ)
from PS_JOB D
where D.EMPLID = A.EMPLID
and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and D.EFFDT = A.EFFDT)
and C.POSN_STATUS <> 'G'
and C.EFFDT = (select max(E.EFFDT)
from PS_POSITION_DATA E
where E.POSITION_NBR = A.POSITION_NBR
and E.EFFDT <= A.EFFDT)
and C.EFFSEQ = (select max(F.EFFSEQ)
from PS_POSITION_DATA F
where F.POSITION_NBR = A.POSITION_NBR
and F.EFFDT = C.EFFDT))
or
(A.POSITION_NBR = C.POSITION_NBR
and A.EFFDT = (select max(D.EFFDT)
from PS_JOB D
where D.EMPLID = A.EMPLID
and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and D.EFFDT <= C.EFFDT)
and A.EFFSEQ = (select max(E.EFFSEQ)
from PS_JOB E
where E.EMPLID = A.EMPLID
and E.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and E.EFFDT = A.EFFDT)
and C.POSN_STATUS <> 'G'
and C.EFFSEQ = (select max(F.EFFSEQ)
from PS_POSITION_DATA F
where F.POSITION_NBR = A.POSITION_NBR
and F.EFFDT = C.EFFDT)))
or
(A.POSITION_NBR = ' '
and A.EFFSEQ = (select max(E.EFFSEQ)
from PS_JOB D
where D.EMPLID = A.EMPLID
and E.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and D.EFFDT = A.EFFDT)))Using distributive law A and (B or C) = (A and B) or (A and C) from right to left we can have:
select distinct A.DEPTID,A.POSITION_NBR,A.EMPLID,A.EMPL_RCD_NBR,A.EFFDT,B.NAME,A.EMPL_STATUS,
A.JOBCODE,A.ANNUAL_RT,A.STD_HOURS,A.PRIMARY_JOB,C.POSN_STATUS,
case when A.POSITION_NBR = ' ' then 0 else C.STD_HOURS end,
case when A.POSITION_NBR = ' ' then ' ' else C.DEPTID end
from PS_JOB A,PS_PERSONAL_DATA B,PS_POSITION_DATA C
where A.EMPLID = B.EMPLID
and (
A.POSITION_NBR = C.POSITION_NBR
and A.EFFSEQ = (select max(D.EFFSEQ)
from PS_JOB D
where D.EMPLID = A.EMPLID
and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and D.EFFDT = A.EFFDT
and C.EFFSEQ = (select max(F.EFFSEQ)
from PS_POSITION_DATA E
where E.POSITION_NBR = A.POSITION_NBR
and E.EFFDT = C.EFFDT
and C.POSN_STATUS != 'G'
and (
C.EFFDT = (select max(E.EFFDT)
from PS_POSITION_DATA E
where E.POSITION_NBR = A.POSITION_NBR
and E.EFFDT <= A.EFFDT
or
A.EFFDT = (select max(D.EFFDT)
from PS_JOB D
where D.EMPLID = A.EMPLID
and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and D.EFFDT <= C.EFFDT
or
A.POSITION_NBR = ' '
and A.EFFSEQ = (select max(E.EFFSEQ)
from PS_JOB D
where D.EMPLID = A.EMPLID
and E.EMPL_RCD_NBR = A.EMPL_RCD_NBR
and D.EFFDT = A.EFFDT
)may not help much as the optimizer might have guessed it already
Regards
Etbin -
CDHDR table query taking long time
Hi all,
Select query from CDHDR table is taking long time,in where condition i am giving OBJECTCLASS = 'MAT_FULL' udate = sy-datum and langu = 'EN'.
any suggestion to improve the performance.i want to select all the article which got changed on current date
regards
shibuThis will always be slow for large data volumes, since CDHDR is designed for quick access by object ID (in this case material number), not by date.
I'm afraid you would need to introduce a secondary index on OBJECTCLAS and UDATE, if that query is crucial enough to warrant the additional disk space and processing time taken by the new index.
Greetings
Thomas -
Sap bi--query taking long time to exexute
Hi
When i try run the bex query ,its taking long time,please suggest
Thanks
sreedharHi
When i try run the bex query ,its taking long time,please suggest
Thanks
sreedhar -
Hi
I have a query in which, its a 3 table join but takes a long time to execute. I had checked with plan table.. it shows one of the table is FULL ACCESS.
I have 2 clarifications.
1. Will the status checking as NULL - (it shouldn't use index)
2. Is the case statements are recommended for queries.
Query
Select .........
FROM CLIENT LEFT OUTER JOIN INTERNET_LOGIN ON INTERNET_LOGIN.NUM_CLIENT_ID=CLIENT.NUM_CLIENT_ID,
POLI_MOT.
WHERE
POLI_MOT.NUM_CLIENT_ID=CLIENT.NUM_CLIENT_ID
AND
(POLI_MOT.CHR_CANCEL_STATUS='N'
OR
POLI_MOT.CHR_CANCEL_STATUS IS NULL)
AND
CLIENT.NUM_CONTACT_TYPE_ID IN (1,3)
AND
(NVL(POLI_MOT.VCH_NEW_IC_NO,'A') =
CASE WHEN (NVL(null,NULL) IS NULL) THEN
NVL(POLI_MOT.VCH_NEW_IC_NO,'A')
ELSE
NVL(null,NULL)
END
OR
POLI_MOT.VCH_OLD_IC_NO =
CASE WHEN nvl(null,null) IS NULL THEN
POLI_MOT.VCH_OLD_IC_NO
ELSE
NVL(null,NULL)
END )
AND POLI_MOT.VCH_POLICY_NO =
CASE WHEN UPPER(nvl(NULL,null)) IS NULL THEN
POLI_MOT.VCH_POLICY_NO
ELSE
NVL(NULL,NULL)
END
AND POLI_MOT.VCH_VEHICLE_NO =
CASE WHEN UPPER(NVL('123',NULL)) IS NULL THEN
POLI_MOT.VCH_VEHICLE_NO
ELSE
NVL('123',NULL)
ENDHi,
There is nothing wrong in having a full table access. When you do the explain plan please check for which table costs you the maximun. try to work on that table.
To tune the performance of your query you can try either indexing or parallel access.
the syntax for parallel index is
/*+ PARALLEL("TBL_NM",100) */(any number)...
for index please use the index name of the table you want to index..
regards
Bharath -
the below query is taking very long time.
select /*+ PARALLEL(a,8) PARALLEL(b,8) */ a.personid,a.winning_id, b.questionid from
winning_id_cleanup a , rm_personquestion b
where a.personid = b.personid and (a.winning_id,b.questionid) not in
(select /*+ PARALLEL(c,8) */ c.personid,c.questionid from rm_personquestion c where c.personid=a.winning_id);
where the rm_personquestion table is having 45 million rows and winning_id_cleanup is having 1 million rows.
please tell me how to tune this query?Please post u'r query at PL/SQL
It's not for SQL and PL/SQL -
Query taking 6mins to execute wityh order by clause, 3secs without orderby
Dear All,
The below query is taking nearly 6minutes time to execute (as i have order by clause in the query)
/* Formatted on 2007/09/26 10:03 (Formatter Plus v4.8.0) */
SELECT (SELECT DISTINCT grndate
FROM fs_lg_grnhdr
WHERE grnid = pl.grnid AND custwhid = pl.custwhid)
grndate,
pl.grnid,
(SELECT DISTINCT vi.orderno
FROM fs_lg_vendorinvoicehdr vi, fs_lg_grndtl gd
WHERE gd.vendorinvoiceid = vi.vendorinvoiceid
AND gd.custwhid = vi.custwhid
AND gd.custwhid = pl.custwhid
AND gd.grnid = pl.grnid
AND gd.partid = pl.partid) orderno,
pl.expirydate, pl.batchno, pl.packuom,
NVL (pl.receiptqty, 0) receiptqty, pl.putawayid, pl.lineno,
(SELECT customscontrolno
FROM fs_lg_putawaydtl
WHERE custwhid = pl.custwhid
AND putawayid = pl.putawayid
AND partid = pl.partid
AND locationto = pl.locationid) cctrlno,
(SELECT customspermitno
FROM fs_lg_putawayhdr
WHERE custwhid = pl.custwhid
AND putawayid = pl.putawayid) cpermitno,
(SELECT SUM (pdtl.pickqty)
FROM fs_lg_pickticketdtl pdtl,
fs_lg_picktickethdr phdr
WHERE pdtl.custwhid = pl.custwhid
AND pdtl.putawayid = pl.putawayid
AND pdtl.putawaylineno = pl.lineno
AND phdr.custwhid = pdtl.custwhid
AND phdr.pickticketid = pdtl.pickticketid
AND phdr.pickdate < '01-SEP-2007'
AND pdtl.status = 'CM') previousoutqty,
(SELECT SUM (pdtl.pickqty)
FROM fs_lg_pickticketdtl pdtl,
fs_lg_picktickethdr phdr
WHERE pdtl.custwhid = pl.custwhid
AND pdtl.putawayid = pl.putawayid
AND pdtl.putawaylineno = pl.lineno
AND phdr.custwhid = pdtl.custwhid
AND phdr.pickticketid = pdtl.pickticketid
AND phdr.pickdate BETWEEN '01-SEP-2007'
AND '25-SEP-2007'
AND pdtl.status = 'CM') presentoutqty,
NVL ((SELECT SUM (qty)
FROM fs_lg_internaltransdtl
WHERE putawayid = pl.putawayid
AND fromputawaylineno = pl.lineno
AND custwhid = pl.custwhid),
0
) toistqty,
NVL ((SELECT SUM (qty)
FROM fs_lg_internaltransdtl
WHERE custwhid = pl.custwhid
AND putawayid = pl.putawayid
AND slno = pl.lineno),
0
) fromistqty
FROM fs_lg_partloads pl
WHERE pl.partid = '2ERCH-2022'
AND pl.custwhid = 'RNH-CSM'
AND inventoryflag IN ('AVAIL','')
AND pl.status = 'CM'
AND pl.grndate <= '25-SEP-2007'
ORDER BY grndate, pl.grnid, pl.putawayid, pl.lineno;
But when i don't use the order by clause it is executing within 3 seconds. But i need to get the output in the sorted order as shown in the order by clause.
Is there any way to avoid order by clause and to get the same output as with order by clasue, and i need to execute the query with less time.
Please help me in this.
Thanks in advance
MahiDear Alok Kumar,
When i execute sql>set autotrace traceonly statistics ;
I am getting the below errors...
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report
What could be the problem, how to resolve this to get the statistics?
But when i use sql>set autotrace traceonly explain; i got the below output for the above query..
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_GRNHDR'
2 1 INDEX (UNIQUE SCAN) OF 'SYS_C00293078' (UNIQUE)
3 0 SORT (UNIQUE)
4 3 NESTED LOOPS
5 4 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_GRNDTL'
6 5 INDEX (RANGE SCAN) OF 'SYS_C00293075' (UNIQUE)
7 4 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_VENDORINVOICEH
DR'
8 7 INDEX (UNIQUE SCAN) OF 'PK_VENDORINVOICE' (UNIQUE)
9 0 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PUTAWAYDTL'
10 9 INDEX (UNIQUE SCAN) OF 'SYS_C00293260' (UNIQUE)
11 0 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PUTAWAYHDR'
12 11 INDEX (UNIQUE SCAN) OF 'SYS_C00293263' (UNIQUE)
13 0 SORT (AGGREGATE)
14 13 NESTED LOOPS
15 14 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PICKTICKETDTL'
16 15 INDEX (RANGE SCAN) OF 'F_L_P_CWI_IND1' (NON-UNIQUE)
17 14 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PICKTICKETHDR'
18 17 INDEX (UNIQUE SCAN) OF 'SYS_C00293202' (UNIQUE)
19 0 SORT (AGGREGATE)
20 19 NESTED LOOPS
21 20 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PICKTICKETDTL'
22 21 INDEX (RANGE SCAN) OF 'F_L_P_CWI_IND1' (NON-UNIQUE)
23 20 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PICKTICKETHDR'
24 23 INDEX (UNIQUE SCAN) OF 'SYS_C00293202' (UNIQUE)
25 0 SORT (AGGREGATE)
26 25 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_INTERNALTRANSDTL
27 26 INDEX (RANGE SCAN) OF 'PK_INTERNALTRANSDTL' (UNIQUE)
28 0 SORT (AGGREGATE)
29 28 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_INTERNALTRANSDTL
30 29 INDEX (RANGE SCAN) OF 'PK_INTERNALTRANSDTL' (UNIQUE)
31 0 SORT (ORDER BY)
32 31 TABLE ACCESS (BY INDEX ROWID) OF 'FS_LG_PARTLOADS'
33 32 INDEX (RANGE SCAN) OF 'PK_PARTLOADS' (UNIQUE)
Please advice me regarding this...
Thanks in advance
Mahi -
QUERY taking longer time than usual
Hello Gurus,
The query below used to take 5-10 minutes depending on the resource availability, but this time it is taking 4-5 hrs to complete this transaction.
INSERT /*+ APPEND */ INTO TAG_STAGING
SELECT /*+ INDEX(A,ALL_tags_INDX1) */
DISTINCT TRIM (serial) serial_num,
TRIM (COMPANY_numBER) COMPANY_NUM,
TRIM (PERSON_id) PERSON_id
FROM ALL_tags@DWDB_link a
WHERE serviceS IN (SELECT /*+ INDEX(B,service_CODES_INDX2) */
services
FROM service_CODES b
WHERE srvc_cd = 'R')
AND (ORDERDATE_date BETWEEN TO_DATE ('01-JAN-2007','dd-mon-yyyy')
AND TO_DATE ('31-DEC-2007','dd-mon-yyyy'))
AND ( (TRIM (status_1) IS NULL)
OR (TRIM (status_1) = 'R')
AND (TRIM (status_2) = 'R' OR TRIM (status_2) IS NULL)
TAG_STAGING table is empty with primary key on the three given columns
ALL_tags@DWDB_link table has about 100M rows
Ideally the query should fetch about 4M rows.
Could any one please give me an idea as to how to proceed to quicken the process.
Thanks in advance
Thanks,
TTFirst I'd check the explain plan to make sure that it makes sense. Perhaps an index was dropped or perhaps the stats are wrong for some reason.
If the explain plan looks good then I'd trace it and see where the time is being spent. -
Hi All,
I am trying to run one SELECT statement which uses 6 tables. That query generally take 25-30 minutes to generate output.
Today it is running from more than 2 hours. I have checked there are no locks on those tables and no other process is using them.
What else I should check in order to figure out why my SELECT statement is taking time?
Any help will be much appreciated.
Thanks!Please let me know if you still want me to provide all the information mentioned in the link.Yes, please.
Before you can even start optimizing, it should be clear what parts of the query are running slow.
The links contains the steps to take regarding how to identify the things that make the query run slow.
Ideally you post a trace/tkprof report with wait events, it'll show on what time is being spent, give an execution plan and a database version all in once...
Today it is running from more than 2 hours. I have checked there are no locks on those tables and no other process is using them.Well, something must have changed.
And you must indentify what exactly has changed, but it's a broad range you have to check:
- it could be outdated table statistics
- it could be data growth or skewness that makes Optimizer choose a wrong plan all of a sudden
- it could be a table that got modified with some bad index
- it could be ...
So, by posting the information in the link, you'll leave less room for guesses from us, so you'll get an explanation that makes sense faster or, while investigating by following the steps in the link, you'll get the explanation yourself. -
Query taking long time To Fectch the Results
Hi!
when I run the query,it takes too long time for fetching the resultsets.
Please find the query below for the same.
SELECT
A.BUSINESS_UNIT,
A.JOURNAL_ID,
TO_CHAR(A.JOURNAL_DATE,'YYYY-MM-DD'),
A.UNPOST_SEQ,
A.FISCAL_YEAR,
A.ACCOUNTING_PERIOD,
A.JRNL_HDR_STATUS,
C.INVOICE,
C.ACCT_ENTRY_TYPE,
C.LINE_DST_SEQ_NUM,
C.TAX_AUTHORITY_CD,
C.ACCOUNT,
C.MONETARY_AMOUNT,
D.BILL_SOURCE_ID,
D.IDENTIFIER,
D.VAT_AMT_BSE,
D.VAT_TRANS_AMT_BSE,
D.VAT_TXN_TYPE_CD,
D.TAX_CD_VAT,
D.TAX_CD_VAT_PCT,
D.VAT_APPLICABILITY,
E.BILL_TO_CUST_ID,
E.BILL_STATUS,
E.BILL_CYCLE_ID,
TO_CHAR(E.INVOICE_DT,'YYYY-MM-DD'),
TO_CHAR(E.ACCOUNTING_DT,'YYYY-MM-DD'),
TO_CHAR(E.DT_INVOICED,'YYYY-MM-DD'),
E.ENTRY_TYPE,
E.ENTRY_REASON,
E.AR_LVL,
E.AR_DST_OPT,
E.AR_ENTRY_CREATED,
E.GEN_AR_ITEM_FLG,
E.GL_LVL, E.GL_ENTRY_CREATED,
(Case when c.account in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','90100000')
and D.TAX_CD_VAT_PCT <> 0 then 'Ej_Momskonto_med_moms'
When c.account not in ('30120000','30180050','30190000','30290000',
'30490000','30690000','30900040','30990000','35100000','35120000','35150000',
'35160000','39100050','90100000')
and D.TAX_CD_VAT_PCT <> 25 then 'Momskonto_utan_moms' end)
FROM
sysadm.PS_JRNL_HEADER A,
sysadm.PS_JRNL_LN B,
sysadm.PS_BI_ACCT_ENTRY C,
sysadm.PS_BI_LINE D,
sysadm.PS_BI_HDR E
WHERE A.BUSINESS_UNIT = '&BU'
AND A.JOURNAL_DATE BETWEEN TO_DATE('&From_date','YYYY-MM-DD')
AND TO_DATE('&To_date','YYYY-MM-DD')
AND A.SOURCE = 'BI'
AND A.BUSINESS_UNIT = B.BUSINESS_UNIT
AND A.JOURNAL_ID = B.JOURNAL_ID
AND A.JOURNAL_DATE = B.JOURNAL_DATE
AND A.UNPOST_SEQ = B.UNPOST_SEQ
AND B.BUSINESS_UNIT = C.BUSINESS_UNIT
AND B.JOURNAL_ID = C.JOURNAL_ID
AND B.JOURNAL_DATE = C.JOURNAL_DATE
AND B.JOURNAL_LINE = C.JOURNAL_LINE
AND C.ACCT_ENTRY_TYPE = 'RR'
AND C.BUSINESS_UNIT = '&BU'
AND C.BUSINESS_UNIT = D.BUSINESS_UNIT
AND C.INVOICE = D.INVOICE
AND C.LINE_SEQ_NUM = D.LINE_SEQ_NUM
AND D.BUSINESS_UNIT = '&BU'
AND D.BUSINESS_UNIT = E.BUSINESS_UNIT
AND D.INVOICE = E.INVOICE
AND E.BUSINESS_UNIT = '&BU'
AND
((c.account in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','90100000')
and D.TAX_CD_VAT_PCT <> 0)
OR
(c.account not in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','z')
and D.TAX_CD_VAT_PCT <> 25)
GROUP BY
A.BUSINESS_UNIT,
A.JOURNAL_ID,
TO_CHAR(A.JOURNAL_DATE,'YYYY-MM-DD'),
A.UNPOST_SEQ, A.FISCAL_YEAR,
A.ACCOUNTING_PERIOD,
A.JRNL_HDR_STATUS,
C.INVOICE,
C.ACCT_ENTRY_TYPE,
C.LINE_DST_SEQ_NUM,
C.TAX_AUTHORITY_CD,
C.ACCOUNT,
D.BILL_SOURCE_ID,
D.IDENTIFIER,
D.VAT_TXN_TYPE_CD,
D.TAX_CD_VAT,
D.TAX_CD_VAT_PCT,
D.VAT_APPLICABILITY,
E.BILL_TO_CUST_ID,
E.BILL_STATUS,
E.BILL_CYCLE_ID,
TO_CHAR(E.INVOICE_DT,'YYYY-MM-DD'),
TO_CHAR(E.ACCOUNTING_DT,'YYYY-MM-DD'),
TO_CHAR(E.DT_INVOICED,'YYYY-MM-DD'),
E.ENTRY_TYPE, E.ENTRY_REASON,
E.AR_LVL, E.AR_DST_OPT,
E.AR_ENTRY_CREATED,
E.GEN_AR_ITEM_FLG,
E.GL_LVL,
E.GL_ENTRY_CREATED,
C.MONETARY_AMOUNT,
D.VAT_AMT_BSE,
D.VAT_TRANS_AMT_BSE
having
(Case when c.account in ('30120000','30180050','30190000','30290000',
'30490000','30690000','30900040','30990000','35100000','35120000','35150000',
'35160000','39100050','90100000')
and D.TAX_CD_VAT_PCT <> 0 then 'Ej_Momskonto_med_moms'
When c.account not in ('30120000','30180050','30190000','30290000','30490000',
'30690000','30900040','30990000','35100000','35120000','35150000','35160000',
'39100050','90100000')
and D.TAX_CD_VAT_PCT <> 25 then 'Momskonto_utan_moms' end) is not null
So Could you provide the solution to fix this issue?
Thanks
senthil[url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]When your query takes too long ...
Regards,
Rob. -
Query taking long time in oracle 10g
I have a query which runs in 1 minute in oracle 8 but it takes 2 hours in oracle 10. The query has couple of sub queries to select the max effective date as wee as current effective sequence. I checked the parameters and their values are as follows. I want to know whether any values can be increased to make it run faster. Also I did not find the parameter unnestsubquery, I think it should be set to FALSE but did not find the value when I did select * from v$parameter. Is it set to false value by default or should i explicitly declare it. Thanks
Statistic Name Result
processes 200
sessions 225
timed_statistics TRUE
sga_target 335544320
control_files /ora1db13/oradata/KVSU2P13/control01.ctl, /ora2db13/o
db_block_size 8192
compatible 10.2.0.1.0
db_file_multiblock_read_count 4
undo_management AUTO
undo_tablespace ADP_UNDO
db_domain
service_names KVSU2P13, KVSU2P13_VSUP
dispatchers (PROTOCOL=tcp)(DISPATCHERS=4)(CONNECTIONS=50)
shared_servers 10
max_shared_servers 20
shared_server_sessions 150
job_queue_processes 10
background_dump_dest /udb01/app/oracle/admin/KVSU2P13/bdump
user_dump_dest /udb01/app/oracle/admin/KVSU2P13/udump
core_dump_dest /udb01/app/oracle/admin/KVSU2P13/cdump
db_name KVSU2P13
open_cursors 300
optimizercost_based_transformation off
alwayssemi_join off
optimizer_index_cost_adj 10
optimizer_index_caching 50
pga_aggregate_target 25165824
workarea_size_policy autoPlease read these standard threads:
How to post a tuning request:
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long:
When your query takes too long ...
Maybe you are looking for
-
Can't connect macbook pro to samsung ue46d8005?
Hi, I just received my new Macbook Pro 13" since my old MBP from 2010 was stolen. I'm trying to connect it with my new led-tv Samsung ue46d8005. I have a mini-display to hdmi adapter and from there a hdmi cable hooked up to the tv. But no matter how
-
Why does my custom HTML newsletters absolute image urls get changed into imap: urls
I made a custom newsletter email in which all my images are absolute URLS. I use Thunderbird to send it out through my imapped google email account. Once I send it the URLs get changed and for some reason brings my tracking URL into the image URL as
-
External USB Connected Samsung DVD: Beeping/flashing of OS/applications
I connected this drive (which is an internal model mounted in a NextStar USB 2 enclosure) to the USB port directly on the back of the mini (I have a Belkin powered USB base, and I'm thinking maybe I should try it in that). In any case, a blank DVD wa
-
I want to know what InputField is selected in the table
Hi Experts Please help me I have table with 4 columns (each column have TableCellEditor of type InputField) I need to know what InputField is selected in the table(or in wich column)
-
How do I enable 'Rapport' in Firefox 15.0.1 for Mac?
Have used the security add on 'Rapport' for over a year with Firefox but since upgrading to 15.0.1, its disappeared and I cannot find a means of restoring it. What's the solution?