The below Query runs very slow
SELECT
ACT1.PROJ,
ACT1.ACT,
ACT1.VER,
ACT1.DS,
ACT1.UC,
ACT1.ACT_RN,
PRED1.PRED,
PRED_DS.DS,
PRED_DS.UC01 ACT_TYPE ,
PRED1.RN,
SUCC.SUC
,SUCC.SUC_NAME
,SUCC.SUC_TYPE
,SUCC.SUCC_RN
FROM
(SELECT A.PROJ , A.VER , A.ACT , A.DS , A.UC01 UC , B.RN ACT_RN
FROM PM_PORTAL.AV_ACTIVITY A , PM_PORTAL.AV_RESREQ B
WHERE A.PROJ = B.PROJ(+)
AND A.ACT = B.ACT(+)
AND A.VER = B.VER(+)
AND A.VER = 50
AND A.PROJ LIKE 'BOM_%'
AND A.UC01 = '560'
) ACT1 ,
( SELECT A.PROJ , A.ACT , A.VER , A.PRED , B.RN
FROM PM_PORTAL.AV_RELN A , PM_PORTAL.AV_RESREQ B
WHERE A.PROJ LIKE 'BOM_%'
AND A.VER = 50
AND A.PROJ = B.PROJ(+)
AND A.PRED = B.ACT(+)
AND A.VER = B.VER(+)
) PRED1,
( SELECT DS , UC01 ,ACT ,VER , PROJ
FROM PM_PORTAL.AV_ACTIVITY
WHERE PROJ LIKE 'BOM_%'
AND VER = 50
) PRED_DS ,
(SELECT A.PROJ , A.VER , A.ACT SUC , A.PRED , B.DS SUC_NAME ,B.UC01 SUC_TYPE , C.RN SUCC_RN
FROM PM_PORTAL.AV_RELN A , PM_PORTAL.AV_ACTIVITY B , PM_PORTAL.AV_RESREQ C
WHERE A.PROJ = B.PROJ
AND A.ACT = B.ACT
AND A.VER = B.VER
AND B.PROJ = C.PROJ
AND B.ACT = C.ACT
AND B.VER = C.VER
) SUCC
WHERE ACT1.PROJ=PRED1.PROJ(+)
AND ACT1.ACT=PRED1.ACT(+)
AND ACT1.VER=PRED1.VER(+)
AND PRED1.PRED = PRED_DS.ACT
AND PRED1.PROJ = PRED_DS.PROJ
AND PRED1.VER = PRED_DS.VER
AND SUCC.PROJ = PRED1.PROJ
AND SUCC.VER = PRED1.VER
AND SUCC.PRED = PRED1.PRED
--Execution Plan
SELECT STATEMENT, GOAL = CHOOSE 293 1 337
NESTED LOOPS 293 1 337
NESTED LOOPS 290 1 305
NESTED LOOPS 287 1 242
NESTED LOOPS 282 1 206
FILTER
HASH JOIN OUTER
VIEW PM_PORTAL_READ 65 2 194
NESTED LOOPS OUTER 65 2 190
TABLE ACCESS BY INDEX ROWID TRN_ARTE AV_ACTIVITY_NPART 59 2 126
INDEX RANGE SCAN TRN_ARTE AV_ACTIVITY_1_NPART 55 2
INDEX RANGE SCAN TRN_ARTE AV_RESREQ_1_NPART 3 35 1120
VIEW PM_PORTAL_READ 210 101 4646
HASH JOIN OUTER 210 101 6868
INDEX RANGE SCAN TRN_ARTE AV_RELN_1_NPART 161 101 3636
INDEX RANGE SCAN TRN_ARTE AV_RESREQ_1_NPART 48 35 1120
TABLE ACCESS BY INDEX ROWID TRN_ARTE AV_ACTIVITY_NPART 3 56 3528
INDEX UNIQUE SCAN TRN_ARTE AV_ACTIVITY_1_NPART 2 56
INDEX RANGE SCAN TRN_ARTE AV_RELN_1_NPART 5 101 3636
TABLE ACCESS BY INDEX ROWID TRN_ARTE AV_ACTIVITY_NPART 3 56 3528
INDEX UNIQUE SCAN TRN_ARTE AV_ACTIVITY_1_NPART 2 56
INDEX RANGE SCAN TRN_ARTE AV_RESREQ_1_NPART 3 35 1120
Here's the verbatim response I gave yesterday to another user also posting his SQL and asking the same question.. why is it slow?
Who says it is not already running as fast as possible?
In order to solve a problem, you need to know the problem. Stating something like 'a query is slow and should be faster' is stating an opinion - it is not describing a problem that can be resolved.
My suggestion is to turn a complex problem, into a bunch of smaller and simpler problems. If you suspect that the query could be faster, pull it apart. Test each step/component of the query in isolation. E.g. start with a single table and progressively add joins to determine what the CBO does with each additional join, what you're asking Oracle to do ito processing, and not only checking that the CBO does not make obvious errors, but that what you're asking via SQL is the best approach to get to the answer.
Similar Messages
-
Hi, I just started a new movie and the program is running very slow. Is there a way to clean up my iMovie program so that it goes faster? Please help.
There is nothing you can do with iMovie program itself. Slow response in usually due to a shortage of system resources (CPU, RAM and disk space).
How much free disk space do you have on your boot drive and what is the capacity of the drive?
You can check memory utilization while running iMovie using Activity Monitor (in Applications/Utilities). What does the Memory tab show for Swap used?
Are you running many other processor-intensive applications a the same time?
If you have a lot of events and projects, it will help a bit to hide the ones you are not using by moving them from your iMovie Projects and iMovie Events folders into an enclosing folder so iMovie doesn't load them.
Geoff. -
MS-Access query running very slow
Hi,
We've MS-Access application which was pointing to UDB. Now we migrated it to point Oracle DB 9.2. After migration some of the query is running very slow.
These queries used to take less than 30 seconds in UDB now taking more than 5 Minutes in Oracle.
some more obeservation :
(1) Some of the queries using "HAVING" clause without any aggregate function. When I moved this condition to "WHERE" clause, performance improved a lot.
But problem is that I can't suggest this solution to "USERS". They are creating query using "query wizard" in MS-Access and they started creating noise on this.
(2) I tested same MDB in two different PCs and same query is returning records in 4 seconds in one system, is taking more than 10 minutes in other system.
Since I'm new to MS-Access, I don't know what other information I need to provide here.
Please help me out.I have seen the problem like this,too
can i have you -
Query runs very slow and sometime freezes
Hi Experts,
I have just installed SAP GUI 710 but when i open a query in analyzer it runs very slow and if the variables are set for more than 6 months it just sits there and finally times out. It takes at least 5 minutes to open the query if it opens at all. Can you please advise me on how to resolve this issue??
Thanks, point will be awarded.Worth running RSRT .
Ravi Thothadri -
Oracle query running very slow
Hi,
We've MS-Access application which was pointing to UDB. Now we migrated it to point Oracle DB 9.2. After migration some of the query is running very slow.
These queries used to take less than 30 seconds in UDB now taking more than 5 Minutes in Oracle.
some more obeservation :
(1) Some of the queries using "HAVING" clause without any aggregate function. When I moved this condition to "WHERE" clause, performance improved a lot.
But problem is that I can't suggest this solution to "USERS". They are creating query using "query wizard" in MS-Access and they started creating noise on this.
(2) I tested same MDB in two different PCs and same query is returning records in 4 seconds in one system, is taking more than 10 minutes in other system.
Since I'm new to MS-Access, I don't know what other information I need to provide here.
Please help me out.ms wrote:
Hi All
I am using Oracle 11g . My table contains 10-12 lac rows.Do not use the word lac: it is common in the Indian sub-continent but not known much outside of
there because it is not standard English.
>
1) what is the difference between a index on one column and an index of number of columns ( i.e composite index). The obvious answer of one contains only one column and the other contains more than one.
2) For what columns in a where clause should index be created ( single columns index or composite index ).Depends
3) Also can u suggest how to improve the perfomane of thsi query?Please read: SQL and PL/SQL FAQ
which tells you how to ask a performance related question -
GL Balances query runs very slow
Hi All,
I am working on Oracle Applications 11i (11.5.10.2) environment.
Database is 11g (Rel.2)
I need to pull the data for all the SOB's and using the below query is running for many hours.
Please help with a better alternate for below query:
SELECT gcc1.segment3 acct,
gcc1.segment3 subacct,
(SELECT SUM(DECODE(gcc.account_type,
'A',
NVL(b.begin_balance_dr, 0) -
NVL(b.begin_balance_cr, 0),
'E',
NVL(b.begin_balance_dr, 0) -
NVL(b.begin_balance_cr, 0),
'L',
NVL(b.begin_balance_cr, 0) -
NVL(b.begin_balance_dr, 0),
'O',
NVL(b.begin_balance_cr, 0) -
NVL(b.begin_balance_dr, 0),
'R',
NVL(b.begin_balance_cr, 0) -
NVL(b.begin_balance_dr, 0)) +
DECODE(gcc.account_type,
'A',
NVL(b.period_net_dr, 0) - NVL(b.period_net_cr, 0),
'E',
NVL(b.period_net_dr, 0) - NVL(b.period_net_cr, 0),
'L',
NVL(b.period_net_cr, 0) - NVL(b.period_net_dr, 0),
'O',
NVL(b.period_net_cr, 0) - NVL(b.period_net_dr, 0),
'R',
NVL(b.period_net_cr, 0) - NVL(b.period_net_dr, 0))) ytd_amt
FROM gl_balances b, gl_code_combinations gcc
WHERE b.code_combination_id = gcc.code_combination_id
AND b.actual_flag = 'A'
AND b.translated_flag is NULL
AND gcc.enabled_flag = 'Y'
AND gcc.end_date_active is NULL
AND gcc1.segment3 = gcc.segment3
AND gcc1.segment4 = gcc.segment4
AND gb1.set_of_books_id = b.set_of_books_id
AND gb1.currency_code = b.currency_code
AND b.period_name = &l_prev_period) begin_balance,
(SELECT SUM(DECODE(gcc.account_type,
'A',
NVL(b.begin_balance_dr, 0) -
NVL(b.begin_balance_cr, 0),
'E',
NVL(b.begin_balance_dr, 0) -
NVL(b.begin_balance_cr, 0),
'L',
NVL(b.begin_balance_cr, 0) -
NVL(b.begin_balance_dr, 0),
'O',
NVL(b.begin_balance_cr, 0) -
NVL(b.begin_balance_dr, 0),
'R',
NVL(b.begin_balance_cr, 0) -
NVL(b.begin_balance_dr, 0)) +
DECODE(gcc.account_type,
'A',
NVL(b.period_net_dr, 0) - NVL(b.period_net_cr, 0),
'E',
NVL(b.period_net_dr, 0) - NVL(b.period_net_cr, 0),
'L',
NVL(b.period_net_cr, 0) - NVL(b.period_net_dr, 0),
'O',
NVL(b.period_net_cr, 0) - NVL(b.period_net_dr, 0),
'R',
NVL(b.period_net_cr, 0) - NVL(b.period_net_dr, 0))) ytd_amt
FROM gl_balances b, gl_code_combinations gcc
WHERE b.code_combination_id = gcc.code_combination_id
and b.rowid = gb1.rowid
and gcc.rowid = gcc1.rowid) Ending_balance
FROM gl_balances gb1, gl_code_combinations gcc1
WHERE gb1.code_combination_id = gcc1.code_combination_id
AND gb1.actual_flag = 'A'
AND gb1.translated_flag is NULL
AND gcc1.enabled_flag = 'Y'
AND gcc1.end_date_active is NULL
AND gb1.period_name = &p_period
Thanks,
gvk.Worth running RSRT .
Ravi Thothadri -
Hi All,
The below query takes long time to execute. Please review this and provide me the better solution by which i can get the faster result .
I have created the index in the txnlog table on timestamp,serialno, and in alt_merchant am on alt_merchantno and in txnlog_overrun on merchantno.
SELECT t.timestamp,t.wicno,t.merchantno,u.overrun_amount,NVL(ad.state,'N/A')
FROM txnlog t,txnlog_overrun u,alt_merchant am,address ad
WHERE t.timestamp > SYSDATE -15
AND t.timestamp=u.timestamp(+)
AND t.serialno=u.serialno(+)
AND t.wicno=am.alt_merchantno(+)
AND t.merchantno=am.merchantno(+)
AND am.ADDRESSID=ad.addressid(+)
Txnlog having millions of records.
Regards,
NiteshHello
SELECT NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_ROW_LEN FROM >USER_TABLES WHERE TABLE_NAME ='TXNLOG';
Returns Null for all columns.This suggests to me that statistics are missing. Have you generated them as I suggested? Could you post the execution plan here:
tylerd@DEV2> set pages 50000
tylerd@DEV2> set lines 200
tylerd@DEV2> EXPLAIN PLAN FOR
2 select * from dual
3 /
Explained.
tylerd@DEV2> SELECT * FROM TABLE(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 272002086
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
8 rows selected.David -
Mac pro run very slow
First, back up all data immediately, as your boot drive might be failing.
There are a few other possible causes of generalized slow performance that you can rule out easily.
Reset the System Management Controller.
If you have many image or video files on the Desktop with preview icons, move them to another folder.
If applicable, uncheck all boxes in the iCloud preference pane.
Disconnect all non-essential wired peripherals and remove aftermarket expansion cards, if any.
Check your keychains in Keychain Access for excessively duplicated items.
Otherwise, take the steps below when you notice the slowdown.
Step 1
Launch the Activity Monitor application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Activity Monitor in the icon grid.
Select the CPU tab of the Activity Monitor window.
Select All Processes from the menu in the toolbar, if not already selected.
Click the heading of the % CPU column in the process table to sort the entries by CPU usage. You may have to click it twice to get the highest value at the top. What is it, and what is the process? Also post the values for % User, % System, and % Idle at the bottom of the window.
Select the System Memory tab. What values are shown in the bottom part of the window for Page outs and Swap used?
Next, select the Disk Activity tab. Post the approximate values shown for Reads in/sec and Writes out/sec (not Reads in and Writes out.)
Step 2
If you have more than one user account, you must be logged in as an administrator to carry out this step.
Launch the Console application in the same way you launched Activity Monitor. Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
View ▹ Show Log List
from the menu bar.
Select the 50 or so most recent entries in the log. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V). You're looking for entries at the end of the log, not at the beginning.
When posting a log extract, be selective. Don't post more than is requested.
Please do not indiscriminately dump thousands of lines from the log into this discussion.
Important: Some personal information, such as your name, may appear in the log. Anonymize before posting. That should be easy to do if your extract is not too long. -
Query running very slow for 2LIS_13_VDKON Extractor.
Dear Experts
Having no Standard InfoCube to accommodate the data from 2LIS_13_VDKON Extractor, I've created an InfoCube having the Standard DSO inbetween. The Data Flow is as below:
2LIS_13_VDKON -> ZSD_DS17 (which is a copy of BCT DSO 0SD_O06) -> ZSD_C17 ---> ZSD_M02 (MultiProvider)
We went live last week and there are only 1252377 records in the InfoCube at the moment in Production. The BEx Query designed on top of the MultiProvider runs by default for the last 3 Months (Variable created) initially and the User will be able to look up only the last 13 Months (another Variable created) of data at any given point in time.
The User doesn't want any Selection Parameters on this Report and that's how it is created.
The problem now is.. this 'Margin on Agreed Cost' Report taking about 3 Minutes and 5 Seconds to run.
I have RSRV on the InfoCube and everything seems to be ok, tried Aggregates (though I understand that this number of records wouldn't need one to be created) and have also tried Query Cache today but no good.
Is there anything that I might have overlooked when designing the InfoCube and the BEx Query? Attached are the screenshots of the InfoCube, MultiProvider and the BEx Query for your reference.
Any suggestions are very much appreciated.
Thanks in advance for your time.
ChanduHi Anshu
Thanks for your time.
The link you've sent was very useful indeed.
I followed instructions from your link and below are the statistics 4 days after this Cube went into Production:
As you could see, the InfoCube design is very fine.
We have noticed that the Report runs within a few seconds when it is run by 0BILL_DATE in Selection Parameters. Therefore, we are trying to buy the End User to have some Selection Parameters so that the performance of the Report will improve.
I have already created Aggregates for this Cube but in vain!
Can anyone please send me the Screenshots of the InfoCube Design which captures all the fields of 2LIS_13_VDKON Extractor?
Thanks,
Chandu -
VO Query runs very slow in jdev, quickly in Toad/SQL Plus
Hi,
I am trying to create a search application using JSF with ADF BC. I have a VO based on a SQL query, which joins two tables. The search criteria is referenced using bind parameters in the VO.
In Toad, SQL Plus, and SQL Developer, I can run my VO query and the results return quickly, within a couple of seconds. An Explain Plan indicates that all indexes are being correctly used. However, when I try to run my search form (exact same query) in jdev, it executes extremely slowly - almost 5 minutes before a result set is returned. My VO query is below.
select oea.order_yr,
oea.order_type,
oea.order_key,
oea.max_rev,
oeo.profit_center_id,
oeo.contract_total_price,
oeo.complexity
from oe_admin oea,
oe_order oeo
where oea.admin_id = oeo.admin_id
and oeo.profit_center_id = :ProfitCenter
and oea.order_yr = nvl(:OYear, oea.order_yr)
and oea.order_type = nvl(:OType, oea.order_type)
I've been messing with this for several days and I'm out of ideas. Does anyone have any suggestions?The question is not whether the query uses a viewLink but rather do you have any other views that are linked to this view - if you do have such views you might want to check the setting for whether children are retrieved as well.
Also run ADF BC in debug mode to see the exact query that is being sent to the server and check out the explain plan for that one. -
The iOS simulator runs very slow on my new Mac mini. Any ideas on how to speed it up?
I am trying to demonstrate a new iPhone app using the Mac mini and the iOS Simulator software. It runs, but it runs very slowly -- not acceptable for a presentation. Any ideas so I can make it run faster?
Thanks! Johnor the private developer forums you have access to as an iOS Developer Program member:
http://developer.apple.com/devforums/
Regards. -
Oracle Query runs very slow filling table
I have used Java Studio Creator 2 with Sun Java System Application Server Platform Edition 8.1_02 (build b06-fcs) in the past. I created a simple oracle query to populate a table and displaying about 560 rows in a table via a web browser. This runs excellent.
Now, I use Netbeans 6, along with Sun Java System Application Server 9.1 (build b58g-fcs), I populate a table using the same query as before and it takes quite a long time to fill the table. Actually, the browser keeps asking if I want to stop the script about 6 times. If I keep saying yes, it eventually completes.
I'm using an Oracle 9i database and have tried different drivers from Oracle with the same results.
Any idea why the difference in filling the table or how to correct this? Thanks!
Please note: I have this same question posted in the Java.net forums but it's not been answered so far, I hope this isn't crossposting and I get yelled at!for NetBeans questions I suggest posting your question in the [email protected] For more information:
http://www.netbeans.org/community/index.html -
Query running very slow with db file sequential read waits which all indexes would be recommended
My query is doing lot of db file sequential reads I want to create few indexes and extended stats please help me with your suggestions.
Can anybody suggest I am unable to paste my query here -don't know why it's not getting pasted--is it not permitted ?
thank you.The simplest way to find it out is using Oracle Enterprise Manager. Just locate the SQL ID for the SQL and run "SQL tuning advisor". This will exactly pinpoint where do you need to create indexes etc. Another option is manually running explain plan for the SQL and finding out which predicate is causing full scans with high i/o
Regards
Tushar -
My mac air is running slugiish and my internet connection takes forever to change windows...what can I do?
If the computer is brand new, it may be reviewing (indexing) all you files for search. This will take a few hours to complete. Otherwise you likely have a program that is running poorly and slowing your system down.
Open the Fibder
Click the Go menu at the top of the screen
Click on utilities menu item under go
Open the Activity Monitor
When Activity monitor opens, there will be a lot of data in the window, to make better sense of it click on the column labeled CPU. This will sort entries by how much of your computer's CPU they use. The lower the number the better.
Locate any programs using 80% or more of your CPU. They are the likely culprits of your speed issue.
If the speed issue is only related to surfing the internet, then you more than likely have an issue with WiFi instead. Try moving closer to your wireless router to see if it speeds up. -
THE PROGRAM IS RUNNING VERY SLOW?
HI:
THERE IS APROGRAM DEVELOPED BY USER ,CAN SOMEONE HELP TO ANALYIZE HOW TO TUNE IT ?
THANKS
THE FILES:
FORM frm_get_data.
DATA: BEGIN OF it_ablad OCCURS 0,
ablad LIKE rkpf-umlgo,
END OF it_ablad.
IF NOT s_kunnr[] IS INITIAL.
SELECT ablad
INTO TABLE it_ablad
FROM knva
WHERE knva~kunnr IN s_kunnr.
ENDIF.
IF it_ablad[] IS NOT INITIAL.
SELECT rsdat
usnam
rspos
rkpf~bwart
xwaok
kzear
xloek
sgtxt
rkpf~rsnum
werks
rkpf~umwrk
resb~matnr
rkpf~umlgo
bdmng
enmng
resb~wempf
ablad
extwg
INTO CORRESPONDING FIELDS OF TABLE et_resb
FROM rkpf INNER JOIN resb ON rkpfrsnum = resbrsnum
INNER JOIN mara ON resbmatnr = maramatnr
UP TO p_hinum ROWS
FOR ALL ENTRIES IN it_ablad
WHERE rkpf~bwart IN s_bwart
AND rsdat IN s_rsdat
AND rkpf~umwrk = '2020'
AND werks = '2020'
AND rkpf~umlgo = it_ablad-ablad
AND mara~extwg IN s_extwg
AND resb~matnr IN s_matnr
AND rkpf~rsnum IN s_rsnum
AND kzear = ''
AND xloek = ''
AND ( xwaok = ''
OR ( xwaok = 'X'
AND lgort = '') ).
ELSE.
SELECT rsdat
usnam
rspos
rkpf~bwart
xwaok
kzear
xloek
sgtxt
rkpf~rsnum
werks
rkpf~umwrk
resb~matnr
rkpf~umlgo
bdmng
enmng
resb~wempf
ablad
extwg
INTO CORRESPONDING FIELDS OF TABLE et_resb
FROM rkpf INNER JOIN resb ON rkpfrsnum = resbrsnum
INNER JOIN mara ON resbmatnr = maramatnr
UP TO p_hinum ROWS
WHERE rkpf~bwart IN s_bwart
AND rsdat IN s_rsdat
AND rkpf~umwrk = '2020'
AND werks = '2020'
AND rkpf~umlgo IN s_umlgo
AND mara~extwg IN s_extwg
AND resb~matnr IN s_matnr
AND rkpf~rsnum IN s_rsnum
AND kzear = ''
AND xloek = ''
AND ( xwaok = ''
OR ( xwaok = 'X'
AND lgort = '') ).
ENDIF.
IF p_sd = 'X'.
DELETE et_resb WHERE wempf <> 'SD'.
ELSEIF p_plfw = 'X'.
DELETE et_resb WHERE wempf+0(2) <> '13'.
ELSEIF p_fw = 'X'.
DELETE et_resb WHERE wempf+0(2) = '13' OR wempf = 'SD'.
ENDIF.
LOOP AT et_resb.
DATA : tmp_labst TYPE mard-labst.
DATA : tmp_wdmeng TYPE mard-labst.
DATA : tmp_calab TYPE mard-labst.
CLEAR wa_output.
wa_output-rsdat = et_resb-rsdat.
wa_output-usnam = et_resb-usnam.
wa_output-bwart = et_resb-bwart.
wa_output-rsnum = et_resb-rsnum.
wa_output-rspos = et_resb-rspos.
wa_output-umwrk = et_resb-umwrk.
wa_output-umlgo = et_resb-umlgo.
wa_output-matnr = et_resb-matnr.
wa_output-matnr1 = et_resb-matnr.
wa_output-extwg = et_resb-extwg.
wa_output-xwaok = et_resb-xwaok.
wa_output-kzear = et_resb-kzear.
wa_output-xloek = et_resb-xloek.
wa_output-wempf = et_resb-wempf.
wa_output-ablad = et_resb-ablad.
wa_output-sgtxt = et_resb-sgtxt.
wa_output-wbdmng = et_resb-bdmng - et_resb-enmng.
IF pp_lgort <> ''.
SELECT SINGLE labst
FROM mard
INTO tmp_labst
WHERE werks = '2020'
AND lgort = pp_lgort.
PERFORM resb_lesen USING '2020'
pp_lgort
et_resb-matnr
CHANGING tmp_wdmeng.
wa_output-calab = tmp_labst - tmp_wdmeng.
wa_output-werks = '2020'.
wa_output-lgort = pp_lgort.
ELSE.
SELECT *
FROM zmt_fckw_new
INTO CORRESPONDING FIELDS OF TABLE et_fckw
WHERE umwrk = et_resb-umwrk
AND umlgo = et_resb-umlgo.
LOOP AT et_fckw.
CLEAR tmp_labst.
SELECT SINGLE labst
FROM mard
INTO tmp_labst
WHERE werks = et_fckw-werks
AND lgort = et_fckw-lgort
AND matnr = et_resb-matnr.
PERFORM resb_lesen USING et_fckw-werks
et_fckw-lgort
et_resb-matnr
CHANGING tmp_wdmeng.
tmp_calab = tmp_labst - tmp_wdmeng.
IF tmp_calab >= wa_output-wbdmng.
wa_output-werks = et_fckw-werks.
wa_output-lgort = et_fckw-lgort.
wa_output-lg_typ = et_fckw-lg_typ.
wa_output-calab = tmp_calab.
wa_output-xwaok = 'X'.
EXIT.
ELSE.
SELECT *
FROM zmt_thwl
INTO CORRESPONDING FIELDS OF TABLE et_thwl
WHERE matnr = et_resb-matnr
AND zgroup <> 'X'.
SORT et_thwl BY matnr
priority DESCENDING
sub_matnr.
LOOP AT et_thwl.
CLEAR tmp_labst.
SELECT SINGLE labst
FROM mard
INTO tmp_labst
WHERE werks = et_fckw-werks
AND lgort = et_fckw-lgort
AND matnr = et_thwl-sub_matnr.
PERFORM resb_lesen USING et_fckw-werks
et_fckw-lgort
et_thwl-sub_matnr
CHANGING tmp_wdmeng.
tmp_calab = tmp_labst - tmp_wdmeng.
IF tmp_calab >= wa_output-wbdmng.
wa_output-matnr1 = et_thwl-sub_matnr.
wa_output-werks = et_fckw-werks.
wa_output-lgort = et_fckw-lgort.
wa_output-lg_typ = et_fckw-lg_typ.
wa_output-calab = tmp_calab.
wa_output-xwaok = 'X'.
wa_output-subst = 'X'.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF wa_output-lgort <> ''.
EXIT.
ENDIF.
ENDLOOP.
IF wa_output-lgort = ''.
READ TABLE et_fckw WITH KEY umwrk = et_resb-umwrk
umlgo = et_resb-umlgo
zdefault = 'X'.
wa_output-werks = et_fckw-werks.
wa_output-lgort = et_fckw-lgort.
wa_output-lg_typ = et_fckw-lg_typ.
wa_output-xwaok = ''.
CLEAR tmp_labst.
PERFORM resb_lesen USING et_fckw-werks
et_fckw-lgort
et_resb-matnr
CHANGING tmp_wdmeng.
tmp_calab = tmp_labst - tmp_wdmeng.
ENDIF.
CLEAR ET_FCKW[].
CLEAR tmp_labst.
ENDIF.
SELECT SINGLE lgobe
INTO wa_output-lgobe
FROM t001l
WHERE werks = et_resb-umwrk
AND lgort = et_resb-umlgo.
SELECT SINGLE lgobe
INTO wa_output-lgobe1
FROM t001l
WHERE werks = wa_output-werks
AND lgort = wa_output-lgort.
SELECT SINGLE maktx
INTO wa_output-maktx
FROM makt
WHERE matnr = wa_output-matnr.
APPEND wa_output.
ENDLOOP.
ENDFORM. "frm_get_dataI agree with what one of the other people has said. Joins are not nesasarily bad, but badly designed joins are. So from the perspective of the Join vs. the For All Entries I don't belive that just moving to a For All Entries will solve your problem. A well desinged Join can actaully perform very well and often would actaully be my choosen way of accessing data. So it's not black and white on this subject, it depends on the relationships between the tables and the distribution of data accross those tables.
Taking a look at the large join statements that you have I'm not going to attempt to do a tuning on it since I'm not really familiar with your specific data distribution in your system, so I'm going to concentrate on some other areas instead. I do suggest that you do an SE30 trace on it so that you can do some profiling of understanding which components of your program are taking up the highest net runtime.
I belive that there is a significant amount of processing time that is taken up inside your looping due to the selects and reads inside the loops. Selects inside loops have certain overhead to them as opposed to doing an arracy select (For All Entries) and also it appears that there are many spots where you are most likely going back to the data base for the same data multiple times. Rudundant DB calls for the same records is one of the leading causes of waste in ABAP programs. My rule of thumb is that during a batch program written in ABAP there should never be a record in a table that is retrieved more then once accross all of your various selects. Pigion hole principal can be applied here, if there are 100 records in a table and you end up executing 1,000 selects against that table then there have been 900 rudundant calls and account for waste in the processing time of the program. Something I often remind my developers of is that if it is inside a loop don't forget that it is happening multiple times! I know that it seems like an obvious statement, but often developers overlook the cost of what they are doing.
Here are some of the pieces of code that should be examined:
1) Switch to a single loop with three checks inside it. Each time you do a delete statement it is actually doing a full sequential pass through the internal table. So in this case you are making 2 redundant full sequential reads of the table.
IF p_sd = 'X'.
DELETE et_resb WHERE wempf 'SD'.
ELSEIF p_plfw = 'X'.
DELETE et_resb WHERE wempf+0(2) '13'.
ELSEIF p_fw = 'X'.
DELETE et_resb WHERE wempf+0(2) = '13' OR wempf = 'SD'.
ENDIF.
2) Remove from loop at et_resb, it doesn't make sense to do this select inside a loop when it could be done as a For All Entries outside of the loop, you're going to most likely be getting the same records selected multiple times which is a waste. Additionally, even if the same records aren't being rudundently called, an array select is still faster for something like this then individual selects due to DB overhead per call. Also note that there seems to be something wrong with this select since you are note including the MATNR field in the where clause, it is going to each time just get the first material it happens to find for the storage location at that plant.
SELECT SINGLE labst
FROM mard
INTO tmp_labst
WHERE werks = '2020'
AND lgort = pp_lgort.
3) What is happening inside the PERFORM resb_lesen? This is inside a loop so it should be examined further to understand the cost of the processing that it is doing.
4) Refer to point#2, this is a select inside a loop and could become expensive depending on the nature of the tables and their data.
SELECT *
FROM zmt_fckw_new
INTO CORRESPONDING FIELDS OF TABLE et_fckw
WHERE umwrk = et_resb-umwrk
AND umlgo = et_resb-umlgo.
5) Refer to point#2, this is another select inside a loop and most likely will be making rudundant calls where it goes back to the DB for the same records multiple times. In addition to this it is actually inside multiple loops nested.
SELECT SINGLE labst
FROM mard
INTO tmp_labst
WHERE werks = et_fckw-werks
AND lgort = et_fckw-lgort
AND matnr = et_resb-matnr.
6) Refer to point#2. Note also that this will be causing redundant DB calls if you're looking at the same materials on multiple passes of the loop.
SELECT *
FROM zmt_thwl
INTO CORRESPONDING FIELDS OF TABLE et_thwl
WHERE matnr = et_resb-matnr
AND zgroup 'X'.
7) Refer to point #6.
SELECT SINGLE labst
FROM mard
INTO tmp_labst
WHERE werks = et_fckw-werks
AND lgort = et_fckw-lgort
AND matnr = et_thwl-sub_matnr.
8) Read statement should be optimized via a non-sequential access pattern such as a binary search or the use of a hash table
READ TABLE et_fckw WITH KEY umwrk = et_resb-umwrk
umlgo = et_resb-umlgo
zdefault = 'X'.
9) Refer to point #6
SELECT SINGLE lgobe
INTO wa_output-lgobe
FROM t001l
WHERE werks = et_resb-umwrk
AND lgort = et_resb-umlgo.
SELECT SINGLE lgobe
INTO wa_output-lgobe1
FROM t001l
WHERE werks = wa_output-werks
AND lgort = wa_output-lgort.
SELECT SINGLE maktx
INTO wa_output-maktx
FROM makt
WHERE matnr = wa_output-matnr.
~Ian
Maybe you are looking for
-
Error in creation of collective invoice.
I have an requirement to create single invoice for delivered material and return material (two line item) as a common practice in BEV Industries. I am trying to maintain: As per standard config the criteria for collective billing are, If your sales
-
How do I delete an old Apple ID one my IPAD
How do you delete an old Apple ID Password on my IPAD #1 and replace it with a new apple ID?
-
[OIM 9.1.0.2] Trusted Recon Workaround
Hi all, IHAC that uses a GTC (Flat file) for trusted recon. The generated file for reconciliation brings entries of actives and inactives users (So, the expected result is User Creation, User Update and User Disabling). AFAIK, the User Definition Fie
-
TS3991 Downloading an app on a second apple device using the same apple id
I have two apple devices. When I log into my second device with my same Apple ID, apps that have been previously downloaded appear with a cloud icon. When I click on this icon, it does not download my app on my second device. Why is this occurring
-
HELP! - How can I transfer Contacts & Messages fro...
I about to buy Lumia 800, having used N900 for the past 2 years. My question is how can I transfer my 700+ Contacts (essential!) and all my Messages (optional) from my loyal N900 to Lumia 800? The bad news is that a couple of days before I proceed to