Performance optimization on select query for all entries
Hi All,
I want to optimize the select query in my Program.
The select query is taking lot of time to search the records for the given condition in the where clause
and more interestingly there are no records fetched from the database as the where condition does not matches.
It is taking more than 30 min to search the record and the result is no record found.
Below is my select query. I have also created the secondary Index for the same.
In My opinion FOR ALL ENTRIES is taking lot of time. Because there are more than 1200 records in internal table t_ajot
select banfn bnfpo bsart txz01 matnr Werks lgort matkl reswk menge meins flief ekorg
INTO CORRESPONDING FIELDS OF TABLE t_req
FROM eban
FOR ALL ENTRIES IN t_ajot
WHERE matkl >= t_ajot-matkl_low
AND matkl <= t_ajot-matkl_high
AND werks = t_ajot-werks
AND loekz = ' '
AND badat IN s_badat
AND bsart = 'NB'.
Please suggest.
Hi,
that,
FOR ALL ENTRIES IN t_ajot
WHERE matkl >= t_ajot-matkl_low
AND matkl <= t_ajot-matkl_high
AND werks = t_ajot-werks
AND loekz = ' '
AND badat IN s_badat
AND bsart = 'NB'.
looks strange.
However:
How does your index look like?
What executoin plan do you get?
How do the statistics look like?
Whats the content of the variables t_ajot-... and s_badata?
Kind regards,
Hermann
Similar Messages
-
Select query 'for all entries'
Hello Friends,
SELECT emp_id emp_name
INTO corresponding fields of table itab_emp
FROM employee
for all entries in itab_dept
WHERE emp_id = itab_dept_emp_id.
In the above select query we are using 'for all entries' for the internal table itab_dept.What will happen if the join fails?Will we get any data in the output table?
What is the prerequisites for using 'for all entries'.
Please advice me on this.
Regards
Ashish.Hi
In this case all the records available in employee table are extracted into internal table itab_emp.
It is safe to check whether itab_dept is initial or not.
If it is initial then stop the select query.
Check the following program u will get an idea.
Also try this program by removing comment to 'REFRESH IT_LFA1'.
REPORT ZBM_PG .
TABLES: LFA1, EKKO.
DATA:
IT_LFA1 TYPE TABLE OF LFA1 WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,
IT_LFA1 TYPE TABLE OF LFA1 WITH HEADER LINE,
IT_EKKO TYPE TABLE OF EKKO WITH HEADER LINE.
SELECT * FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR EQ '0000001000' OR LIFNR EQ '0000001500'.
SELECT * FROM LFA1 INTO TABLE IT_LFA1 UP TO 1 ROWS.
refresh it_lfa1.
SELECT * FROM EKKO INTO TABLE IT_EKKO FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.
LOOP AT IT_EKKO.
WRITE: / IT_EKKO-LIFNR, IT_EKKO-EBELN.
ENDLOOP.
Reward me if it is useful -
Performance Issue in Select Statement (For All Entries)
Hello,
I have a report where i have two select statement
First Select Statement:
Select A B C P Q R
from T1 into Table it_t1
where ....
Internal Table it_t1 is populated with 359801 entries through this select statement.
Second Select Statement:
Select A B C X Y Z
from T2 in it_t2 For All Entries in it_t1
where A eq it_t1-A
and B eq it_t1-B
and C eq it_t1-C
Now Table T2 contains more than 10 lac records and at the end of select statement it_t2 is populated with 844003 but it takes a lot of time (15 -20 min) to execute second select statement.
Can this code be optimized?
Also i have created respective indexes on table T1 and T2 for the fields in Where Condition.
Regards,If you have completed all the steps mentioned by others, in the above thread, and still you are facing issues then,.....
Use a Select within Select.
First Select Statement:
Select A B C P Q R package size 5000
from T1 into Table it_t1
where ....
Second Select Statement:
Select A B C X Y Z
from T2 in it_t2 For All Entries in it_t1
where A eq it_t1-A
and B eq it_t1-B
and C eq it_t1-C
do processing........
endselect
This way, while using for all entries on T2, your it_t1, will have limited number of entries and thus the 2nd select will be faster.
Thanks,
Juwin -
Performance optimization in Select query
Hi All,
Please suggest good performance practice for the below code.
SELECT * FROM BKPF WHERE BUKRS IN SO_BUKRS
AND BELNR IN SO_BELNR
AND GJAHR IN SO_GJAHR
AND BLART IN SO_BLART
AND BUDAT IN SO_BUDAT
AND USNAM IN SO_USNAM.
CLEAR BSEG.
SELECT * FROM BSEG WHERE BUKRS EQ BKPF-BUKRS
AND BELNR EQ BKPF-BELNR
AND GJAHR EQ BKPF-GJAHR
AND KOART EQ 'K'.
SELECT SINGLE * FROM LFA1 WHERE LIFNR EQ BSEG-LIFNR
AND KTOKK IN SO_KTOKK.
CHECK SY-SUBRC EQ 0.
MOVE-CORRESPONDING BKPF TO ITAB2.
MOVE BSEG-LIFNR TO ITAB2-LIFNR.
APPEND ITAB2.
ENDSELECT.
PERFORM CHECK_FOR_REVERSAL.
ENDSELECT.
Thanks
Sonaldeclare internal table for BKPF, BSEG & LFA1 separately.
instead of using Select & End select, use for all entries.
SELECT * FROM BKPF into table itab1 WHERE BUKRS IN SO_BUKRS
AND BELNR IN SO_BELNR
AND GJAHR IN SO_GJAHR
AND BLART IN SO_BLART
AND BUDAT IN SO_BUDAT
AND USNAM IN SO_USNAM.
if not itab1[] is initial.
sort bkpf by belnr.
SELECT * FROM BSEG into table itab2
for all entries in itab1
WHERE BUKRS EQ itab1-BUKRS
AND BELNR EQ itab1-BELNR
AND GJAHR EQ itab1-GJAHR
AND KOART EQ 'K'.
if not itab2[] is initial.
sort itab2 by lifnr
SELECT SINGLE * FROM LFA1 into table itab3
for all entries in itab2
WHERE LIFNR EQ itab2-LIFNR
AND KTOKK IN SO_KTOKK.
endif.
endif.
endif.
sort itab1 by belnr.
sort itab2 by belnr.
sort itab3 by lifnr.
loop at itab1.
move-corresponding itab1 to itfinal.
loop at itab2 where belnr = itab1-belnr.
move-corresponding itab2 to itfinal.
read itab3 with key lifnr = itab2-lifnr.
if sy-subrc = 0.
move-corresponding itab3 to itfinal.
endif.
endloop.
append itfinal.
clear itfinal.
endloop. -
Regarding Select using FOR ALL ENTRIES (FAEI)
Hi all,
Please help me with Select using FOR ALL ENTRIES (FAEI)
Thanks in advns,
Das.Hi,
This version of the SELECT statement was the only way to join tables until SAP release 3.0E. It is recommended that the SQL JOIN be used. However, this is an alternate method of joining tables that may be used in some circumstances. Remember, SQL JOIN doesnt utilize the SAP internal database buffer.
Example:
SELECT EKGRP FROM T024
INTO TABLE T_024.
SELECT MATNR WERKS EKGRP FROM MARC
INTO TABLE T_MARC
FOR ALL ENTRIES IN T_024
WHERE EKGRP = T_024-EKGRP.
Prerequisites:
The driver table cannot be empty. This would cause one full table scan.
In general, keep the driver table as small and unique (in regards to the fields that would be needed for referencing in the FAEI) as possible. If duplicate entries are not deleted, identical data is read unnecessarily from the database.
If FAEI is used, the selected field list must be a superset of all the key fields of the database tables used in SQL. This is absolutely required to avoid data loss since the DB interface in R/3 returns unique sets of the result set to the application program. Failing to ensure this may cause problems when you want to get all records from a database table that match a certain condition.
Avoid using FAEI on a small DB table (like configuration tables). This could potentially cause full table scans for each FAEI packet. Even if it does index range scan, it is better to get data from the small DB tables by individual SELECT without the use of FAE.
Always use FAEI in conjunction with a DB index otherwise it would cause multiple full table scans (one table scan for each FAEI packet).
The first field(s) of the DB index should refer to the fields of the FAEI driver table in the SQL WHERE clause. Do not leave gaps between index fields in the WHERE clause. Inefficient index access will impact every FAEI packets.
FAEI works best when retrieving a small percentage of data from a Database table. When a large percentage of data is needed, consider getting data out of the DB table without FAEI implementation, and then do additional filtration in your application
Reward points if found helpfull...
Cheers,
Chandra Sekhar. -
hi gurus,
plz check my report using for all entries where i am give data in selection screen from date to date as 3.01.2007 to 4.02.2007
my code does not provide me data between above date to date.
it fetch data from other date like 26.06.2006 to some other
plz check code and give me solution for it.
TABLES: bseg, bkpf.
*ALV grid_data
TYPE-POOLS: slis.
INTERNAL TABLES
TYPES: BEGIN OF it_output,
bukrs TYPE bseg-bukrs, "Company Code
belnr TYPE bseg-belnr, "Accounting Document Number
gjahr TYPE bseg-gjahr, "Fiscal Year
buzei TYPE bseg-buzei, "Number of Line Item
augdt TYPE bseg-augdt, "Clearing Date
shkzg TYPE bseg-shkzg, "Debit/Credit Indicator
dmbtr TYPE bseg-dmbtr, "Amount in local currency
kostl TYPE bseg-kostl, "Cost Center
hkont TYPE bseg-hkont, "G/L Account
matnr TYPE bseg-matnr, "Material Number
werks TYPE bseg-werks, "Plant
erfmg TYPE bseg-erfmg, "Quantity in unit of entry
blart TYPE bkpf-blart, "Document type
bldat TYPE bkpf-bldat, "Document Date
budat TYPE bkpf-budat, "Posting Date
monat TYPE bkpf-monat, "Fiscal period
cpudt TYPE bkpf-cpudt, "Document Entry Date
usnam TYPE bkpf-usnam, "User name
tcode TYPE bkpf-tcode, "Transaction Code20
bktxt TYPE bkpf-bktxt, "Document Header Text
waers TYPE bkpf-waers, "Currency Key
awtyp TYPE bkpf-awtyp, "Reference procedure
awkey TYPE bkpf-awkey, "Object key
END OF it_output.
TYPES: BEGIN OF it_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
blart TYPE bkpf-blart,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
monat TYPE bkpf-monat,
cpudt TYPE bkpf-cpudt,
usnam TYPE bkpf-usnam,
tcode TYPE bkpf-tcode,
bktxt TYPE bkpf-bktxt,
waers TYPE bkpf-waers,
awtyp TYPE bkpf-awtyp,
awkey TYPE bkpf-awkey,
END OF it_bkpf.
DATA: lt_output TYPE it_output OCCURS 0 WITH HEADER LINE.
DATA: lt_bkpf TYPE it_bkpf OCCURS 0 WITH HEADER LINE.
ALV DECLARATION DATA *
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
it_heading TYPE slis_t_listheader,
it_sort TYPE slis_t_sortinfo_alv,
it_events TYPE slis_t_event,
it_alv_event TYPE slis_alv_event,
gv_repname TYPE syrepid,
gv_save TYPE char1,
is_layout TYPE slis_layout_alv.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE text-011.
SELECT-OPTIONS: s_bukrs FOR bseg-bukrs NO INTERVALS,
s_blart FOR bkpf-blart,
s_budat FOR bkpf-budat.
SELECTION-SCREEN END OF BLOCK bl.
START OF SELECTION *
START-OF-SELECTION.
PERFORM get_data.
End of Selection *
END-OF-SELECTION.
PERFORM build_field_catalog.
PERFORM eventstab.
PERFORM display_data.
FORMS *
*& Form get_data
Get Data
FORM get_data .
SELECT bukrs
belnr
gjahr
buzei
augdt
shkzg
dmbtr
kostl
hkont
matnr
werks
erfmg
INTO TABLE lt_output
FROM bseg
WHERE bukrs IN s_bukrs.
IF sy-subrc = 0.
SORT lt_output BY belnr.
DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
ENDIF.
IF NOT lt_output[] IS INITIAL.
SELECT bukrs
belnr
gjahr
blart
bldat
budat
monat
cpudt
usnam
tcode
bktxt
waers
awtyp
awkey
INTO TABLE lt_bkpf FROM bkpf
FOR ALL ENTRIES IN lt_output
WHERE bukrs = lt_output-bukrs AND
belnr = lt_output-belnr AND
gjahr = lt_output-gjahr."AND
blart IN s_blart AND
budat IN s_budat ." AND
blart = 'SA' OR
blart = 'SB' OR
blart = 'AB' OR
blart = 'ZC'.
*sort lt_bkpf by blart budat.
DELETE lt_bkpf WHERE blart NOT IN s_blart AND
budat NOT IN s_budat.
ENDIF.
SORT lt_bkpf BY bukrs belnr.
SORT lt_output[].
DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
LOOP AT lt_output.
READ TABLE lt_bkpf WITH KEY bukrs = lt_output-bukrs
belnr = lt_output-belnr
budat = lt_output-budat
BINARY SEARCH.
IF sy-subrc = 0.
MOVE: lt_bkpf-gjahr TO lt_output-gjahr,
lt_bkpf-belnr TO lt_output-belnr,
lt_bkpf-blart TO lt_output-blart,
lt_bkpf-bldat TO lt_output-bldat,
lt_bkpf-budat TO lt_output-budat,
lt_bkpf-monat TO lt_output-monat,
lt_bkpf-cpudt TO lt_output-cpudt,
lt_bkpf-usnam TO lt_output-usnam,
lt_bkpf-tcode TO lt_output-tcode,
lt_bkpf-bktxt TO lt_output-bktxt,
lt_bkpf-waers TO lt_output-waers,
lt_bkpf-awtyp TO lt_output-awtyp,
lt_bkpf-awkey TO lt_output-awkey.
MODIFY lt_output.
ELSE.
DELETE lt_output.
ENDIF.
ENDLOOP.
ENDFORM. "get_data
thanks jayantHi Jayant,
You cannot retrieve data first from BSEG and then from BKPF.
It is not correct and you cannot get the correct data.
You should use BKPF which is header table first and then
using for all entries retrieve data from BSEG.
Use date field in the select statement condition for BKPF table retrieval and
you don't have posting date field in BSEG.
If you do like this, it will definitely work.
Retrieve data from BKPF using date condition in SELECT statement.
Then, using for all entries retrieve from BSEG.
Reward if helpful. -
Dynamic SELECT containing 'FOR ALL ENTRIES'
Hi,
I am trying to do a slect from a table in which the table and the field to be selected will be dynamically populated using Field Symbol
Something like this,
SELECT * FROM <FS_TABLE>
INTO CORRESPONDING FIELDS OF TABLE <FS_IT_TABLE>
FOR ALL ENTRIES IN T_TABLE
WHERE <FS_FIELD> EQ T_TABLE-FIELD1.
I know that <FS_FIELD> cannot be used along with 'FOR ALL ENTRIES'. Is there any other way to achieve this?Hi!
Try out the dynamical WHERE conditions then:
PARAMETERS: column TYPE c LENGTH 8,
value TYPE c LENGTH 30.
DATA spfli_wa TYPE spfli.
DATA cond_syntax TYPE string.
CONCATENATE column '= value'
INTO cond_syntax SEPARATED BY space.
TRY.
SELECT SINGLE *
FROM spfli
INTO spfli_wa
WHERE (cond_syntax).
CATCH cx_sy_dynamic_osql_error.
MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.
Regards
Tamá -
Dynamic SELECT with FOR ALL ENTRIES IN: take 2
Hello Xperts,
we are now having a bit of new trouble with the following SELECT ... special thanks to Raul and Suhas for their previous contributions.
FIELD-SYMBOLS:
<itab1> TYPE standard table.
ASSIGN ATTR_T_I->* TO <itab1>.
select
FIELD1
FIELD2
from DBTAB1
into CORRESPONDING FIELDS OF table <itab1>
FOR ALL ENTRIES IN <itab1>
where
(condition).
ATTR_T_I is a static attibute of type table containing 10 records where all records have FIELD1 and FIELD2 empty.
The select finds in DBTAB1 entries fulfilling the 'condition' for 8 of the above 10 records in ATTR_T_I.
Hence, after the select 8 of the 10 records in ATTR_T_I have the fields FIELD1 and FIELD2 filled (ie not empty).
So far so good!
BUT: the 2 remaining records (i.e. those without entries in DBTAB1 fullfilling 'condition') have been deleted! Why? This is not what we want nor expected.
Any ideas out there how to fix this?
Thanx!Martin Helmstein wrote:
> Yes, 'condition' contains all the key fields of DBTAB1.
Hi Martin,
It's not the Where condition fields i was talking about. I was referring to the Select fields, you have to SELECT all the keyfields when using FAE. Something like this:
SELECT key1 key2 ... keyn "all the key fields of the table
field1 field2 ... fieldn
FROM table
INTO CORRESPONDING FIELDS OF it_data
FOR ALL ENTRIES IN <itab>
WHERE (condition).
You can search in the forums for further details. It has been discussed many a times.
BR,
Suhas -
Dynamic SELECT with FOR ALL ENTRIES IN
Hello Xperts,
we are having a bit of trouble with the following SELECT
FIELD-SYMBOLS:
<itab1> TYPE standard table.
ASSIGN ATTR_T_I->* TO <itab1>.
select
FIELD1
FIELD2
from DBTAB1
into CORRESPONDING FIELDS OF table <itab1>
FOR ALL ENTRIES IN <itab1>
where
FIELD3 = <itab1>-FIELD3 and
FIELD4 = <itab1>-FIELD4
ATTR_T_I is a static attibute of type table.
The syntax check throws the following message:
The specified type has no structure and therefore no component called FIELD3.
Any ideas out there how to solve this issue?
Thanx!Hi Martin,
Change your code like this and try.
DATA: itab2 TYPE TABLE OF string.
FIELD-SYMBOLS:
<itab1> TYPE standard table.
ASSIGN ATTR_T_I->* TO <itab1>.
APPEND 'FIELD3 = <itab1>-FIELD3 and' TO itab2.
APPEND 'FIELD4 = <itab1>-FIELD4' TO itab2.
select
FIELD1
FIELD2
from DBTAB1
into CORRESPONDING FIELDS OF table <itab1>
FOR ALL ENTRIES IN <itab1>
where
(itab2)
Regards,
Rahul Muraleedharan. -
The select with for all entries is not working correctly
IF NOT i_ekko_ekpo[] IS INITIAL.
SELECT ebeln
ebelp
zekkn
vgabe
bewtp
menge
bpmng
shkzg
INTO TABLE i_ekbe
FROM ekbe
FOR ALL ENTRIES IN i_ekko_ekpo
WHERE ebeln EQ i_ekko_ekpo-ebeln.
AND ebelp EQ i_ekko_ekpo-ebelp.
IF sy-subrc EQ 0.
SORT i_ekbe.
ENDIF.
ENDIF.
I have a PO with 2 line items in i_ekko_ekpo. In EKBE, I have 49 recs for this PO and this select is returning only 13 recs.
I tried by commenting EBELP and still the same result.
Thanks
Kiran
Edited by: kiran dasari on May 22, 2009 9:56 PMHi Sudhi, I added these now but still no charm
SELECT ebeln
ebelp
zekkn
vgabe
bewtp
menge
bpmng
shkzg
INTO TABLE i_ekbe
FROM ekbe
FOR ALL ENTRIES IN i_ekko_ekpo
WHERE ebeln EQ i_ekko_ekpo-ebeln
AND ebelp EQ i_ekko_ekpo-ebelp
AND zekkn GE '00'
AND vgabe IN ('1','2').
And as per your note: in the 13 entries, am having duplicate also. This is something weird for me now.
Any more clues.
Thanks
Kiran -
How to write select query for all the user tables in database
Can any one tell me how to select the columns from all the user tables in a database
Here I had 3columns as input...
1.phone no
2.memberid
3.sub no.
I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
I am trying for this query since 30days...
Help me please....any kind of help is appreciated.....Hi,
user13113704 wrote:
... i need to include the symbol (') for the numbers(values) to get selected..
eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
Starting in Oracle 10, you can also use Q-notation:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
-- Run preliminary query to generate main query
SPOOL c:\my_sql_dir\all_ah_t.sql
SELECT 'select call time, record, agn from '
|| owner
|| '.'
|| table_name
|| ' where phone_no = ''6186759765'' and memberid = j34563298'
|| CASE
WHEN ROW_NUMBER () OVER ( ORDER BY owner DESC
, table_name DESC
) = 1
THEN ';'
ELSE ' UNION ALL'
END AS txt
FROM all_tables
WHERE SUBSTR (table_name, 1, 4) = 'AH_T'
ORDER BY owner
, table_name
SPOOL OFF
-- Restore SQL*Plus features that interfere with raw output (if desired)
SET FEEDBACK ON
SET PAGESIZE 50
-- Run main query:
@c:\my_sql_dir\all_ah_t.sql
so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"? -
"For All Entries in ITAB" -error
Hello!
I am new to this ABAP. I getting one error in Select query "For All Entries" keyword. My problem is,
Iam taking vbeln field from the table LIPS and stored in internal table it_lips. and then based on this vbeln i am taking the material document no. field mblnr from MKPF table. The Common field present in this table is vbeln in LIPS and xblnr in MKPF.
my select query is,
select xblnr mblnr
into corresponding fields of table it_mkpf
from mkpf
for all entries in it_lips
where xblnr = it_lips-vbeln
and blart = 'WL'.Hi,
Use the below logic:
TYPES: BEGIN OF ty_mkpf,
mblnr TYPE mblnr,
xblnr TYPE xblnr1,
END OF ty_mkpf.
TYPES: BEGIN OF ty_lips,
vbeln TYPE vbeln_vl,
vbeln1 TYPE xblnr1,
END OF ty_lips.
DATA: git_mkpf TYPE STANDARD TABLE OF ty_mkpf,
git_lips TYPE STANDARD TABLE OF ty_lips.
DATA: gwa_lips TYPE ty_lips.
SELECT vbeln FROM lips INTO TABLE git_lips
UP TO 5 ROWS.
LOOP AT git_lips INTO gwa_lips.
gwa_lips-vbeln1 = gwa_lips-vbeln.
MODIFY git_lips FROM gwa_lips.
ENDLOOP.
SELECT mblnr xblnr
INTO TABLE git_mkpf
FROM mkpf
FOR ALL ENTRIES IN git_lips
WHERE xblnr = git_lips-vbeln1
AND blart = 'WL'. -
Is "Joins & For all entries" in same SQL Query Possible?
Hi all Professional,
Can we use "Inner Joins" and "For All Entries In" in the same SQL Query. if possible then pls clarify this query.
Here I am using three Transparent Table and fetching data from them.
SELECT abukrs abelnr ahkont axref2 ashkzg awrbtr agsber azfbdt azterm amwskz asgtxt axref1 agjahr abuzei
bkunnr bwerks bmenge bmeins bmatnr bkoart
cbukrs cbelnr cblart cbldat cbudat cxblnr cgjahr cstgrd cstblg cstblg c~xreversal
INTO CORRESPONDING FIELDS OF TABLE it_bsid FROM ( ( bsid AS a
INNER JOIN acctit AS b ON abukrs = bbukrs )
INNER JOIN bkpf AS c ON cbukrs = abukrs
AND cbelnr = abelnr
AND cgjahr = agjahr )
FOR ALL ENTRIES IN it_bkpf
WHERE
a~belnr EQ it_bkpf-belnr
AND a~gjahr EQ it_bkpf-gjahr
AND a~bukrs EQ it_bkpf-bukrs
AND a~gsber IN so_bus.
After executing this query, I'm getting Dump Error.
Error analysis
When the program was running, it was established that more
memory was needed than the operating system is able to provide savely.
To avoid a system crash, you must prevent this
situation.
Last error logged in SAP kernel
Component............ "EM"
Place................ "SAP-Server Development_DVL_01 on host Development (wp
2)"
Version.............. 37
Error code........... 7
Error text........... "Warning: EM-Memory exhausted: Workprocess gets PRIV "
Description.......... " "
System call.......... " "
Module............... "emxx.c"
Line................. 1886
Pls resolve, if anybody knows.
Thanks
DevinderHi,
During testing i notice that splitting into multiple selects does improve performance. But the best performance I achieved using DB Hints instead of splitting the select statements.
Generally performance of joins together with for all entries is bad.
However if you will look into SAP note 1662726 you will notice that this issue (bad performance in using join and for all entries together) has been addressed.
Even though the note is for HANA DB, FM RSDU_CREATE_HINT_FAE can be used independent of DB.
On HANA DB performance improvement is huge (i achieved 62 seconds using DB Hints compared to 1656 seconds using for all entries). On Oracle DB the same code initially run in 99 seconds with for all entries and with DB Hints in 82 seconds for ~ 1.000.000 records and ~660 seconds compared to 1349 seconds for ~8.000.000 records..
Sample code from SAP Note below:
Original statement:
SELECT COL1 COL2 COL3 COL4 COL5
FROM TAB1
INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
FOR ALL ENTRIES IN LT_SOURCE_TMP
WHERE COL3 = LT_SOURCE_TMP-COL3
AND COL4 = LT_SOURCE_TMP-COL4
AND COL5 = LT_SOURCE_TMP-COL5
Revision:
DATA: L_T_TABLNM TYPE RSDU_T_TABLNM,
L_LINES TYPE I,
L_HINT TYPE RSDU_HINT.
APPEND 'TAB1' TO L_T_TABLNM.
L_LINES = LINES( LT_SOURCE_TMP ).
CALL FUNCTION 'RSDU_CREATE_HINT_FAE'
EXPORTING
I_T_TABLNM = L_T_TABLNM
I_FAE_FIELDS = 3
I_FAE_LINES = L_LINES
I_EQUI_JOIN = RS_C_TRUE
IMPORTING
E_HINT = L_HINT
EXCEPTIONS
OTHERS = 0.
SELECT COL1 COL2 COL3 COL4 COL5
FROM TAB1
INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
FOR ALL ENTRIES IN LT_SOURCE_TMP
WHERE COL3 = LT_SOURCE_TMP-COL3
AND COL4 = LT_SOURCE_TMP-COL4
AND COL5 = LT_SOURCE_TMP-COL5
%_HINTS ADABAS L_HINT.
Best regards,
Octavian -
INNER JOIN with FOR ALL ENTRIES IN Performance ?
I am using following the following <b>Select using Inner join with For All Entries in.</b>
SELECT kebeln kebelp kvbeln kvbelp
FROM ekkn AS k INNER JOIN ekbe AS b ON kebeln = bebeln
AND kebelp = bebelp
INTO TABLE gi_purchase
FOR ALL ENTRIES
IN gi_sales
WHERE k~mandt EQ sy-mandt
AND k~vbeln EQ gi_sales-vbeln
AND k~vbelp EQ gi_sales-posnr
AND b~budat EQ p_date.
If i am not doing inner join then I will have to do 2 select with for all entries in on ekkn and ekbe tables and then compare them.
<b>I want to know which one has better performance
Inner join with for all entries in
or
2 Selects with for all entries in</b>the join is almost aways faster:
<a href="/people/rob.burbank/blog/2007/03/19/joins-vs-for-all-entries--which-performs-better">JOINS vs. FOR ALL ENTRIES - Which Performs Better?</a>
<a href="http://blogs.ittoolbox.com/sap/db2/archives/for-all-entries-vs-db2-join-8912">FOR ALL ENTRIES vs DB2 JOIN</a>
Rob -
Inner Join with For All Entries - Performance ?
I am using following the following <b>Select using Inner join with For All Entries in.</b>
SELECT kebeln kebelp kvbeln kvbelp
FROM ekkn AS k INNER JOIN ekbe AS b ON kebeln = bebeln
AND kebelp = bebelp
INTO TABLE gi_purchase
FOR ALL ENTRIES
IN gi_sales
WHERE k~mandt EQ sy-mandt
AND k~vbeln EQ gi_sales-vbeln
AND k~vbelp EQ gi_sales-posnr
AND b~budat EQ p_date.
If i am not doing inner join then I will have to do 2 select with for all entries in on ekkn and ekbe tables and then compare them.
<b>I want to know which one has better performance
Inner join with for all entries in
or
2 Selects with for all entries in</b><b></b>An Inner Join with for all entries should be done if you add this....
IF NOT gi_sales[] IS INITIAL.
SELECT k~ebeln k~ebelp k~vbeln k~vbelp
FROM ekkn AS k INNER JOIN ekbe AS b ON k~ebeln = b~ebeln
AND k~ebelp = b~ebelp
INTO TABLE gi_purchase
FOR ALL ENTRIES
IN gi_sales
WHERE k~mandt EQ sy-mandt
AND k~vbeln EQ gi_sales-vbeln
AND k~vbelp EQ gi_sales-posnr
AND b~budat EQ p_date.
ENDIF.
Also, while you use an index or the complete key for the SELECT, your not going to suffer from lack of performance -;)
Greetings,
Blag.
Maybe you are looking for
-
I have a wrt54G router, I have four ports one hard wired to desk top, the other is a wireless laptop.I want to connect another wireless laptop and I am having difficulty connecting without wired cable.I tried LEAL and it said wire was not connected t
-
My ipod 5 gen dont sync or appear in my itunes for a month now,
I have some music, photos and videos to sync but my ipod even appear in my itunes, he charges and all. Already deleted and get the itunes over and over again and nothing works please, help
-
IPod Classic won't start or connect
My iPod Classic 80gig is acting weird. The screen was black like it was dead, then I connected it to the computer and the Apple becomes somewhat visible. Then it goes dark and the Apple becomes visible again for about 2 seconds. I can hear a very fai
-
Message control vs with out message control
tell me the differenece between message control and without message control.
-
Frustrated by being limited to 4/4 time
I guess this question's been answered ad nauseam, but, indulge me; How do I get drum samples in time signatures other than 4/4? Suggestions?