Select query taking more time..
Hi friends..
The below inner join statement is taking more time , can any body sugget me to improve the performance . I tried FOR ALL ENTRIES also but that also taking more time than inner join statement .
SELECT a~vbeln from vbap as a inner join vakpa as b
on avbeln = bvbeln
into corresponding fields of table IT_VAKPA
where a~WERKS IN S_IWERKS
and a~pstyv NE 'ZRS'
and b~vkorg = IVKORG
and b~audat IN IAUDAT
and b~vtweg IN IVTWEG.
Regards
Chetan
Hi Chetan ,
VAKPA is an index table. From the select query , it has been observed that you are not fetching any data from VAKPA. Only you have added some selection paramenters in where clause of select query.
My suggestion will be instead of using VAKPA in inner join you use VBAK along with VBAP. All the fields that you are using as selection condition from VAKPA are there in VBAK.
I am sure performance of query will be improved.
If still duo to business logic you need to use VAKPA, try to create secondary non unique index on fields VKORD,AUDATand VTWEG on table VAKPA.
However I will recommend you to go for first option only. If this does not work then go for second option.
Hopfully this will help you.
Regards,
Nikhil
Similar Messages
-
Dear Gurus/Masters/All,
I request your valuble assistance in tuning one of my SQL.
We are using oracle 10.2.04 version and OS is HP-UX 11.23(ia64) version
In my production environment one SQL is taking more time to complete the task. According to EXPLAIN PLAN, i observed that one of it's WHERE condition execution is causing the issue.
I took the explain plan of the WHERE condition which is causing the issue. It is going for full table scan to satisfy the criteria. But a normal index exists on this column.
Main Query WHERE condition and Explain Plan.
SELECT column list ....
FROM
SIEBEL.S_ADDR_PER T1,
SIEBEL.S_PTY_PAY_PRFL T2,
SIEBEL.S_INVLOC T3,
SIEBEL.S_ORDER T4,
SIEBEL.S_ORG_EXT T5,
SIEBEL.S_POSTN T6,
SIEBEL.S_PARTY T7,
SIEBEL.S_PROJ T8,
SIEBEL.S_CON_ADDR T9,
SIEBEL.S_ORG_EXT T10,
SIEBEL.S_USER T11,
SIEBEL.S_DOC_QUOTE T12,
SIEBEL.S_ACCNT_POSTN T13,
SIEBEL.S_INS_CLAIM T14,
SIEBEL.S_USER T15,
SIEBEL.S_ORG_EXT T16,
SIEBEL.S_ASSET T17,
SIEBEL.S_ORDER_TNTX T18,
SIEBEL.S_ORG_EXT_TNTX T19,
SIEBEL.S_PERIOD T20,
SIEBEL.S_DEPOSIT_TNT T21,
SIEBEL.S_ADDR_PER T22,
SIEBEL.S_PAYMENT_TERM T23,
SIEBEL.S_ORG_EXT_X T24,
SIEBEL.S_ORG_EXT T25,
SIEBEL.S_INSCLM_ELMNT T26,
SIEBEL.S_INVOICE T27
WHERE
T25.BU_ID = T10.PAR_ROW_ID (+) AND
T26.INSCLM_ID = T14.ROW_ID (+) AND
T27.ELEMENT_ID = T26.ROW_ID (+) AND
T27.LAST_UPD_BY = T15.PAR_ROW_ID (+) AND
T4.QUOTE_ID = T12.ROW_ID (+) AND
T3.CG_ASSSET_ID = T17.ROW_ID (+) AND
T27.BL_ADDR_ID = T22.ROW_ID (+) AND
T8.BU_ID = T5.PAR_ROW_ID (+) AND
T27.PER_PAY_PRFL_ID = T2.ROW_ID (+) AND
T27.REMIT_ORG_EXT_ID = T16.PAR_ROW_ID (+) AND
T27.PROJ_ID = T8.ROW_ID (+) AND
T27.BL_PERIOD_ID = T20.ROW_ID (+) AND
T27.PAYMENT_TERM_ID = T23.ROW_ID (+) AND
T12.BU_ID = T19.PAR_ROW_ID (+) AND
T27.ACCNT_ID = T25.PAR_ROW_ID (+) AND
T27.ORDER_ID = T18.ROW_ID (+) AND
T4.SRC_INVLOC_ID = T3.ROW_ID (+) AND
T27.ORDER_ID = T4.ROW_ID (+) AND
T27.ACCNT_ID = T24.PAR_ROW_ID (+) AND
T18.PR_DEPOSIT_ID = T21.ROW_ID (+) AND
T27.BL_ADDR_ID = T9.ADDR_PER_ID (+) AND T27.ACCNT_ID = T9.ACCNT_ID (+) AND
T27.BL_ADDR_ID = T1.ROW_ID (+) AND
T25.PR_POSTN_ID = T13.POSITION_ID (+) AND T25.ROW_ID = T13.OU_EXT_ID (+) AND
T13.POSITION_ID = T7.ROW_ID (+) AND
T13.POSITION_ID = T6.PAR_ROW_ID (+) AND
T6.PR_EMP_ID = T11.PAR_ROW_ID (+) AND
(T27.INVC_TYPE_CD = :1)
ORDER BY
T27.INVC_DT;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 2576210427
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 39M| 71G| | 624M (1)|278:42:59 |
| 1 | SORT ORDER BY | | 39M| 71G| 150G| 624M (1)|278:42:59 |
| 2 | NESTED LOOPS OUTER | | 39M| 71G| | 610M (1)|272:11:24 |
| 3 | NESTED LOOPS OUTER | | 39M| 70G| | 515M (1)|229:48:41 |
| 4 | NESTED LOOPS OUTER | | 39M| 69G| | 483M (1)|215:41:04 |
| 5 | NESTED LOOPS OUTER | | 39M| 68G| | 483M (1)|215:41:04 |
| 6 | NESTED LOOPS OUTER | | 39M| 67G| | 483M (1)|215:41:04 |
| 7 | NESTED LOOPS OUTER | | 39M| 66G| | 406M (1)|181:17:50 |
| 8 | NESTED LOOPS OUTER | | 39M| 65G| | 343M (1)|153:12:57 |
| 9 | NESTED LOOPS OUTER | | 39M| 64G| | 311M (1)|139:04:56 |
| 10 | NESTED LOOPS OUTER | | 39M| 63G| | 185M (1)| 82:37:56 |
| 11 | NESTED LOOPS OUTER | | 39M| 54G| | 108M (1)| 48:11:29 |
| 12 | NESTED LOOPS OUTER | | 39M| 53G| | 108M (1)| 48:11:29 |
| 13 | NESTED LOOPS OUTER | | 39M| 51G| | 76M (1)| 34:03:51 |
| 14 | NESTED LOOPS OUTER | | 39M| 49G| | 76M (1)| 34:03:51 |
| 15 | NESTED LOOPS OUTER | | 39M| 46G| | 76M (1)| 34:03:51 |
| 16 | NESTED LOOPS OUTER | | 39M| 44G| | 76M (1)| 34:03:51 |
| 17 | NESTED LOOPS OUTER | | 39M| 40G| | 65M (1)| 29:25:49 |
| 18 | NESTED LOOPS OUTER | | 39M| 39G| | 65M (1)| 29:25:49 |
| 19 | NESTED LOOPS OUTER | | 39M| 38G| | 65M (1)| 29:25:49 |
| 20 | NESTED LOOPS OUTER | | 39M| 34G| | 65M (1)| 29:17:44 |
| 21 | NESTED LOOPS OUTER | | 39M| 32G| | 65M (1)| 29:17:08 |
| 22 | NESTED LOOPS OUTER | | 39M| 31G| | 65M (1)| 29:09:04 |
| 23 | NESTED LOOPS OUTER | | 39M| 30G| | 2043K (9)| 00:54:42 |
| 24 | NESTED LOOPS OUTER | | 39M| 30G| | 2043K (9)| 00:54:42 |
| 25 | NESTED LOOPS OUTER | | 39M| 25G| | 2015K (7)| 00:53:57 |
| 26 | NESTED LOOPS OUTER | | 39M| 22G| | 2015K (7)| 00:53:57 |
| 27 | NESTED LOOPS OUTER | | 39M| 16G| | 2015K (7)| 00:53:57 |
|* 28 | TABLE ACCESS FULL | S_INVOICE | 39M| 9G| | 2015K (7)| 00:53:57 |
| 29 | TABLE ACCESS BY INDEX ROWID| S_PROJ | 1 | 188 | | 1 (0)| 00:00:01 |
|* 30 | INDEX UNIQUE SCAN | S_PROJ_P1 | 1 | | | 1 (0)| 00:00:01 |
| 31 | TABLE ACCESS BY INDEX ROWID | S_PAYMENT_TERM | 1 | 156 | | 1 (0)| 00:00:01 |
|* 32 | INDEX UNIQUE SCAN | S_PAYMENT_TERM_P1 | 1 | | | 1 (0)| 00:00:01 |
| 33 | TABLE ACCESS BY INDEX ROWID | S_INSCLM_ELMNT | 1 | 77 | | 1 (0)| 00:00:01 |
|* 34 | INDEX UNIQUE SCAN | S_INSCLM_ELMNT_P1 | 1 | | | 1 (0)| 00:00:01 |
| 35 | TABLE ACCESS BY INDEX ROWID | S_INS_CLAIM | 1 | 134 | | 1 (0)| 00:00:01 |
|* 36 | INDEX UNIQUE SCAN | S_INS_CLAIM_P1 | 1 | | | 1 (0)| 00:00:01 |
| 37 | TABLE ACCESS BY INDEX ROWID | S_PERIOD | 1 | 19 | | 1 (0)| 00:00:01 |
|* 38 | INDEX UNIQUE SCAN | S_PERIOD_P1 | 1 | | | 1 (0)| 00:00:01 |
| 39 | TABLE ACCESS BY INDEX ROWID | S_USER | 1 | 25 | | 2 (0)| 00:00:01 |
|* 40 | INDEX UNIQUE SCAN | S_USER_U2 | 1 | | | 1 (0)| 00:00:01 |
| 41 | TABLE ACCESS BY INDEX ROWID | S_ORDER_TNTX | 1 | 26 | | 2 (0)| 00:00:01 |
|* 42 | INDEX UNIQUE SCAN | S_ORDER_TNTX_P1 | 1 | | | 1 (0)| 00:00:01 |
| 43 | TABLE ACCESS BY INDEX ROWID | S_DEPOSIT_TNT | 1 | 45 | | 1 (0)| 00:00:01 |
|* 44 | INDEX UNIQUE SCAN | S_DEPOSIT_TNT_P1 | 1 | | | 1 (0)| 00:00:01 |
| 45 | TABLE ACCESS BY INDEX ROWID | S_ORDER | 1 | 101 | | 2 (0)| 00:00:01 |
|* 46 | INDEX UNIQUE SCAN | S_ORDER_P1 | 1 | | | 1 (0)| 00:00:01 |
| 47 | TABLE ACCESS BY INDEX ROWID | S_INVLOC | 1 | 47 | | 1 (0)| 00:00:01 |
|* 48 | INDEX UNIQUE SCAN | S_INVLOC_P1 | 1 | | | 1 (0)| 00:00:01 |
| 49 | TABLE ACCESS BY INDEX ROWID | S_DOC_QUOTE | 1 | 21 | | 1 (0)| 00:00:01 |
|* 50 | INDEX UNIQUE SCAN | S_DOC_QUOTE_P1 | 1 | | | 1 (0)| 00:00:01 |
|* 51 | TABLE ACCESS FULL | S_ORG_EXT_TNTX | 1 | 94 | | 0 (0)| 00:00:01 |
| 52 | TABLE ACCESS BY INDEX ROWID | S_PTY_PAY_PRFL | 1 | 74 | | 1 (0)| 00:00:01 |
|* 53 | INDEX UNIQUE SCAN | S_PTY_PAY_PRFL_P1 | 1 | | | 1 (0)| 00:00:01 |
| 54 | TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1 | 84 | | 2 (0)| 00:00:01 |
|* 55 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | | 1 (0)| 00:00:01 |
| 56 | TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1 | 57 | | 1 (0)| 00:00:01 |
|* 57 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | | 1 (0)| 00:00:01 |
| 58 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 32 | | 1 (0)| 00:00:01 |
|* 59 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | | 1 (0)| 00:00:01 |
| 60 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 32 | | 1 (0)| 00:00:01 |
|* 61 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | | 1 (0)| 00:00:01 |
| 62 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 256 | | 2 (0)| 00:00:01 |
|* 63 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | | 1 (0)| 00:00:01 |
| 64 | TABLE ACCESS BY INDEX ROWID | S_ACCNT_POSTN | 1 | 32 | | 3 (0)| 00:00:01 |
|* 65 | INDEX RANGE SCAN | S_ACCNT_POSTN_U1 | 1 | | | 2 (0)| 00:00:01 |
| 66 | TABLE ACCESS BY INDEX ROWID | S_POSTN | 1 | 21 | | 1 (0)| 00:00:01 |
|* 67 | INDEX UNIQUE SCAN | S_POSTN_U2 | 1 | | | 1 (0)| 00:00:01 |
| 68 | TABLE ACCESS BY INDEX ROWID | S_USER | 1 | 25 | | 2 (0)| 00:00:01 |
|* 69 | INDEX UNIQUE SCAN | S_USER_U2 | 1 | | | 1 (0)| 00:00:01 |
| 70 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 32 | | 2 (0)| 00:00:01 |
|* 71 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | | 1 (0)| 00:00:01 |
| 72 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 1 | 24 | | 2 (0)| 00:00:01 |
|* 73 | INDEX UNIQUE SCAN | S_ASSET_P1 | 1 | | | 2 (0)| 00:00:01 |
| 74 | TABLE ACCESS BY INDEX ROWID | S_CON_ADDR | 1 | 36 | | 3 (0)| 00:00:01 |
|* 75 | INDEX RANGE SCAN | S_CON_ADDR_U1 | 1 | | | 2 (0)| 00:00:01 |
|* 76 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1 | 12 | | 1 (0)| 00:00:01 |
| 77 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_X | 1 | 37 | | 2 (0)| 00:00:01 |
|* 78 | INDEX RANGE SCAN | S_ORG_EXT_X_U1 | 1 | | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
28 - filter("T27"."INVC_TYPE_CD"=:1)
30 - access("T27"."PROJ_ID"="T8"."ROW_ID"(+))
32 - access("T27"."PAYMENT_TERM_ID"="T23"."ROW_ID"(+))
34 - access("T27"."ELEMENT_ID"="T26"."ROW_ID"(+))
36 - access("T26"."INSCLM_ID"="T14"."ROW_ID"(+))
38 - access("T27"."BL_PERIOD_ID"="T20"."ROW_ID"(+))
40 - access("T27"."LAST_UPD_BY"="T15"."PAR_ROW_ID"(+))
42 - access("T27"."ORDER_ID"="T18"."ROW_ID"(+))
44 - access("T18"."PR_DEPOSIT_ID"="T21"."ROW_ID"(+))
46 - access("T27"."ORDER_ID"="T4"."ROW_ID"(+))
48 - access("T4"."SRC_INVLOC_ID"="T3"."ROW_ID"(+))
50 - access("T4"."QUOTE_ID"="T12"."ROW_ID"(+))
51 - filter("T12"."BU_ID"="T19"."PAR_ROW_ID"(+))
53 - access("T27"."PER_PAY_PRFL_ID"="T2"."ROW_ID"(+))
55 - access("T27"."BL_ADDR_ID"="T1"."ROW_ID"(+))
57 - access("T27"."BL_ADDR_ID"="T22"."ROW_ID"(+))
59 - access("T8"."BU_ID"="T5"."PAR_ROW_ID"(+))
61 - access("T27"."REMIT_ORG_EXT_ID"="T16"."PAR_ROW_ID"(+))
63 - access("T27"."ACCNT_ID"="T25"."PAR_ROW_ID"(+))
65 - access("T25"."ROW_ID"="T13"."OU_EXT_ID"(+) AND "T25"."PR_POSTN_ID"="T13"."POSITION_ID"(+))
67 - access("T13"."POSITION_ID"="T6"."PAR_ROW_ID"(+))
69 - access("T6"."PR_EMP_ID"="T11"."PAR_ROW_ID"(+))
71 - access("T25"."BU_ID"="T10"."PAR_ROW_ID"(+))
73 - access("T3"."CG_ASSSET_ID"="T17"."ROW_ID"(+))
75 - access("T27"."BL_ADDR_ID"="T9"."ADDR_PER_ID"(+) AND "T27"."ACCNT_ID"="T9"."ACCNT_ID"(+))
filter("T27"."ACCNT_ID"="T9"."ACCNT_ID"(+))
76 - access("T13"."POSITION_ID"="T7"."ROW_ID"(+))
78 - access("T27"."ACCNT_ID"="T24"."PAR_ROW_ID"(+))
117 rows selected.SQL> EXPLAIN PLAN FOR
2 SELECT * FROM SIEBEL.S_INVOICE T27 WHERE T27.INVC_TYPE_CD=:1;
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 1810797629
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 39M| 9G| 2016K (8)| 00:53:59 |
|* 1 | TABLE ACCESS FULL| S_INVOICE | 39M| 9G| 2016K (8)| 00:53:59 |
Predicate Information (identified by operation id):
1 - filter("T27"."INVC_TYPE_CD"=:1)
13 rows selected.Edited by: KODS on Feb 13, 2013 1:08 PMDear Ivan,
Please find the details below.
select * from dba_indexes where index_name = 'S_INVOICE_U1';
OWNER INDEX_NAME INDEX_TYPE TABLE_OWNER TABLE_NAME TABLE_TYPE UNIQUENESS COMPRESSION PREFIX_LENGTH TABLESPACE_NAME INI_TRANS MAX_TRANS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE PCT_THRESHOLD INCLUDE_COLUMN FREELISTS FREELIST_GROUPS PCT_FREE LOGGING BLEVEL LEAF_BLOCKS DISTINCT_KEYS AVG_LEAF_BLOCKS_PER_KEY AVG_DATA_BLOCKS_PER_KEY CLUSTERING_FACTOR STATUS NUM_ROWS SAMPLE_SIZE LAST_ANALYZED DEGREE INSTANCES PARTITIONED TEMPORARY GENERATED SECONDARY BUFFER_POOL USER_STATS DURATION PCT_DIRECT_ACCESS ITYP_OWNER ITYP_NAME PARAMETERS GLOBAL_STATS DOMIDX_STATUS DOMIDX_OPSTATUS FUNCIDX_STATUS JOIN_INDEX IOT_REDUNDANT_PKEY_ELIM DROPPED
SIEBEL S_INVOICE_U1 NORMAL SIEBEL S_INVOICE TABLE UNIQUE DISABLED CRMSBL_AEM_INDEX 2 255 65536 1 2147483645 10 NO 3 902796 196739390 1 1 125598294 VALID 196739390 196739390 10-02-13 1 1 NO N N N DEFAULT NO YES NO NO NO
select * from dba_ind_columns where index_name = 'S_INVOICE_U1' order by column_position;
INDEX_OWNER INDEX_NAME TABLE_OWNER TABLE_NAME COLUMN_NAME COLUMN_POSITION COLUMN_LENGTH CHAR_LENGTH DESCEND
SIEBEL S_INVOICE_U1 SIEBEL S_INVOICE INVC_NUM 1 200 50 ASC
SIEBEL S_INVOICE_U1 SIEBEL S_INVOICE INVC_TYPE_CD 2 120 30 ASC
SIEBEL S_INVOICE_U1 SIEBEL S_INVOICE CONFLICT_ID 3 60 15 ASC -
Iam having nearly 2 crores records at present in my table..
I want to get the avg of price from my table..
i put the query like
select avg(sum(price)) from table group by product_id
The query taking more than 5 mins to execute...
is that any other way i can simplify my query?Warren:
Your first query gives:
SQL> SELECT AVG(SUM(price)) sum_price
2 FROM t;
SELECT AVG(SUM(price)) sum_price
ERROR at line 1:
ORA-00978: nested group function without GROUP BYand your second gives:
SQL> SELECT product_id, AVG(SUM(price))
2 FROM t
3 GROUP BY product_id;
SELECT product_id, AVG(SUM(price))
ERROR at line 1:
ORA-00937: not a single-group group functionSymon:
What exactly are you ttrying to accomplish. Your query as posted will calculate the average of the sums of the prices for all product_id values. That is, it is equivalent to:
SELECT AVG(sum_price)
FROM (SELECT SUM(price) sum_price
FROM t
GROUP BY product_id)So given:
SQL> SELECT * FROM t;
PRODUCT_ID PRICE
PROD1 5
PROD1 7
PROD1 10
PROD2 3
PROD2 4
PROD2 5The sum of the prices per product_id is:
SQL> SELECT SUM(price) sum_price
2 FROM t
3 GROUP BY product_id;
SUM_PRICE
22
12 and the average of that is (22 + 12) / 2 = 17. Is that what you are looking for? If so, then the equivalent query I posted above is at least clearer, but may not be any faster. If this is not what you are looking for, then some sample data and expected results may help. Although, it appears that you need to full scan the table in either case, so that may be as good as it gets.
John -
Hi All,
I have cloned KSB1 tcode to custom one as required by business.
Below query takes more time than excepted.
Here V_DB_TABLE = COVP.
Values in Where clause are as follows
OBNJR in ( KSBB010000001224 BT KSBB012157221571)
GJAHR in blank
VERSN in '000'
WRTTP in '04' and '11'
all others are blank
VT_VAR_COND = ( CPUDT BETWEEN '20091201' and '20091208' )
SELECT (VT_FIELDS) INTO CORRESPONDING FIELDS OF GS_COVP_EXT
FROM (V_DB_TABLE)
WHERE LEDNR = '00'
AND OBJNR IN LR_OBJNR
AND GJAHR IN GR_GJAHR
AND VERSN IN GR_VERSN
AND WRTTP IN GR_WRTTP
AND KSTAR IN LR_KSTAR
AND PERIO IN GR_PERIO
AND BUDAT IN GR_BUDAT
AND PAROB IN GR_PAROB
AND (VT_VAR_COND).
Checked in table for this condition it has only 92 entries.
But when i execute program takes long time as 3 Hrs.
Could any one help me on this>1.Dont use SELECT/ENDSELECT instead use INTO TABLE addition .
> 2.Avoid using corresponding addition.create a type and reference it.
> If the select is going for dump beacause of storage limitations ,then use Cursors.
you got three large NOs .... all three recommendations are wrong!
The SE16 test is going in the right direction ... but what was filled. Nobody knows!!!!
Select options:
Did you ever try to trace the SE16? The generic statement has for every field an in-condition!
Without the information what was actually filled, nobody can say something there
are at least 2**n combinations possible!
Use ST05 for SE16 and check actual statement plus explain! -
Select query taking long time (more then 6 min)
Dear experts,
DATA:IT_CHEQ2 TYPE TABLE OF TY_BSAS,
WA_CHEQ2 LIKE LINE OF IT_CHEQ2.
DATA : IT_CHEQ3 TYPE STANDARD TABLE OF TY_BSAS WITH HEADER LINE.
TYPES:BEGIN OF TY_BSAS,
BUKRS TYPE BSAS-BUKRS,
HKONT TYPE BSAS-HKONT,
AUGDT TYPE BSAS-AUGDT,
AUGBL TYPE BSAK-AUGBL,
ZUONR TYPE BSAK-ZUONR,
GJAHR TYPE BSAK-GJAHR,
BELNR TYPE BSAK-BELNR,
BUZEI TYPE BSAK-BUZEI,
BUDAT TYPE BSAK-BUDAT,
XBLNR TYPE BSAK-XBLNR,
BLART TYPE BSAK-BLART,
SHKZG TYPE BSAK-SHKZG,
DMBTR TYPE BSAK-DMBTR,
WMWST TYPE BSAK-WMWST,
AUGGJ TYPE BSAK-AUGGJ, " CLEARING FYSICAL YEAR
OT_TAX TYPE BSAK-DMBTR,
TDS TYPE BSAK-DMBTR,
VAT TYPE BSAK-DMBTR, "Vat amount
WCT TYPE BSAK-DMBTR,
ADV TYPE BSAK-DMBTR, "Advance
CHAMT TYPE BSAK-DMBTR,
CHNO TYPE PAYR-CHECT,
CHDATE TYPE PAYR-ZALDT,
DBIT_NOTE TYPE BSAK-DMBTR,
PAY_ADJ TYPE BSAK-DMBTR,
PEND_SES TYPE BSAK-DMBTR, "PENDING SES
CR_PARTY(50) TYPE C,
END OF TY_BSAS.
SELECT BUKRS HKONT AUGDT AUGBL ZUONR GJAHR BELNR BUZEI BUDAT XBLNR BLART SHKZG
DMBTR WMWST
FROM BSAS INTO " APPENDING
CORRESPONDING FIELDS OF TABLE IT_CHEQ3
FOR ALL ENTRIES IN IT_CHEQ2
WHERE AUGBL = IT_CHEQ2-AUGBL and
BUKRS = IT_CHEQ2-BUKRS AND
* AUGBL = IT_CHEQ2-AUGBL
GJAHR = IT_CHEQ2-GJAHR
AND XBLNR = IT_CHEQ2-XBLNR.
line company code hkont augdt augbl zuonr gjahr belnr buzei budat
1 1018 0012100030 20110831 2100009710 20110831 2011 2100009710 005 20110831
xblnr blart shkzg
RA03 KZ H 37067.00 0.00 2011 0.00 0.00
2 1018 0012100030 20110831 2100009710 20110831 2011 2100009710 006 20110831
RA03 KZ H 393850.00 0.00 2011 0.00 0.00
3 1018 0012100030 20110831 2100009710 20110831 2011 2100009710 004 20110831 RA03 KZ S 723589.13 0.00 2011 0.00 0.00
4 1018 0012100030 20110831 2100009710 20110823 2011 3900001250 001 20110823 RA03 RS H 712921.13 0.00 2011 0.00 0.00
5 1018 0023200000 20110831 2100009710 20110831 2011 2100009710 008 20110831 RA03 KZ H 21788.00 0.00 2011 0.00 0.00
6 1018 0023200000 20110831 2100009710 20110831 2011 2100009710 007 20110831 RA03 KZ H 1162821.00 0.00 2011 0.00 0.00
if i put same entry in se11 for bsas it takes 7 second
and in query takes more then 6 min ,kindly tell why
help me gurus
regards
victorTested point 2.
There is no difference.
REPORT Z_YZ_SELECT_ORDER.
types: begin of t_orderadm,
description type CRMT_PROCESS_DESCRIPTION,
created_at type COMT_CREATED_AT_USR,
LOGICAL_SYSTEM type CRMT_LOGSYS,
TEMPLATE_TYPE type CRMT_TEMPLATE_TYPE_DB,
VERIFY_DATE type CRMT_VERIFY_DATE,
GUID type CRMT_OBJECT_GUID,
end of t_orderadm.
types: begin of t_orderadm_1,
GUID type CRMT_OBJECT_GUID,
description type CRMT_PROCESS_DESCRIPTION,
LOGICAL_SYSTEM type CRMT_LOGSYS,
TEMPLATE_TYPE type CRMT_TEMPLATE_TYPE_DB,
created_at type COMT_CREATED_AT_USR,
VERIFY_DATE type CRMT_VERIFY_DATE,
end of t_orderadm_1.
data: lt_orders type table of t_orderadm,
lt_orders_1 type table of t_orderadm_1.
select description created_at logical_system template_type verify_date guid
into table lt_orders
from crmd_orderadm_h.
select guid description logical_system template_type created_at verify_date
into table lt_orders_1
from crmd_orderadm_h.
write 'done'.
First select - mixed order of fields. Response time: 82.155 microseconds for 39380 records selected.
Second select - fields in the order of the table. Response time: 81.061 microseconds for the same 39380 records selected.
Then I changed the order of SELECT statements. I have put first the select with ordered fields, and second - select with mixed order of fields. The runtimes were the following:
Ordered fields - 82.649 microseconds
Mixed order of fields - 80.270 microseconds.
So I'm going to change the Wiki page in order to avoid in future advices that make no sense. -
Stopping a Query taking more time to execute in runtime in Oracle Forms.
Hi,
In the present application one of the oracle form screen is taking long time to execute a query, user wanted an option to stop the query in between and browse the result (whatever has been fetched before stopping the query).
We have tried three approach.
1. set max fetch record in form and block level.
2. set max fetch time in form and block level.
in above two method does not provide the appropiate solution for us.
3. the third approach we applied is setting the interaction mode to "NON BLOCKING" at the form level.
It seems to be worked, while the query took long time to execute, oracle app server prompts an message to press Esc to cancel the query and it a displaying the results fetched upto that point.
But the drawback is one pressing esc, its killing the session itself. which is causing the entire application to collapse.
Please suggest if there is any alternative approach for this or how to overcome this perticular scenario.
This kind of facility is alreday present in TOAD and PL/SQL developer where we can stop an executing query and browse the results fetched upto that point, is the similar facility is avialable in oracle forms ,please suggest.
Thanks and Regards,
Suraj
Edited by: user10673131 on Jun 25, 2009 4:55 AMHello Friend,
You query will definitely take more time or even fail in PROD,becuase the way it is written. Here are my few observations, may be it can help :-
1. XLA_AR_INV_AEL_SL_V XLA_AEL_SL_V : Never use a view inside such a long query , becuase View is just a window to the records.
and when used to join other table records, then all those tables which are used to create a view also becomes part of joining conition.
First of all please check if you really need this view. I guess you are using to check if the records have been created as Journal entries or not ?
Please check the possbility of finding it through other AR tables.
2. Remove _ALL tables instead use the corresponding org specific views (if you are in 11i ) or the sysnonymns ( in R12 )
For example : For ra_cust_trx_types_all use ra_cust_trx_types.
This will ensure that the query will execute only for those ORG_IDs which are assigned to that responsibility.
3. Check with the DBA whether the GATHER SCHEMA STATS have been run atleast for ONT and RA tables.
You can also check the same using
SELECT LAST_ANALYZED FROM ALL_TABLES WHERE TABLE_NAME = 'ra_customer_trx_all'.
If the tables are not analyzed , the CBO will not be able to tune your query.
4. Try to remove the DISTINCT keyword. This is the MAJOR reason for this problem.
5. If its a report , try to separate the logic in separate queries ( using a procedure ) and then populate the whole data in custom table, and use this custom table for generating the
report.
Thanks,
Neeraj Shrivastava
[email protected]
Edited by: user9352949 on Oct 1, 2010 8:02 PM
Edited by: user9352949 on Oct 1, 2010 8:03 PM -
Dear all ,
I am fetching data from pool table a006. The select query is mentioned below.
select * from a005 into table i_a005 for all wntries in it_table
where kappl = 'V'
and kschl IN s_kschl
and vkorg in s_vkorg
and vtweg in s_vtgew
and matnr in s_matnr
and knumh = it_table-knumh .
here every fields are primary key fields except one field knumh which is comparing with table it_table. Because of these field this query is taking too much time as KNUMH is not primary key. And a005 is pool table . So , i cant create index for same. If there is alternate solutions , than please let me know..
Thank You ,
And in technical setting of table ITS Metioned as Fully buffered and size category is 0 .. But data are around 9000000. Is it issue or What ? Can somebody tell some genual reason ? Or improvement in my select query.........
Edited by: TVC6784 on Jun 30, 2011 3:31 PMTVC6784 wrote:
Hi Yuri ,
>
> Thanks for your reply....I will check as per your comment...
> bUT if i remove field KNUMH From selection condition and also for all entries in it_itab , than data fetch very fast As KNUMH is not primary key..
> . the example is below
>
> select * from a005 into table i_a005
> where kappl = 'V'
> and kschl IN s_kschl
> and vkorg in s_vkorg
> and vtweg in s_vtgew
> and matnr in s_matnr.
>
> Can you comment anything about it ?
>
> And can you please say how can i check its size as you mention that is 2-3 Mb More ?
>
> Edited by: TVC6784 on Jun 30, 2011 7:37 PM
I cannot see the trace and other information about the table so I cannot judge why the select w/o KNUMH is faster.
Basically, if the table is buffered and it's contents is in the SAP application server memory, the access should be really fast. Does not really matter if it is with KNUMH or without.
I would really like to see at least ST05 trace of your report that is doing this select. This would clarify many things.
You can check the size by multiplying the entries in A005 table by 138. This is (in my test system) the ABAP width of the structure.
If you have 9.000.000 records in A005, then it would take 1,24 Gb in the buffer (which is a clear sign to unbuffer). -
Oracle query taking more time in SSRS
Hi All
we have report which connects to Orale DB . the Query for the datset is running in 9 Secs in PL/sql developer but the same query is taking more than 150 secs in SSRS. we are using Oracleclient type provider.
Surendra ThotaHi Surendra,
Based on the current description, I understand that you may use Oracle Provider for OLE DB to connect Oracle database. If so, I suggest you using Microsoft OLE DB Provider for Oracle to compare the query time between SQLPlus and SSRS.
Here is a relative thread (SSRS Report with Oracle database performance problems) for your reference.
Hope this helps.
Regards,
Heidi Duan
If you have any feedback on our support, please click
here.
Heidi Duan
TechNet Community Support -
Select Query taking long time to run second time
Hi All,
I have Oracle 11gR1 in windows server 2008 R2 .
I have some tables with 10 million records . When i run the select query for those tables first time it gives me result in 15 seconds but if i am running the same script second time from the same session I am getting the result in 15 minutes to complete ..
Why it is happening? What may be the solution for this ?
Thanks & Regards,
Vikash jain(Junior DBA)Hi Mohamed,
I just saw that both the times for the same query execution plan is different ..
here are the details :
First time Second Time
g84m3qqjv2p3q g84m3qqjv2p3q
2733045235 1310485984
So plz tell me how should i force database to use the first execution plan ?
I got this script for forcing the Db to use the same execution plan
accept sql_id -
prompt 'Enter value for sql_id: ' -
default 'X0X0X0X0'
accept plan_hash_value -
prompt 'Enter value for plan_hash_value: ' -
default 'X0X0X0X0'
accept fixed -
prompt 'Enter value for fixed (NO): ' -
default 'NO'
accept enabled -
prompt 'Enter value for enabled (YES): ' -
default 'YES'
accept plan_name -
prompt 'Enter value for plan_name (ID_sqlid_planhashvalue): ' -
default 'X0X0X0X0'
set feedback off
set sqlblanklines on
set serveroutput on
declare
l_plan_name varchar2(40);
l_old_plan_name varchar2(40);
l_sql_handle varchar2(40);
ret binary_integer;
l_sql_id varchar2(13);
l_plan_hash_value number;
l_fixed varchar2(3);
l_enabled varchar2(3);
major_release varchar2(3);
minor_release varchar2(3);
begin
select regexp_replace(version,'\..*'), regexp_substr(version,'[0-9]+',1,2) into major_release, minor_release from v$instance;
minor_release := 2;
l_sql_id := '&&sql_id';
l_plan_hash_value := to_number('&&plan_hash_value');
l_fixed := '&&fixed';
l_enabled := '&&enabled';
ret := dbms_spm.load_plans_from_cursor_cache(
sql_id=>l_sql_id,
plan_hash_value=>l_plan_hash_value,
fixed=>l_fixed,
enabled=>l_enabled);
if minor_release = '1' then
-- 11gR1 has a bug that prevents renaming Baselines
dbms_output.put_line(' ');
dbms_output.put_line('Baseline created.');
dbms_output.put_line(' ');
else
-- This statements looks for Baselines create in the last 4 seconds
select sql_handle, plan_name,
decode('&&plan_name','X0X0X0X0','SQLID_'||'&&sql_id'||'_'||'&&plan_hash_value','&&plan_name')
into l_sql_handle, l_old_plan_name, l_plan_name
from dba_sql_plan_baselines spb
where created > sysdate-(1/24/60/15);
ret := dbms_spm.alter_sql_plan_baseline(
sql_handle=>l_sql_handle,
plan_name=>l_old_plan_name,
attribute_name=>'PLAN_NAME',
attribute_value=>l_plan_name);
dbms_output.put_line(' ');
dbms_output.put_line('Baseline '||upper(l_plan_name)||' created.');
dbms_output.put_line(' ');
end if;
end;
undef sql_id
undef plan_hash_value
undef plan_name
undef fixed
set feedback on
Output:
Enter value for sql_id: g84m3qqjv2p3q
Enter value for plan_hash_value: 2733045235
Enter value for fixed (NO):
Enter value for enabled (YES):
Enter value for plan_name (ID_sqlid_planhashvalue): g84m3qqjv2p3q
old 16: l_sql_id := '&&sql_id';
new 16: l_sql_id := 'g84m3qqjv2p3q';
old 17: l_plan_hash_value := to_number('&&plan_hash_value');
new 17: l_plan_hash_value := to_number('2733045235');
old 18: l_fixed := '&&fixed';
new 18: l_fixed := 'NO';
old 19: l_enabled := '&&enabled';
new 19: l_enabled := 'YES';
old 40: decode('&&plan_name','X0X0X0X0','SQLID_'||'&&sql_id'||'_'||'&&plan_hash_value','&&plan_name')
new 40: decode('g84m3qqjv2p3q','X0X0X0X0','SQLID_'||'g84m3qqjv2p3q'||'_'||'2733045235','g84m3qqjv2p3q')
declare
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 39
Kindly help me to resolve the issue ..
Thanks & Regards,
Vikash Jain(Junior DBA) -
Select Statement taking more time.How to improve the query performance.
SELECT DISTINCT ORDERKEY, SUM(IMPRESSIONCNT) AS ActualImpressions ,SUM(DiscountedSales)AS ActualRevenue ,SUM(AgencyCommAmt) as AgencyCommAmt
,SUM(SalesHouseCommAMT) as SalesHouseCommAMT
--INTO Anticiapted_ADXActualsMeasures
FROM AdRevenueFact_ADX ADx WITH(NOLOCK)
Where FiscalMonthkey >=201301 and Exists (Select 1 from Anticipated_cdr_AX_OrderItem OI Where Adx.Orderkey=Oi.Orderkey)
GROUP BY ORDERKEY
Clustered indexes on orderkey,fiscalmonthkey and orderkey in AdRevenueFact_ADX(contain more than 170 million rows)
thanksAs mentioned by Kalman, if your clustered index starts with Orderkey, then this query will require a full table scan. If it is an option to change the clustered index in such a way that FiscalMonthkey is the leading column, then only the data of the last
two year has to be queried.
In addition, you should have a look at the indexes of table Anticipated_cdr_AX_OrderItem. Ideally, there is a nonclustered index on Orderkey.
To get better advice, please post the query plan and list all available indexes of these tables.
Finally, an off topic remark: it is a good practice to keep consistent spelling of object names, and to keep the same spelling as their declaration. Your query would cause serious problems if the database is ever run with case sensitive collation.
Gert-Jan -
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. -
JDBC look Up query taking more time to process
Hi all,
I am using JDBC Look Up in my project to retreive data from multiple tables.But the problem here is it is taking 10-12 minutes for processing the query which has around 770 records.So my question is there any way that i can reduce the time of processing query.
Ex:Select EmpId from EmpTable where EmpId>500 and EmpName="Arun"
Here I have 770 records and it is taking 12 minutes to retreive results.
Is there any database tuning technique that we can use in JDBC Look up in PI?
Thanks in Advance.
Regards,
Yeshwanth> I am using JDBC Look Up in my project to retrieve data from multiple tables.But the problem here is it is taking 10-12 minutes for processing the query which has around 770 records.So my question is there any way that i can reduce the time of processing query.
This is happening since you are executing the Query (Select F1 from tablename where segment1='X', segment2='Y',segment3='X1',segment4='Y1',segment5='X2',segment6='Y2') for each record. So, the execution is 770 times in your case, which means it is opening and closing DB Accessor channel 770 times which is basically causing performance.
Better pass all fields in one Context as input to JDBCLookUP UDF and logically iterate by opening only one DB accessor.
I am just providing a rough UDF code, so it might not work at first shot. Change it according to your requirement.
Note: UDF should be advanced in nature (context or Queue)
Sample Code
Channel channel = null;
Map rowMap = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
try
//Determine a channel, as created in the Configuration
channel = LookupService.getChannel("<BUSINESSYSTEM>","<CHANNELNAME>");// give your service and channel
//Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.
accessor = LookupService.getDataBaseAccessor(channel);
catch (Exception e1)
e1.printStackTrace();
for (i=0; i<a.length;i++ )
//Query = "Select F1 from tablename where segment1='X', segment2='Y',segment3='X1',segment4='Y1',segment5='X2',segment6='Y2'";
Query = "Select " + a<i> + " from tablename where segment1='X', segment2='Y',segment3='X1',segment4='Y1',segment5='X2',segment6='Y2'";
try{
resultSet = null;
//Execute Query and get the values in resultset
resultSet = accessor.execute(Query);
for(Iterator rows = resultSet.getRows();rows.hasNext();)
rowMap = (Map)rows.next();
result.addValue((String)rowMap.get(a<i>)); //this statement might not be correct as your query is already fetching F1, so make some adjust in this statement accordingly
catch(Exception e2)
//result.addValue(ex.getMessage());
e2.printStackTrace();
try{
if (accessor!=null)
accessor.close();
catch(Exception e3)
e3.printStackTrace();
Let us know the outcome.......
Regards,
Praveen Gujjeti.
Edited by: Praveen Gujjeti on Jun 29, 2010 10:38 PM -
Alter table query taking more time
Hi,
My table T1 contains lots of data and when I am trying to run the below query its taking around 1 hour to update and some times its hanging.
"ALTER TABLE T1 ADD COLUMN C1 INTEGER DEFAULT 1 NOT NULL;"
How we can resolve this? Any help
Thanks,
SankarMy table T1 contains lots of data and when I am
trying to run the below query its taking around 1
hour to updateYes, it's normal, if it's a big table.Oracle has to update every record in your table.
and some times its hanging.How Do you know that it hangs? -
Query taking more time then required.
I have aquery which is taking is taking 8-9 min to retrieve data. It contain 27,000 rows. pls tell me how can i optimize this query.
SELECT DEPO_CODE,
DEPO_NAME,
DEPO_LOCAL_NAME,
CIRCLE_ID,
CIRCLE_CODE,
CIRCLE_NAME,
CIRCLE_LOCAL_NAME,
VILLAGE_ID,
VILLAGE_CODE,
VILLAGE_NAME,
VILLAGE_LOCAL_NAME,
MEM_ID,
MEM_CODE,
MEM_NAME,
MEM_LOCAL_NAME,
MEM_TYPE,
Mem_typ_srno,
AMOUNT,
SHARE_AMT,
TONNAGE,
(NVL(AMOUNT, 0)) - (NVL(SHARE_AMT, 0)) Balance
FROM (SELECT D.DP_TYPE_CODE DEPO_CODE,
D.DP_TYPE_NAME DEPO_NAME,
D.DP_TYPE_NAME_LOCAL DEPO_LOCAL_NAME,
G.GUT_ID CIRCLE_ID,
G.GUT_CODE CIRCLE_CODE,
G.GUT_NAME CIRCLE_NAME,
G.LOCAL_GUT_NAME CIRCLE_LOCAL_NAME,
V.VILLAGE_ID VILLAGE_ID,
V.VILLAGE_CODE VILLAGE_CODE,
V.VILLAGE_NAME VILLAGE_NAME,
V.LOCAL_VILLAGE_NAME VILLAGE_LOCAL_NAME,
M.FAAM_ID MEM_ID,
M.FAAM_CODE MEM_CODE,
M.FAAM_NAME MEM_NAME,
M.FAAM_LOCAL_NAME MEM_LOCAL_NAME,
decode(T.MEMBER_TYPE,
'Y',
'ºÉ¦ÉɺÉnù',
'N',
'ʤÉMÉ®ú-ºÉ¦ÉɺÉnù',
'G',
'MÉä]õEòäxÉ',
'D',
'Êb÷{ÉÉìÊZÉ]õ®') MEM_TYPE,
decode(T.MEMBER_TYPE, 'Y', 1, 'N', 2, 'D', 3, 'G', 4) Mem_typ_srno,
SUM(NVL(T.AMOUNT, 0)) AMOUNT,
NULL SHARE_AMT,
T.TONAGE TONNAGE
FROM CANE_DEPOSIT_TRN T,
CANE_DEPOSITE_TYPE_MST D,
FA_ACT_MST M,
VILLAGE_MST V,
GUT_MST G
WHERE T.ACC_ID = M.FAAM_ID
AND T.DEPOSIT_TYPE_ID = D.DP_TYPE_ID
AND M.FAAM_VILLAGE = V.VILLAGE_ID(+)
AND V.GUT_ID = G.GUT_ID(+)
AND T.TRDATE BETWEEN NVL(&P_FROM_DATE, T.TRDATE) AND
NVL(&P_TO_DATE, T.TRDATE)
AND T.MEMBER_TYPE = NVL(&p_grower_type_id, T.MEMBER_TYPE)
AND M.FAAM_ID = NVL(&P_ACC_ID, M.FAAM_ID)
AND D.DP_TYPE_ID = NVL(&P_DEPOSITE_TYPE_ID, D.DP_TYPE_ID)
AND T.COMPANY = &P_COMPANY_ID
AND T.BRANCH = &P_BRANCH_ID
AND G.GUT_ID = NVL(&p_gut_id, G.GUT_ID)
and v.village_id = nvl(&p_village_id, V.VILLAGE_ID)
GROUP BY D.DP_TYPE_CODE,
D.DP_TYPE_NAME,
D.DP_TYPE_NAME_LOCAL,
G.GUT_ID,
G.GUT_CODE,
G.GUT_NAME,
T.MEMBER_TYPE,
G.LOCAL_GUT_NAME,
V.VILLAGE_ID,
V.VILLAGE_CODE,
V.VILLAGE_NAME,
V.LOCAL_VILLAGE_NAME,
M.FAAM_ID,
M.FAAM_CODE,
M.FAAM_NAME,
M.FAAM_LOCAL_NAME,
M.MEMBER_TYPE,
T.TONAGE
UNION ALL
SELECT D.DP_TYPE_CODE DEPO_CODE,
D.DP_TYPE_NAME DEPO_NAME,
D.DP_TYPE_NAME_LOCAL DEPO_LOCAL_NAME,
G.GUT_ID CIRCLE_ID,
G.GUT_CODE CIRCLE_CODE,
G.GUT_NAME CIRCLE_NAME,
G.LOCAL_GUT_NAME CIRCLE_LOCAL_NAME,
V.VILLAGE_ID VILLAGE_ID,
V.VILLAGE_CODE VILLAGE_CODE,
V.VILLAGE_NAME VILLAGE_NAME,
V.LOCAL_VILLAGE_NAME VILLAGE_LOCAL_NAME,
M.FAAM_ID MEM_ID,
M.FAAM_CODE MEM_CODE,
M.FAAM_NAME MEM_NAME,
M.FAAM_LOCAL_NAME MEM_LOCAL_NAME,
NULL MEM_TYPE,
NULL Mem_typ_srno,
NULL AMOUNT,
SUM(NVL(S.AMOUNT, 0)) SHARE_AMT,
NULL TONNAGE
FROM CANE_DEPOSIT_TRF_TO_SHARE S,
CANE_DEPOSITE_TYPE_MST D,
FA_ACT_MST M,
VILLAGE_MST V,
GUT_MST G
WHERE S.ACC_ID = M.FAAM_ID
AND S.DEPOSIT_TYPE_ID = D.DP_TYPE_ID
AND M.FAAM_VILLAGE = V.VILLAGE_ID(+)
AND V.GUT_ID = G.GUT_ID(+)
AND S.TRDATE BETWEEN NVL(&P_FROM_DATE, S.TRDATE) AND
NVL(&P_TO_DATE, S.TRDATE)
AND M.FAAM_ID = NVL(&P_ACC_ID, M.FAAM_ID)
AND D.DP_TYPE_ID = NVL(&P_DEPOSITE_TYPE_ID, D.DP_TYPE_ID)
AND S.COMPANY = &P_COMPANY_ID
AND S.BRANCH = &P_BRANCH_ID
AND G.GUT_ID = NVL(&p_gut_id, G.GUT_ID)
and v.village_id = nvl(&p_village_id, V.VILLAGE_ID)
GROUP BY D.DP_TYPE_CODE,
D.DP_TYPE_NAME,
D.DP_TYPE_NAME_LOCAL,
G.GUT_ID,
G.GUT_CODE,
G.GUT_NAME,
G.LOCAL_GUT_NAME,
V.VILLAGE_ID,
V.VILLAGE_CODE,
V.VILLAGE_NAME,
V.LOCAL_VILLAGE_NAME,
M.FAAM_ID,
M.FAAM_CODE,
M.FAAM_NAME,
M.FAAM_LOCAL_NAME,
M.MEMBER_TYPE)
ORDER BY Mem_typ_srno, DEPO_CODE, CIRCLE_ID, VILLAGE_ID, MEM_NAMEMaybe
when using if-parameter-is-null-then-all approach and parameters are mostly not null pushing predicates can substantially reduce the number of rows to join (to an extent where indexes are not really necessary).
Could not be of any help as the Optimizer is very good at predicate pushing and might have seen to it already.
Rewritten to ANSI join syntax
<tt>
WHERE S.ACC_ID = M.FAAM_ID
AND S.DEPOSIT_TYPE_ID = D.DP_TYPE_ID
AND M.FAAM_VILLAGE = <b><font color="red">V</font>.VILLAGE_ID<font color="red">( + )</font></b>
AND <b><font color="red">V</font>.GUT_ID</b> = <b><font color="blue">G</font>.GUT_ID<font color="blue">( + )</font></b>
</tt>
being suspicious about the combination as above
select depo_code,depo_name,depo_local_name,
circle_id,circle_code,circle_name,circle_local_name,
village_id,village_code,village_name,village_local_name,
mem_id,mem_code,mem_name,mem_local_name,
mem_type,mem_typ_srno,
amount,share_amt,tonnage,
(nvl(amount, 0)) - (nvl(share_amt, 0)) balance
from (select d.depo_code,d.depo_name,d.depo_local_name,
g.circle_id,g.circle_code,g.circle_name,g.circle_local_name,
v.village_id,v.village_code,v.village_name,v.village_local_name,
m.mem_id,m.mem_code,m.mem_name,m.mem_local_name,
t.mem_type,t.mem_typ_srno,
sum(t.amount) amount,to_number(null) share_amt,t.tonage
from (select acc_id,deposit_type_id,amount,tonnage,
decode(member_type,'Y','oɦÉÉoÉnu','N','E¤ÉMÉ®ú-oɦÉÉoÉnu','G','MÉä]oEoäxÉ','D','Eb÷{ÉÉiEZÉ]o®') mem_type,
decode(member_type,'Y',1,'N',2,'D',3,'G',4) mem_typ_srno,
from cane_deposit_trn
where trdate between nvl(&p_from_date,trdate) and nvl(&p_to_date,trdate)
and member_type = nvl(&p_grower_type_id,member_type)
and company = &p_company_id
and branch = &p_branch_id
) t
join
(select dp_type_id,dp_type_code depo_code,dp_type_name depo_name,dp_type_name_local depo_local_name
from cane_deposite_type_mst
where dp_type_id = nvl(&p_deposite_type_id,dp_type_id)
) d
on t.deposit_type_id = d.dp_type_id
join
(select faam_id,faam_village,faam_id mem_id,faam_code mem_code,faam_name mem_name,faam_local_name mem_local_name,member_type
from fa_act_mst
where m.faam_id = nvl(&p_acc_id,m.faam_id)
) m
on m.faam_id = t.acc_id
left join
(select village_id,gut_id,village_code,village_name,local_village_name village_local_name
from village_mst
where v.village_id = nvl(&p_village_id,village_id)
) v
on m.faam_village = v.village_id
left join
(select gut_id circle_id,gut_code circle_code,gut_name circle_name,local_gut_name circle_local_name
from gut_mst
where g.gut_id = nvl(&p_gut_id,g.gut_id)
) g
on v.gut_id = g.gut_id
group by d.depo_code,d.depo_name,d.depo_local_name,
g.circle_id,g.circle_code,g.circle_name,
t.mem_type,
g.circle_local_name,
v.village_id,v.village_code,v.village_name,v.village_local_name,
m.mem_id,m.mem_code,m.mem_name,m.mem_local_name,m.member_type,
t.tonage
union all
select d.depo_code,d.depo_name,d.depo_local_name,
g.circle_id,g.circle_code,g.circle_name,g.circle_local_name,
v.village_id,v.village_code,v.village_name,v.village_local_name,
m.mem_id,m.mem_code,m.mem_name,m.mem_local_name,
null mem_type,null mem_typ_srno,null amount,
sum(s.amount) share_amt,null tonnage
from (select acc_id,deposit_type_id,amount
from cane_deposit_trf_to_share
where trdate between nvl(&p_from_date,trdate) and nvl(&p_to_date,trdate)
and s.company = &p_company_id
and s.branch = &p_branch_id
) s
join
(select dp_type_id,dp_type_code depo_code,dp_type_name depo_name,dp_type_name_local depo_local_name
from cane_deposite_type_mst
where dp_type_id = nvl(&p_deposite_type_id,dp_type_id)
) d
on s.deposit_type_id = d.dp_type_id
join
(select faam_id mem_id,faam_village,faam_code mem_code,faam_name mem_name,faam_local_name mem_local_name,member_type
from fa_act_mst
where faam_id = nvl(&p_acc_id,faam_id)
) m
on m.faam_id = s.acc_id
left join
(select village_id,gut_id,village_code,village_name,local_village_name village_local_name
from village_mst
where village_id = nvl(&p_village_id,village_id)
) v
on m.faam_village = v.village_id
left join
(select gut_id circle_id,gut_code circle_code,gut_name circle_name,local_gut_name circle_local_name
from gut_mst
where gut_id = nvl(&p_gut_id,gut_id)
) g
on v.gut_id = g.gut_id
group by d.depo_code,d.depo_name,d.depo_local_name,
g.circle_id,g.circle_code,g.circle_name,g.circle_local_name,
v.village_id,v.village_code,v.village_name,v.village_local_name,
m.mem_id,m.mem_code,m.mem_name,m.mem_local_name,m.member_type
order by mem_typ_srno,depo_code,circle_id,village_id,mem_nameRegards
Etbin -
Same select statement taking more time
Hello all,
I have two select statements. only the name of table from where it is fetching records are different.
1) select belnr posnr etenr into corresponding fields of table it_cdtemp2
from j_3avasso for all entries in it_cdtemp1
where belnr = it_cdtemp1-vbeln and posnr = it_cdtemp1-posnr .
it_cdtemp1 has 100 entries and j_3avasso has 20000 entries
2) select belnr posnr etenr into corresponding fields of table it_cdtemp2
from j_3avap for all entries in it_cdtemp1
where belnr = it_cdtemp1-vbeln and posnr = it_cdtemp1-posnr .
it_cdtemp1 has 100 entries and j_3avasso has 2000 entries
statement 1 is executing less than a minute where as statement 2 is taking around 15 to 20 minutes
could anyone suggest why.. if so how to minimize run time
Regards
BalaHi,
You can sort the internal table before using FOR ALL ENTRIES BY VBELN and POSNR.
This will save a lot of processing time.
You can also try combing both the selects as one join statement taking both the tables with for all entries addition.
Regards,
Subhashini
Edited by: Subhashini K on Oct 8, 2009 2:58 PM
Maybe you are looking for
-
Logical system and partner profile configuration
Hi, I have a SQL server which is defined as a Business system in my landscape. It is sending records to ECC 6.0 which makes it a JDBC to IDOC scenario (inbound IDocs) First question is do I have to mention a logical system name for the SQL server Bus
-
When opening a folder, its takes ages to show the files
Hi All, I have a 2012 Macbook Pro running Lion (as you can probably guess!), with a 512Gb SSD and 8Gb Ram. Its a pretty fast machine and i'm really happy with the way it runs, however when I open a folder to view files, it opens and shows a blank fol
-
How to remove display in iMac 2012?
I would like to know how to remove the display in Mac 2012. It is very important for me to change RAM memory or hard drive by myself without taking the whole machine to the repairment service. I wish that Apple´s wise designers have considered this
-
i run this import command at dos prompt: c:\imp system/system file=c:\x.dmp full=y i got this error : IMP-00017 : following statement failed with oracle error 4068: "BEGIN SYS.DBMS_REPCAT_MIG_PRE_IMPORT; END;" ORA-04068 : existing state packages has
-
Photoshop elements 10 not opeining
I can no longer open my Photoshop Elements 10. I uninstalled and reinstalled but it still wont open. I can get the organizer to open from files but need to get to editor but can't seem to open it anywhere