Help on performance
Hi
ALL
I am new to this forum
I am jez learning ABAP . I anm sure that this site will help me grow in SAP via the help of all the gurus
I thank U all in advance
I have written a code and there is a Performance issue . The particular form 'cal_no_of_orders' is taking lotof time say more than 5 mins to execute can anyone suggest me the better way of writing this where I need to pass the valid to and valid from dates to calculate the noof orders and dollars . please tell me the flaw inthe code
report orders .
DICTIONARY TABLES
tables: vbak, "Sales Document: Header Data
vbpa, "Sales Document: Partner
vbuk, "Sales Document: Header Status and Administrative Data
adrc.
ALV Declarations *
type-pools: slis, kkblo.
data: g_repid like sy-repid,
gs_layout type slis_layout_alv,
gt_fieldcat type slis_t_fieldcat_alv,
fieldcat_in like line of gt_fieldcat,
cos_pos type i,
months like komp-anz_monate.
data: g_anzlines type i.
data : t_list_top_of_page type slis_t_listheader.
data : t_list_end_of_list type slis_t_listheader.
data : t_events type slis_t_event.
DATA
data: gv_netwr like vbak-netwr,
gv_netwr0 like vbak-netwr,
zvbeln like vbak-vbeln,
gv_count(6) type n,
gv_count0(6) type n,
erdat1 like vbak-erdat,
erdat2 like vbak-erdat,
vkorg like vbak-vkorg,
erdat(25),
hyphen(3) value '---',
p_name1 like adrc-name1,
zlines type i.
INTERNAL TABLES
data: begin of zvbak occurs 0,
vbeln like vbak-vbeln, "order no
vgbel like vbak-vgbel, "reference doc num
netwr like vbak-netwr, " amount
end of zvbak.
data: zvbak0 like zvbak occurs 0 with header line.
data: begin of zvbpa occurs 0,
vbeln like vbpa-vbeln,
parvw like vbpa-parvw, " partner function
kunnr like vbpa-kunnr,
adrnr like vbpa-adrnr,
netwr like vbak-netwr,
name1 like adrc-name1,
end of zvbpa.
data: zvbpa0 like zvbpa occurs 0 with header line.
data: alv_tab like zvbpa occurs 0 with header line,
alv_dat like zvbpa occurs 0 with header line.
data: begin of zvbuk occurs 0,
vbeln like vbak-vbeln,
netwr like vbak-netwr,
end of zvbuk.
data: begin of ztab_period occurs 0.
include structure scscp_period_str.
data: name(10) type c,
end of ztab_period.
data ztab_period0 like ztab_period occurs 0 with header line.
SELECTION SCREEN
selection-screen begin of block b with frame title text-001 .
select-options: s_erdat for vbak-erdat obligatory,
s_vkorg for vbak-vkorg obligatory.
selection-screen end of block b.
*INITIALIZATION.
initialization.
g_repid = sy-repid.
*START-OF-SELECTION.
start-of-selection.
perform select_orders.
**END-OF-SELECTION.
end-of-selection.
describe table alv_tab lines g_anzlines.
if g_anzlines gt 0.
perform display_list.
endif.
*& Form select_orders
text
--> p1 text
<-- p2 text
form select_orders.
data: gv_index like sy-tabix,
ztab like ztab_period,
erdath like vbak-erdat,
erdat_h like vbak-erdat.
erdat1 = s_erdat-low(8).
erdath = s_erdat-high(8).
concatenate erdat1 hyphen erdat_h erdath into erdat.
vkorg = s_vkorg+3(4).
*calculate the no of orders and dollars month wise from the selection
*date
call function 'CSCP_PARA1_GET_PERIODS'
exporting
i_datuv = s_erdat-low
i_datub = s_erdat-high
i_timeunit = 'D'
tables
et_dates = ztab_period.
append ztab_period.
clear ztab_period.
clear gv_index.
*calculate the names of the months
sort ztab_period by datuv.
describe table ztab_period lines zlines.
loop at ztab_period.
gv_index = sy-tabix.
*always delete first record inthe internal table
if ztab_period-sindex = 1.
delete ztab_period.
clear ztab_period.
endif.
endloop.
*Assign Month name and calculate no of orders
clear gv_index.
loop at ztab_period.
gv_index = sy-tabix.
if ztab_period-datuv+4(2) = '01'.
move 'JANUARY' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '01'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '02'.
move 'FEBRUARY' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '02'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '03'.
move 'MARCH' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '03'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '04'.
move 'APRIL' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '04'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '05'.
move 'MAY' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '05'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '06'.
move 'JUNE' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '06'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '07'.
move 'JULY' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '07'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '08'.
move 'AUGUST' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '08'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '09'.
move 'SEPTEMBER' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '09'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '10'.
move 'OCTOBER' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '10'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '11'.
move 'NOVEMBER' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '11'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
elseif ztab_period-datuv+4(2) = '12'.
move 'DECEMBER' to ztab_period-name.
loop at ztab_period into ztab.
if ztab_period-datuv+4(2) = '12'.
move ztab_period-datuv to ztab-datuv.
move ztab_period-datub to ztab-datub.
endif.
erdat1 = ztab-datuv.
erdat2 = ztab-datub.
perform cal_no_of_orders tables alv_dat
using erdat1 erdat2
changing gv_count0 gv_netwr0.
modify ztab_period index gv_index.
clear : erdat1 , ztab-datuv, erdat2, ztab-datub.
endloop.
clear: erdat1, erdat2, ztab_period-datuv, ztab_period-datub, ztab.
endif.
clear ztab_period-datuv+4(2).
endloop.
endform. " select_orders
*& Form DISPLAY_LIST
text
--> p1 text
<-- p2 text
form display_list.
g_repid = sy-repid.
perform fillevents.
perform comment_build using t_list_top_of_page.
perform create_layout.
perform create_fieldcat.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = g_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS = gs_settings
is_layout = gs_layout
it_fieldcat = gt_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = 'X'
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
IS_VARIANT =
it_events = t_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = alv_tab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_LIST
*& Form comment_build
text
-->P_t_list_top_of_page text
form comment_build using t_list_top_of_page type slis_t_listheader.
data : ls_line type slis_listheader.
data : ldate(10),hdate(10).
refresh : t_list_top_of_page.
clear ls_line.
ls_line-info = sy-repid.
ls_line-typ = 'H'.
ls_line-info = 'ORDERS AND DOLLARS REPORT'.
append ls_line to t_list_top_of_page.
write sy-datum to ldate using edit mask '__.__.____' .
clear ls_line.
ls_line-typ = 'A'.
concatenate 'Run Date :' ldate
into ls_line-info separated by space.
append ls_line to t_list_top_of_page.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'User ID :'.
ls_line-info+12 = sy-uname.
append ls_line to t_list_top_of_page.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'No OF ORDERS :'.
ls_line-info+17 = gv_count.
append ls_line to t_list_top_of_page.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'TOTAL dOLLAR AMOUNT :'.
ls_line-info+25 = gv_netwr.
append ls_line to t_list_top_of_page.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'Date Range for Documents :'.
ls_line-info+25 = erdat.
append ls_line to t_list_top_of_page.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'Sales Organization :'.
ls_line-info+25 = vkorg.
append ls_line to t_list_top_of_page.
endform. " comment_build
*& Form fillevents
text
--> p1 text
<-- p2 text
form fillevents.
data l_events type line of slis_t_event.
clear l_events.
l_events-name = 'TOP_OF_PAGE'.
l_events-form = 'TOP_OF_PAGE'.
append l_events to t_events.
*perform top-of-page1.
endform. " fillevents
*& Form create_fieldcat
text
--> p1 text
<-- p2 text
form create_fieldcat.
perform fill_fieldcat using 'KUNNR' 'ALV_TAB' 'SOLD-TO-PARTY' '1' ''.
perform fill_fieldcat using 'NAME1' 'ALV_TAB' 'NAME' '2' ''.
perform fill_fieldcat using 'NETWR' 'ALV_TAB' 'NETVALUE' '3' ''.
endform. " create_fieldcat
*& Form create_layout
text
--> p1 text
<-- p2 text
form create_layout.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
gs_layout-no_totalline = 'X'.
endform. " create_layout
*& Form fill_fieldcat
text
-->P_0564 text
-->P_0565 text
-->P_0566 text
-->P_0567 text
-->P_0568 text
form fill_fieldcat using p_fname
p_tabname
p_seltext
p_colpos
p_do_sum.
clear fieldcat_in.
fieldcat_in-fieldname = p_fname.
fieldcat_in-tabname = p_tabname.
fieldcat_in-seltext_m = p_seltext.
fieldcat_in-col_pos = p_colpos.
fieldcat_in-do_sum = p_do_sum.
append fieldcat_in to gt_fieldcat.
endform. " fill_fieldcat
*& Form TOP_OF_PAGE
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = t_list_top_of_page.
endform.
*& Form cal_no_of_orders
text
-->P_ALV_DAT text
-->P_ERDAT1 text
-->P_ERDAT2 text
<--P_KUNNR text
<--P_GV_COUNT text
<--P_GV_NETWR text
<--P_GV_NAME1 text
form cal_no_of_orders tables atv_tab
using p_erdat1
p_erdat2
changing p_gv_count
p_gv_netwr.
data: g_tabix like sy-tabix,
gv_index like sy-tabix.
*Select Orders Processed
select vbeln netwr vgbel from vbak
into corresponding fields of table zvbak where
erdat between p_erdat1 and p_erdat2 and
vkorg in s_vkorg and
vgbel ne space and
auart = 'TA' and
( ( bsark = 'DFUA' ) or
( bsark = 'DFUE' ) or
( bsark = 'DFUI' ) ).
if sy-subrc = 0.
clear sy-subrc .
select vbeln parvw kunnr adrnr from vbpa
into corresponding fields of table zvbpa
for all entries in zvbak
where vbeln = zvbak-vgbel
and parvw = 'AG'.
if sy-subrc = 0.
loop at zvbpa.
g_tabix = sy-tabix.
read table zvbak with key vgbel = zvbpa-vbeln.
if sy-subrc eq 0.
move :zvbak-netwr to zvbpa-netwr.
modify zvbpa index g_tabix.
endif.
select single name1 into (p_name1 )
from adrc
where addrnumber = zvbpa-adrnr.
if sy-subrc = 0.
move p_name1 to zvbpa-name1.
modify zvbpa index g_tabix.
endif.
endloop.
endif.
endif.
move Processed Orders to ALV display table
loop at zvbpa.
move-corresponding zvbpa to alv_tab.
append alv_tab.
clear alv_tab.
endloop.
Select Open Quotaions
select vbeln netwr vgbel from vbak
into corresponding fields of table zvbak0 where
erdat between p_erdat1 and p_erdat2 and
vkorg in s_vkorg and
vbtyp = 'B' and
vgbel = space and
auart = 'ZEDI'.
loop at zvbak0.
select single vbeln from vbuk
into (zvbeln )
where vbeln = zvbak0-vbeln
and vbtyp = 'B'
and gbstk = 'A'.
if sy-subrc = 0.
read table zvbak0 with key vbeln = zvbeln.
if sy-subrc = 0.
move: zvbak0-vbeln to zvbuk-vbeln,
zvbak0-netwr to zvbuk-netwr.
append zvbuk.
clear zvbuk.
endif.
endif.
endloop.
move Open Quotations to ALV display table
sort zvbuk.
loop at zvbuk.
move-corresponding zvbuk to alv_tab.
append alv_tab.
clear alv_tab.
endloop.
*get the total no of orders and dollar amount
sort alv_tab by kunnr.
loop at alv_tab.
gv_netwr = alv_tab-netwr + gv_netwr.
gv_count = gv_count + 1.
endloop.
endform. " cal_no_of_orders
thanks for taking time to read and go thru my code
ur suggestions would help me to grow and may be one day become a part of this forum .
thanks
And look at the lines I've marked:
FORM cal_no_of_orders TABLES atv_tab
USING p_erdat1
p_erdat2
CHANGING p_gv_count
p_gv_netwr.
DATA: g_tabix LIKE sy-tabix,
gv_index LIKE sy-tabix.
*Select Orders Processed
SELECT vbeln netwr vgbel FROM vbak
INTO CORRESPONDING FIELDS OF TABLE zvbak WHERE
erdat BETWEEN p_erdat1 AND p_erdat2 AND
vkorg IN s_vkorg AND
vgbel NE space AND
auart = 'TA' AND
( ( bsark = 'DFUA' ) OR
( bsark = 'DFUE' ) OR
( bsark = 'DFUI' ) ).
IF sy-subrc = 0.
CLEAR sy-subrc .
SORT zvbak BY vgbel. "<==========================
SELECT vbeln parvw kunnr adrnr FROM vbpa
INTO CORRESPONDING FIELDS OF TABLE zvbpa
FOR ALL ENTRIES IN zvbak
WHERE vbeln = zvbak-vgbel
AND parvw = 'AG'.
IF sy-subrc = 0.
LOOP AT zvbpa.
g_tabix = sy-tabix.
READ TABLE zvbak WITH KEY vgbel = zvbpa-vbeln
BINARY SEARCH. "<==========================
IF sy-subrc EQ 0.
MOVE :zvbak-netwr TO zvbpa-netwr.
MODIFY zvbpa INDEX g_tabix.
ENDIF.
SELECT SINGLE name1 INTO (p_name1 )
FROM adrc
WHERE addrnumber = zvbpa-adrnr.
IF sy-subrc = 0.
MOVE p_name1 TO zvbpa-name1.
MODIFY zvbpa INDEX g_tabix.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
* move Processed Orders to ALV display table
LOOP AT zvbpa.
MOVE-CORRESPONDING zvbpa TO alv_tab.
APPEND alv_tab.
CLEAR alv_tab.
ENDLOOP.
* Select Open Quotaions
SELECT vbeln netwr vgbel FROM vbak
INTO CORRESPONDING FIELDS OF TABLE zvbak0 WHERE
erdat BETWEEN p_erdat1 AND p_erdat2 AND
vkorg IN s_vkorg AND
vbtyp = 'B' AND
vgbel = space AND
auart = 'ZEDI'.
LOOP AT zvbak0.
SELECT SINGLE vbeln FROM vbuk
INTO (zvbeln )
WHERE vbeln = zvbak0-vbeln
AND vbtyp = 'B'
AND gbstk = 'A'.
IF sy-subrc = 0.
READ TABLE zvbak0 WITH KEY vbeln = zvbeln.
IF sy-subrc = 0.
MOVE: zvbak0-vbeln TO zvbuk-vbeln,
zvbak0-netwr TO zvbuk-netwr.
APPEND zvbuk.
CLEAR zvbuk.
ENDIF.
ENDIF.
ENDLOOP.
* move Open Quotations to ALV display table
SORT zvbuk.
LOOP AT zvbuk.
MOVE-CORRESPONDING zvbuk TO alv_tab.
APPEND alv_tab.
CLEAR alv_tab.
ENDLOOP.
*get the total no of orders and dollar amount
SORT alv_tab BY kunnr.
LOOP AT alv_tab.
gv_netwr = alv_tab-netwr + gv_netwr.
gv_count = gv_count + 1.
ENDLOOP.
ENDFORM. " cal_no_of_orders
Rob
Similar Messages
-
Need help in Performance tuning for function...
Hi all,
I am using the below algorithm for calculating the Luhn Alogorithm to calculate the 15th luhn digit for an IMEI (Phone Sim Card).
But the below function is taking about 6 min for 5 million records. I had 170 million records in a table want to calculate the luhn digit for all of them which might take up to 4-5 hours.Please help me performance tuning (better way or better logic for luhn calculation) to the below function.
A wikipedia link is provided for the luhn algorithm below
Create or Replace FUNCTION AddLuhnToIMEI (LuhnPrimitive VARCHAR2)
RETURN VARCHAR2
AS
Index_no NUMBER (2) := LENGTH (LuhnPrimitive);
Multiplier NUMBER (1) := 2;
Total_Sum NUMBER (4) := 0;
Plus NUMBER (2);
ReturnLuhn VARCHAR2 (25);
BEGIN
WHILE Index_no >= 1
LOOP
Plus := Multiplier * (TO_NUMBER (SUBSTR (LuhnPrimitive, Index_no, 1)));
Multiplier := (3 - Multiplier);
Total_Sum := Total_Sum + TO_NUMBER (TRUNC ( (Plus / 10))) + MOD (Plus, 10);
Index_no := Index_no - 1;
END LOOP;
ReturnLuhn := LuhnPrimitive || CASE
WHEN MOD (Total_Sum, 10) = 0 THEN '0'
ELSE TO_CHAR (10 - MOD (Total_Sum, 10))
END;
RETURN ReturnLuhn;
EXCEPTION
WHEN OTHERS
THEN
RETURN (LuhnPrimitive);
END AddLuhnToIMEI;
http://en.wikipedia.org/wiki/Luhn_algorithmAny sort of help is much appreciated....
Thanks
RedeThere is a not needed to_number function in it. TRUNC will already return a number.
Also the MOD function can be avoided at some steps. Since multiplying by 2 will never be higher then 18 you can speed up the calculation with this.
create or replace
FUNCTION AddLuhnToIMEI_fast (LuhnPrimitive VARCHAR2)
RETURN VARCHAR2
AS
Index_no pls_Integer;
Multiplier pls_Integer := 2;
Total_Sum pls_Integer := 0;
Plus pls_Integer;
rest pls_integer;
ReturnLuhn VARCHAR2 (25);
BEGIN
for Index_no in reverse 1..LENGTH (LuhnPrimitive) LOOP
Plus := Multiplier * TO_NUMBER (SUBSTR (LuhnPrimitive, Index_no, 1));
Multiplier := 3 - Multiplier;
if Plus < 10 then
Total_Sum := Total_Sum + Plus ;
else
Total_Sum := Total_Sum + Plus - 9;
end if;
END LOOP;
rest := MOD (Total_Sum, 10);
ReturnLuhn := LuhnPrimitive || CASE WHEN rest = 0 THEN '0' ELSE TO_CHAR (10 - rest) END;
RETURN ReturnLuhn;
END AddLuhnToIMEI_fast;
/My tests gave an improvement for about 40%.
The next step to try could be to use native complilation on this function. This can give an additional big boost.
Edited by: Sven W. on Mar 9, 2011 8:11 PM -
How does logical volume helps in performance in AIX..Should have posted IBM
We are setting up a new DB server and the disks are in RAID5 config,Does putting data and index in different logical volumes helps in performance
(I hope I'm not falling for April Fools joke here...)
Hi Maran,
As someone already answered, if both volumes are striped against all available disks, you can put everything in one volume and expect equal or better performance.
However, I want to warn you from optimizing the disk structure without knowing that your database will really bottleneck on disk access to index and data blocks. My storage manager and I wasted countless hours with such optimizations before realizing that we are wasting our time because the application code contains so many functions that disk IO is not even close to being an issue.
-- Chen -
Help on performance with dynamic query
Hi All,
We are using SQL Server 2008R2. In our one of report we are using Dynamic query and it is taking more time to retrieve the data. to retrieve 32 records it is taking 13-15 secs. In my observation in a table variable, created more than 60 columns. In
the SP called one more sp with insert statement.
Please let me know how i can improve performance of the SP.
I know that i have to provide the SP for observation but unfortunately I cannot provide the SP. Please guide me how i can achieve this .
I tried with temp tables by creating indexes on temp tables but i couldn't find improvement in performance.
Waiting for valuable replies.First of all a "dynamic query" is not "a query" - it is a multitude of them. Some of them may be fast, others may be slow.
There is of course no way we can give specific suggestions without seeing the code, the table and index definitions etc.
We can only give the generic suggestions. As for the code, make sure that you are using parameterised SQL and you are not building a complete SQL string with parameters and all. If nothing else, this helps to make the code more readable and maintainable.
It also protects you against SQL injection. And it also helps to prevent performance issue due to implicit conversion.
You will need to look at the query plan to see where the bottlenecks may be. You should look at the actual query plan. Note that the thickness of the arrows are more relevant than the percentages you see; the percentages are only estimates, and estimates
are often off. Next step is to see if you can add indexes to alleviate the situation. You should also analyse if there are problems in the query, for instance indexed columns that are entangled in expression. If you are using views, make sure that you don't
have views built on top of views etc. This can often result a table appearing multiple times in a query, when one would be enough.
Erland Sommarskog, SQL Server MVP, [email protected] -
Need your help on performance issue please
Hello everyone!
I need your help to understand an effect I notice with a Thread class I built. I currently work on enhancement of my application Playlist Editor (see http://www.lightdev.com/page74.htm) and a new release will be available soon.
Among other extensions the new release will have a title filter function which is based on audio data that is recursively read from ID3 tags of files found in a given root directory. The data collection is done by a CollectionThread class which reads into a data model class AudioDataModel and the entire process works fine, no problem with that.
However, when my application is started for the first time the CollectionThread runs approximately 3 minutes to collect data from approximately 4300 audio files on an Intel Pentium M 1,4 GHz, 512 MB RAM, Windows XP SP2. When the application is shut down and started again, it takes only a few seconds to do the same task for all subsequent launches.
I already tried to start the application with java option -Xms40m to increase initial heap size. This increases performance in general but the effect is still the same, i.e. first run lasts significantly longer than subsequent runs.
I also tried to build a pool mechanism which creates many empty objects in the data model and then releases them to contain the actual data at is being read in but this did not lead to better performance.
It must have to do with how Java (or Windows?) allocates and caches memory. I wonder whether there is a way to pre-allocate memory or if there are any other ideas to improve performance so that the process always only takes seconds instead of minutes?
I attach the key classes to this message. Any help or ideas is much appreciated!
Thanks a lot a best regards
Ulrich
PS: You can use the news subscription service at
http://www.lightdev.com/dynTemplate.php4?id=80&dynPage=subscribe.php4 to be informed when the new release of Playlist Editor is available.
All classes posted here do not need debugging, they already have proven to run error free. The classes are only posted for information for the interested reader - no need to go through all the stuff in detail - only if it interests you.
My application calls class CollectionThread wich is a subclass of InfoThread. CollectionThread recursively goes through a directory and file structure and stores found ID3 tag information in instances of class ID3v11Tag which in turn gets stored in one instance of class AudioDataModel. All classes are shown below.
This is the mentioned CollectionThread
* Light Development Playlist Editor
* Copyright (C) 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.app.playlisteditor.data;
import com.lightdev.lib.util.InfoThread;
import java.io.File;
* A class to collect audio data from a given storage location.
* <p>
* <code>CollectionThread</code> uses ID3 tag information to gain data.
* </p>
* <p>See <a href="http://www.id3.org">http://www.id3.org</a> for details about
* ID3 tags.</p>
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software as well as any licensing notes
* inside this documentation
* @version 1, October 13, 2004
public class CollectionThread extends InfoThread {
* constructor
* @param model AudioDataModel the data model to collect data to
public CollectionThread(AudioDataModel model) {
this.model = model;
* constructor, creates a new empty AudioDataModel
public CollectionThread() {
this(new AudioDataModel());
* set the data model to collect data to
* @param model AudioDataModel the model to collect data to
public void setModel(AudioDataModel model) {
this.model = model;
* get the data model associated to this thread
* @return AudioDataModel the data model
public AudioDataModel getModel() {
return model;
* set the directory to collect data from
* @param rootDir File the directory to collect data from
public void setRootDirectory(File rootDir) {
this.rootDir = rootDir;
* do te actual work of this thread, i.e. iterate through a given directory
* structure and collect audio data
* @return boolean true, if work is left
protected boolean work() {
boolean workIsLeft = true;
maxValue = -1;
filesProcessed = 0;
if(getStatus() < STATUS_HALT_PENDING) {
countElements(rootDir.listFiles());
if(getStatus() < STATUS_HALT_PENDING) {
workIsLeft = collect(rootDir.listFiles());
return workIsLeft;
* count the elements in a given file array including its subdirectories
* @param files File[]
private void countElements(File[] files) {
int i = 0;
while (i < files.length && getStatus() < STATUS_HALT_PENDING) {
File file = files;
if (file.isDirectory()) {
countElements(file.listFiles());
i++;
maxValue++;
* recursively read data into model
* @param files File[] the file array representing the content of a given directory
private boolean collect(File[] files) {
int i = 0;
while(i < files.length && getStatus() < STATUS_HALT_PENDING) {
File file = files[i];
if(file.isDirectory()) {
collect(file.listFiles());
else if(file.getName().toLowerCase().endsWith("mp3")) {
try {
model.addTrack(file);
catch(Exception e) {
fireThreadException(e);
i++;
filesProcessed++;
fireThreadProgress(filesProcessed);
return (i<files.length);
/** the directory to collect data from */
private File rootDir;
/** the data model to collect data to */
private AudioDataModel model;
/** the number of files this thread processed so far while it is running */
private long filesProcessed = 0;
This is class InfoThread
* Light Development Java Library
* Copyright (C) 2003, 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.lib.util;
import java.util.Vector;
import java.util.Enumeration;
* Abstract class <code>InfoThread</class> implements a status and listener concept.
* An <code>InfoThread</code> object actively informs all objects registered as listeners about
* status changes, progress and possible exceptions. This way the status of a running
* thread does not require a polling mechanism to be monitored.
* <p>
* <code>InfoThread</code> implements the following working scheme
* </p>
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software
* @version Version 1, October 13, 2004
public abstract class InfoThread extends Thread {
* construct an <code>InfoThread</code> object
* <p>This class is meant to be used when a <code>Thread</code> object is needed that actively
* informs other objects about its status</code>. It is a good idea therefore to register
* one or more listeners with instances of this class before doing anything
* else.</p>
* @see addInfoThreadListener
public InfoThread() {
* set the amount of time this thread shall idle after it is through with one
* work cycle and before a next work cycle is started. This influences the time
* other threads have for their work.
* @param millis long the number of milliseconds to idle after one work cycle
public void setIdleMillis(long millis) {
idleMillis = millis;
* Causes this thread to begin execution; the Java Virtual Machine calls the <code>run</code>
* method of this thread. Calls method <code>prepareThread</code> before calling
* <code>run</code>.
* @see run
* @see prepareThread
public synchronized void start() {
setStatus(STATUS_INITIALIZING);
prepareThread();
setStatus(STATUS_READY);
super.start();
* call method <code>start</code> instead of this method.
* calling this method directly will lead to an exception
* @see start
public void run() {
//System.out.println("InfoThread.run");
if (status == STATUS_READY) {
boolean workIsLeft = true;
setStatus(STATUS_RUNNING);
while (status < STATUS_STOP_PENDING && workIsLeft) {
if (status < STATUS_HALT_PENDING) {
workIsLeft = work();
if(!workIsLeft) {
setStatus(STATUS_WORK_COMPLETE);
if (status == STATUS_HALT_PENDING) {
setStatus(STATUS_HALTED);
else if (status == STATUS_STOP_PENDING) {
setStatus(STATUS_STOPPED);
else {
try {
sleep(idleMillis);
catch (InterruptedException e) {
fireThreadException(e);
else {
// error: Thread is not ready to run
setStatus(STATUS_THREAD_FINISHED);
* stop this thread. This will terminate the thread irrevokably. Use method
* <code>haltThread</code> to pause a thread with the possiblity to resume work later.
* @see haltThread
public void stopThread() {
switch (status) {
case STATUS_RUNNING:
setStatus(STATUS_STOP_PENDING);
break;
case STATUS_HALT_PENDING:
// exception: the thread already is about to halt
break;
case STATUS_STOP_PENDING:
// exception: the thread already is about to stop
break;
default:
// exception: a thread can not be stopped, when it is not running
break;
* halt this thread, i.e. pause working allowing to resume later
* @see resumeThread
public void haltThread() {
switch (status) {
case STATUS_RUNNING:
setStatus(STATUS_STOP_PENDING);
break;
case STATUS_HALT_PENDING:
// exception: the thread already is about to halt
break;
case STATUS_STOP_PENDING:
// exception: the thread already is about to stop
break;
default:
// exception: a thread can not be halted, when it is not running
break;
* resume this thread, i.e. resume previously halted work
* @see haltThread
public void resumeThread() {
if(status == STATUS_HALTED || status == STATUS_HALT_PENDING) {
setStatus(STATUS_RUNNING);
else {
// exception: only halted threads or threads that are about to halt can be resumed
* this is the method to prepare a thread to run. It is not implemented in this abstract
* class. Subclasses of <code>InfoThread</code> can implement this method to do anything
* that might be required to put their thread into STATUS_READY. This method is called
* automatically by method <code>start</code>. When implementing this method, it should
* call method <code>fireThreadException</code> accordingly.
* @see start
* @see fireThreadException
protected void prepareThread() {
// does nothing in this abstract class but might be needed in subclasses
* this is the main activity method of this object. It is not implemented in this abstract
* class. Subclasses of <code>InfoThread</code> must implement this method to do something
* meaningful. When implementing this method, it should call methods
* <code>fireThreadProgress</code> and <code>fireThreadException</code> accordingly.
* @return boolean true, if work is left, false if not
* @see fireThreadProgress
* @see fireTreadException
protected abstract boolean work();
* add an <code>InfoTreadListener</code> to this instance of <code>InfoThread</code>
* @param l InfoThreadListener the listener to add
* @see removeInfoThreadListener
public void addInfoThreadListener(InfoThreadListener l) {
listeners.add(l);
* remove an <code>InfoTreadListener</code> from this instance of <code>InfoThread</code>
* @param l InfoThreadListener the listener to remove
public void removeInfoThreadListener(InfoThreadListener l) {
listeners.remove(l);
* notify all <code>InfoThreadListener</code>s of a status change
* @param fromStatus int the status tis thread had before the change
* @param toStatus int the status this thread has now
protected void fireThreadStatusChanged(int fromStatus, int toStatus) {
Enumeration e = listeners.elements();
while(e.hasMoreElements()) {
Object l = e.nextElement();
if(l instanceof InfoThreadListener) {
((InfoThreadListener) l).threadStatusChanged(this, fromStatus, toStatus);
* notify all <code>InfoThreadListener</code>s of an exception in this thread
* @param ex Exception the exception that occurred
protected void fireThreadException(Exception ex) {
Enumeration e = listeners.elements();
while(e.hasMoreElements()) {
Object l = e.nextElement();
if(l instanceof InfoThreadListener) {
((InfoThreadListener) l).threadException(this, ex);
* notify all <code>InfoThreadListener</code>s of the progress of this thread
* @param progressValue long a value indicating the current thread progress
protected void fireThreadProgress(long progressValue) {
Enumeration e = listeners.elements();
while(e.hasMoreElements()) {
Object l = e.nextElement();
if(l instanceof InfoThreadListener) {
((InfoThreadListener) l).threadProgress(this, progressValue, maxValue);
* set the status of this thread and notify all listeners
* @param newStatus int the status this thread is to be changed to
private void setStatus(int newStatus) {
//System.out.println("InfoThread.setStatus oldStatus=" + status + ", newStatus=" + newStatus);
int fromStatus = status;
status = newStatus;
fireThreadStatusChanged(fromStatus, newStatus);
* get the current status of this thread
* @return int the status
public int getStatus() {
return status;
* cleanup before actual destruction.
public void destroy() {
//System.out.println("InfoThread.destroy");
cleanup();
super.destroy();
* cleanup all references this thread maintains
private void cleanup() {
//System.out.println("InfoThread.cleanup");
listeners.removeAllElements();
listeners = null;
/* ----------------------- class fields start ------------------------ */
/** storage for the objects this thread notifies about status changes and progress */
private Vector listeners = new Vector();
/** indicator for the status of this thread */
private int status = STATUS_NONE;
/** maximum value for threadProgress */
protected long maxValue = -1;
/** the idle time inside one work cycle in milliseconds */
protected long idleMillis = 1;
/* ----------------------- class fields end -------------------------- */
/* ----------------------- constants start --------------------------- */
/** constant value indicating that no status has been set so far */
public static final int STATUS_NONE = 0;
/** constant value indicating that the thread is currently initializing */
public static final int STATUS_INITIALIZING = 1;
/** constant value indicating that the thread is ready to run */
public static final int STATUS_READY = 2;
/** constant value indicating that the thread is running */
public static final int STATUS_RUNNING = 3;
/** constant value indicating that the thread is about to halt */
public static final int STATUS_HALT_PENDING = 4;
/** constant value indicating that the thread is halted */
public static final int STATUS_HALTED = 5;
/** constant value indicating that the work of this thread is complete */
public static final int STATUS_WORK_COMPLETE = 6;
/** constant value indicating that the thread is about to stop */
public static final int STATUS_STOP_PENDING = 7;
/** constant value indicating that the thread is stopped */
public static final int STATUS_STOPPED = 8;
/** constant value indicating that the thread is finished */
public static final int STATUS_THREAD_FINISHED = 9;
/* ----------------------- constants end --------------------------- */
}this is the InfoThreadListener interface
* Light Development Java Library
* Copyright (C) 2003, 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.lib.util;
* An interface classes interested to receive events from objects
* of class <code>InfoThread</code> need to implement.
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software
* @version Version 1, October 13, 2004
public interface InfoThreadListener {
* method to receive a status change notification from a thread
* @param thread InfoThread the thread which status changed
* @param fromStatus int the status which the thread had before the change
* @param toStatus int the status which the thread has now
public void threadStatusChanged(InfoThread thread, int fromStatus, int toStatus);
* method to receive a notification about the progress of a thread
* @param thread InfoThread the thread which notified about its progress
* @param progressValue long the value (e.g. 10 if 100 percent completed, 20 of 1 million files processed, etc.)
public void threadProgress(InfoThread thread, long progressValue, long maxValue);
* method to receive a notifiaction about the fact that an exception occurred in a thread
* @param thread InfoThread the thread for which an exception occurred
* @param e Exception the exception that occurred
public void threadException(InfoThread thread, Exception e);
}This is class AudioFileDescriptor
* Light Development Java Library
* Copyright (C) 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.lib.audio;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.text.DecimalFormat;
* This class models characteristics of an audio file such as the absolute path
* of the file, its tag contents (if any) and the play duration, etc.
* <p>See <a href="http://www.id3.org">http://www.id3.org</a> for details about
* ID3 tags.</p>
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software
* @version Version 1, October 13, 2004
public class AudioFileDescriptor implements Serializable, Comparable {
public AudioFileDescriptor(String absolutePath) throws FileNotFoundException, IOException {
load(absolutePath);
public boolean equals(Object o) {
if(o != null && o instanceof AudioFileDescriptor) {
return ((AudioFileDescriptor) o).getAbsolutePath().equalsIgnoreCase(this.getAbsolutePath());
else {
return false;
public void load(String absolutePath) throws FileNotFoundException, IOException {
this.absolutePath = absolutePath;
RandomAccessFile rf = new RandomAccessFile(absolutePath, "r");
if(id3v11Tag == null) {
id3v11Tag = new ID3v11Tag(rf, false);
else {
id3v11Tag.readTag(rf, rf.length() - 128);
rf.close();
public String getAbsolutePath() {
return absolutePath;
public ID3v11Tag getID3v11Tag() {
return id3v11Tag;
public void setID3v11Tag(ID3v11Tag tag) {
this.id3v11Tag = tag;
public String toString() {
DecimalFormat df = new DecimalFormat("00");
return id3v11Tag.getArtist() + ", " + id3v11Tag.getAlbum() + " - " +
df.format(id3v11Tag.getTrackNumber()) + " " + id3v11Tag.getTitle();
* Compares this object with the specified object for order.
* @param o the Object to be compared.
* @return a negative integer, zero, or a positive integer as this object is less than, equal to,
* or greater than the specified object.
* @todo Implement this java.lang.Comparable method
public int compareTo(Object o) {
return toString().compareTo(o.toString());
private String absolutePath;
private ID3v11Tag id3v11Tag;
private transient long duration = -1;
private transient int type = TYPE_UNKNOWN;
public static final transient int TYPE_UNKNOWN = 0;
public static final transient int TYPE_MP3 = 1;
}This is class ID3V11Tag into which the data is actually stored
* Light Development Java Library
* Copyright (C) 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.lib.audio;
import java.io.File;
import java.io.RandomAccessFile;
import java.io.IOException;
import java.io.Serializable;
import java.text.DecimalFormat;
* This class is a very simple implementation of an ID3v11Tag. It models an ID3 tag
* pretty much the same way as it is physically stored inside an audio file.
* <p>See <a href="http://www.id3.org">http://www.id3.org</a> for details about
* ID3 tags.</p>
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software
* @version Version 1, October 13, 2004
public class ID3v11Tag implements Serializable, Comparable {
* construct an ID3v11Tag and read tag content from a given file
* <p>This constructor can be used for cases where a RandomAccessFile has already
* been opened and will be closed elsewhere</p>
* @param rf RandomAccessFile the open file to read from
* @param isAtTagStartPos boolean true, if the file pointer is at the
* position where the ID3 tag starts; when false, the pointer is positioned accordingly here
* @throws IOException
public ID3v11Tag(RandomAccessFile rf, boolean isAtTagStartPos) throws IOException {
if(isAtTagStartPos) {
readTag(rf);
else {
readTag(rf, rf.length() - 128);
* construct an ID3v11Tag and read tag content from a file at a given location
* <p>This constructor opens and closes the audio file for reading</p>
* @param absolutePath String the absolute path to the audio file to open
* @throws IOException
public ID3v11Tag(String absolutePath) throws IOException {
RandomAccessFile rf = new RandomAccessFile(absolutePath, "r");
readTag(rf, rf.length() - 128);
rf.close();
* construct an ID3v11Tag and read tag content from a given file
* <p>This constructor opens and closes the audio file for reading</p>
* @param audioFile File the audio file to read from
* @throws IOException
public ID3v11Tag(File audioFile) throws IOException {
this(audioFile.getAbsolutePath());
* get a string representation of this object
* @return String
public String toString() {
DecimalFormat df = new DecimalFormat("00");
return getArtist() + ", " + getAlbum() + " - " + df.format(getTrackNumber()) + " " + getTitle();
* position to file pointer and read the tag
* @param rf RandomAccessFile the file to read from
* @param jumpPos long the position to jump to (the tag start position)
* @throws IOException
public void readTag(RandomAccessFile rf, long jumpPos) throws IOException {
rf.seek(jumpPos);
readTag(rf);
* read the tag from a given file, assuming the file pointer to be at the tag start position
* @param rf RandomAccessFile the file to read from
* @throws IOException
public void readTag(RandomAccessFile rf) throws IOException {
rf.read(tagBuf);
if(tag.equalsIgnoreCase(new String(tagBuf))) {
rf.read(title);
rf.read(artist);
rf.read(album);
rf.read(year);
rf.read(comment);
rf.read(trackNo);
rf.read(genre);
public String getTitle() {
return new String(title).trim();
public String getArtist() {
return new String(artist).trim();
public String getAlbum() {
return new String(album).trim();
public String getYear() {
return new String(year).trim();
public String getComment() {
return new String(comment).trim();
public int getGenreId() {
try {
int id = new Byte(genre[0]).intValue();
if(id < GENRE_ID_MIN || id > GENRE_ID_MAX) {
return GENRE_ID_OTHER;
else {
return id;
catch(Exception ex) {
return GENRE_ID_OTHER;
public String getGenreName() {
return genreNames[getGenreId()];
public int getTrackNumber() {
try {
return (int) trackNo[0];
catch(Exception e) {
return 0;
* Compares this object with the specified object for order.
* @param o the Object to be compared.
* @return a negative integer, zero, or a positive integer as this object is less than, equal to,
*Hi Franck,
thank you, mate. I did what you suggested (changed class attached) but that did not change the mentioned behaviour.
The first run is approximately 75 seconds with Java option -Xms40m and approx. double without, the second run and all subsequent runs are only 2-3 seconds each (!!!) even when terminating and re-starting the application between thread runs.
I'm pretty clueless about that, any more help on this anyone?
Thanks a lot and best regards
Ulrich
PS: BTW, I forgot to post the class that is filled with data by class CollectionThread, so here it is
* Light Development Playlist Editor
* Copyright (C) 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.app.playlisteditor.data;
import java.io.File;
import com.lightdev.lib.audio.ID3v11Tag;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.IOException;
import java.io.Serializable;
import com.lightdev.lib.audio.AudioFileDescriptor;
import com.lightdev.lib.ui.SortListModel;
import java.util.Iterator;
* Storage model for audio data.
* <p>
* <code>AudioDataModel</code> can be used to store ID3 tag data collected from
* a directory with audio files to perform queries and reports on the found data.
* </p>
* <p>See <a href="http://www.id3.org">http://www.id3.org</a> for details about
* ID3 tags.</p>
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software as well as any licensing notes
* inside this documentation
* @version 1, October 15, 2004
public class AudioDataModel extends SortListModel implements Serializable {
* constructor
public AudioDataModel() {
* add an audio track from a given audio file
* <p>This will attempt to read ID3 tag data from the file.</p>
* @param audioFile File the file to add audio data for
* @throws IOException
public void addTrack(File audioFile) throws IOException {
AudioFileDescriptor afd = new AudioFileDescriptor(audioFile.getAbsolutePath());
if (!data.contains(afd)) {
data.add(afd);
* get all tracks for agiven combination of genre name, artist name and album name. Any of
* the parameters may be null or AudioDataModel.FILTER_ALL
* <p>Ugly code, I know, but it simply hard codes all combinations of the the mentioned
* parameters. Any more elegant implementations welcome.</p>
* @param genreName String a genre name to get tracks for
* @param artistName String an artist name to get tracks for
* @param albumName String an album name to get tracks for
* @return SortListModel the found tracks in a list model
public SortListModel getTracks(String genreName, String artistName, String albumName) {
SortListModel foundTracks = new SortListModel();
Iterator e = data.iterator();
while(e.hasNext()) {
AudioFileDescriptor afd = (AudioFileDescriptor) e.next();
ID3v11Tag tag = afd.getID3v11Tag();
if(genreName == null || genreName.equalsIgnoreCase(FILTER_ALL)) {
if(artistName == null || artistName.equalsIgnoreCase(FILTER_ALL)) {
if (tag.getAlbum().equalsIgnoreCase(albumName))
foundTracks.add(afd);
else {
if(albumName == null || albumName.equalsIgnoreCase(FILTER_ALL)) {
if (tag.getArtist().equalsIgnoreCase(artistName))
foundTracks.add(afd);
else {
if (tag.getArtist().equalsIgnoreCase(artistName) &&
tag.getAlbum().equalsIgnoreCase(albumName))
foundTracks.add(afd);
else {
if(artistName == null || artistName.equalsIgnoreCase(FILTER_ALL)) {
if(albumName == null || albumName.equalsIgnoreCase(FILTER_ALL)) {
if (tag.getGenreName().equalsIgnoreCase(genreName))
foundTracks.add(afd);
else {
if (tag.getGenreName().equalsIgnoreCase(genreName) &&
tag.getAlbum().equalsIgnoreCase(albumName))
foundTracks.add(afd);
else {
if(albumName == null || albumName.equalsIgnoreCase(FILTER_ALL)) {
if (tag.getGenreName().equalsIgnoreCase(genreName) &&
tag.getArtist().equalsIgnoreCase(artistName))
foundTracks.add(afd);
else {
if (tag.getGenreName().equalsIgnoreCase(genreName) &&
tag.getArtist().equalsIgnoreCase(artistName) &&
tag.getAlbum().equalsIgnoreCase(albumName))
foundTracks.add(afd);
foundTracks.sort();
return foundTracks;
* list all artists in this model
* @return SortListModel
public SortListModel listArtists() {
SortListModel artists = new SortListModel();
artists.add(FILTER_ALL);
Iterator e = data.iterator();
while (e.hasNext()) {
ID3v11Tag tag = ((AudioFileDescriptor) e.next()).getID3v11Tag();
String artistName = tag.getArtist();
if (artists.indexOf(artistName) < 0) {
artists.add(artistName);
artists.sort();
return artists;
* list all artists in this model having titles belonging to a given genre
* @param genreName String name of the genre artists are searched for
* @return SortListModel
public SortListModel listArtists(String genreName) {
SortListModel artists = new SortListModel();
artists.add(FILTER_ALL);
Iterator e = data.iterator();
while (e.hasNext()) {
ID3v11Tag tag = ((AudioFileDescriptor) e.next()).getID3v11Tag();
String artistName = tag.getArtist();
String genre = tag.getGenreName();
if (artists.indexOf(artistName) < 0 && genre.equalsIgnoreCase(genreName)) {
artists.add(artistName);
artists.sort();
return artists;
* list all genres in this model
* @return SortListModel
public SortListModel listGenres() {
SortListModel genres = new SortListModel();
genres.add(FILTER_ALL);
Iterator e = data.iterator();
while (e.hasNext()) {
ID3v11Tag tag = ((AudioFileDescriptor) e.next()).getID3v11Tag();
String genreName = tag.getGenreName();
if (genres.indexOf(genreName) < 0) {
genres.add(genreName);
genres.sort();
return genres;
* list all albums in this model
* @return SortListModel
public SortListModel listAlbums() {
SortListModel albums = new SortListModel();
albums.add(FILTER_ALL);
Iterator e = data.iterator();
while (e.hasNext()) {
ID3v11Tag tag = ((AudioFileDescriptor) e.next()).getID3v11Tag();
String albumName = tag.getAlbum();
if (albums.indexOf(albumName) < 0) {
albums.add(albumName);
albums.sort();
return albums;
* list all albums in this model having titles belonging to a given genre
* @param genreName String name of the genre albums are searched for
* @return SortListModel
public SortListModel listAlbums(String genreName) {
SortListModel albums = new SortListModel();
albums.add(FILTER_ALL);
Iterator e = data.iterator();
while (e.hasNext()) {
ID3v11Tag tag = ((AudioFileDescriptor) e.next()).getID3v11Tag();
String albumName = tag.getAlbum();
String genre = tag.getGenreName();
if (albums.indexOf(albumName) < 0 && genre.equalsIgnoreCase(genreName)) {
albums.add(albumName);
albums.sort();
return albums;
* list all albums in this model having titles belonging to a given genre and artist
* @param genreName String name of the genre albums are searched for
* @param artistName String name of the artist albums are searched for
* @return SortListModel
public SortListModel listAlbums(String genreName, String artistName) {
SortListModel albums = new SortListModel();
albums.add(FILTER_ALL);
Iterator e = data.iterator();
while (e.hasNext()) {
ID3v11Tag tag = ((AudioFileDescriptor) e.next()).getID3v11Tag();
String albumName = tag.getAlbum();
String genre = tag.getGenreName();
String artist = tag.getArtist();
if(genreName == null || genreName.equalsIgnoreCase(FILTER_ALL)) {
if (albums.indexOf(albumName) < 0 &&
artist.equalsIgnoreCase(artistName))
albums.add(albumName);
else {
if (albums.indexOf(albumName) < 0 &&
genre.equalsIgnoreCase(genreName) &&
artist.equalsIgnoreCase(artistName))
albums.add(albumName);
albums.sort();
return albums;
* get the number of audio tracks stored in this data model
* @return int the number of tracks
public int getTrackCount() {
return data.size();
/** constant to select all items of a given part */
public static final String FILTER_ALL = " all";
}...and here the changed CollectionThread now caching found File objects in a vector
* Light Development Playlist Editor
* Copyright (C) 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package com.lightdev.app.playlisteditor.data;
import com.lightdev.lib.util.InfoThread;
import java.io.File;
import java.util.Vector;
import java.util.Enumeration;
* A class to collect audio data from a given storage location.
* <p>
* <code>CollectionThread</code> uses ID3 tag information to gain data.
* </p>
* <p>See <a href="http://www.id3.org">http://www.id3.org</a> for details about
* ID3 tags.</p>
* @author Ulrich Hilger
* @author Light Development
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
* @author <a href="mailto:[email protected]">[email protected]</a>
* @author published under the terms and conditions of the
* GNU General Public License,
* for details see file gpl.txt in the distribution
* package of this software as well as any licensing notes
* inside this documentation
* @version 1, October 13, 2004
public class CollectionThread extends InfoThread {
* constructor
* @param model AudioDataModel the data model to collect data to
public CollectionThread(AudioDataModel model) {
this.model = model;
* constructor, creates a new empty AudioDataModel
public CollectionThread() {
this(new AudioDataModel());
* set the data model to collect data to
* @param model AudioDataModel the model to collect data to
public void setModel(AudioDataModel model) {
this.model = model;
* get the data model associated to this thread
* @return AudioDataModel the data model
public AudioDataModel getModel() {
return model;
* set the directory to collect data from
* @param rootDir File the directory to collect data from
public void setRootDirectory(File rootDir) {
this.rootDir = rootDir;
* this is the method to prepare a thread to run.
protected void prepareThread() {
maxValue = -1;
filesProcessed = 0;
innerCount = 0;
fileList = new Vector();
* do the actual work of this thread, i.e. iterate through a given directory
* structure and collect audio data
* @return boolean true, if work is left
protected boolean work() {
boolean workIsLeft = true;
if(getStatus() < STATUS_HALT_PENDING) {
countElements(rootDir.listFiles());
if(getStatus() < STATUS_HALT_PENDING) {
workIsLeft = collect(); //collect(rootDir.listFiles());
fileList.clear();
fileList = null;
return workIsLeft;
* count the elements in a given file array including its subdirectories
* @param files File[]
private void countElements(File[] files) {
int i = 0;
while (i < files.length && getStatus() < STATUS_HALT_PENDING) {
File file = files;
if (file.isDirectory()) {
countElements(file.listFiles());
else {
fileList.add(file);
i++;
maxValue++;
* read data into model
* @param files File[] the file array representing the content of a given directory
* @return boolean true, if work is left
private boolean collect(/*File[] files*/) {
Enumeration files = fileList.elements();
while(files.hasMoreElements() && getStatus() < STATUS_HALT_PENDING) {
File file = (File) files.nextElement();
try {
model.addTrack(file);
catch(Exception e) {
fireThreadException(e);
filesProcessed++;
if(++innerCount > 99) {
innerCount = 0;
fireThreadProgress(filesProcessed);
return false;
int i = 0;
while(i < files.length && getStatus() < STATUS_HALT_PENDING) {
File file = files[i];
if(file.isDirectory()) {
collect(file.listFiles());
else if(file.getName().toLowerCase().endsWith("mp3")) {
try {
model.addTrack(file);
catch(Exception e) {
fireThreadException(e);
i++;
filesProcessed++;
fireThreadProgress(filesProcessed);
return (i<files.length);
/** the directory to collect data from */
private File rootDir;
/** the data model to collect data to */
private AudioDataModel model;
/** the number of files this thread processed so far while it is running */
private long filesProcessed = 0;
/** a list to temporary store found files */
private Vector fileList;
/** counter to determine when to fire progress messages */
private int innerCount = 0; -
Hi,
I am looking for some help in tuning a query and details are below.
SELECT NVL(B.START_DATE_TIME,
A.START_DATE_TIME) START_DATE,
NVL(B.CUST_PRODUCTION_SEQ_NUM,
A.CUST_PRODUCTION_SEQ_NUM) PROD_NUM,
A.HEADER_ID NEW_HEADER_ID,
B.HEADER_ID OLD_HEADER_ID,
A.LINE_ID,
B.LINE_ID,
A.QTY_TYPE_CODE NEW_CODE,
B.QTY_TYPE_CODE OLD_CODE,
NVL(B.SHIP_FROM_ORG_ID,
A.SHIP_FROM_ORG_ID) SHIP_FROM_ORG_ID,
-- hrorg.name ship_from_name ,
NVL(B.SHIP_TO_ORG_ID,
A.SHIP_TO_ORG_ID) SHIP_TO_ORG_ID,
NVL(B.BILL_TO_ADDRESS_ID,
A.BILL_TO_ADDRESS_ID) BILL_TO_ADDRESS_ID,
NVL(B.SHIP_TO_ADDRESS_ID,
A.SHIP_TO_ADDRESS_ID) SHIP_TO_ADDRESS_ID,
NVL(B.SHIP_TO_NAME_EXT,
A.SHIP_TO_NAME_EXT) SHIP_TO_NAME,
NVL(B.INTRMD_SHIP_TO_ID,
A.INTRMD_SHIP_TO_ID) INTRMD_SHIP_TO_ID,
NVL(B.CUSTOMER_ITEM_ID,
A.CUSTOMER_ITEM_ID) CUSTOMER_ITEM_ID,
--mci.customer_item_desc customer_item_desc,
NVL(B.INVENTORY_ITEM_ID,
A.INVENTORY_ITEM_ID) INVENTORY_ITEM_ID,
NVL(B.ITEM_DETAIL_SUBTYPE,
A.ITEM_DETAIL_SUBTYPE) ITEM_DETAIL_SUBTYPE,
FND1.MEANING DETAIL_SUBTYPE,
NVL(B.UOM_CODE,
A.UOM_CODE) UOM_CODE,
NVL(B.CUST_PO_NUMBER,
A.CUST_PO_NUMBER) CUST_PO_NUMBER,
NVL(B.INDUSTRY_ATTRIBUTE1,
A.INDUSTRY_ATTRIBUTE1) CUST_RECORD_YEAR,
A.ITEM_DETAIL_QUANTITY,
A.ITEM_DETAIL_TYPE,
FND2.MEANING NEW_DETAIL_TYPE,
B.ITEM_DETAIL_QUANTITY,
B.ITEM_DETAIL_TYPE,
FND3.MEANING OLD_DETAIL_TYPE
FROM RLM_SCHEDULE_LINES_ALL A,
(SELECT * FROM RLM_SCHEDULE_LINES_ALL b_in
WHERE TRUNC(b_in.START_DATE_TIME) >=
(SELECT TRUNC(SCHED_HORIZON_START_DATE)
FROM RLM_SCHEDULE_HEADERS
WHERE HEADER_ID = :P_NEW_HEADER_ID)---
AND TRUNC(b_in.START_DATE_TIME) <=
(SELECT TRUNC(SCHED_HORIZON_END_DATE)
FROM RLM_SCHEDULE_HEADERS
WHERE HEADER_ID = :P_NEW_HEADER_ID)
AND HEADER_ID = (SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE header_id =
(SELECT MAX(rsha.header_id)
FROM apps.rlm_schedule_headers_all rsha,
apps.rlm_schedule_lines_all rsla
WHERE rsha.customer_id = :p_customer_id
AND rsha.schedule_type = :p_schedule_type
AND rsla.inventory_item_id = b_in.inventory_item_id ---
AND rsla.org_id = rsha.org_id
AND (((rsla.cust_po_number = b_in.cust_po_number)AND
EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID))
OR
NOT EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID) )---
and rsha.header_id = rsla.header_id
and rsla.ship_from_org_id = :p_ship_from_org_id
AND rsha.ece_tp_location_code_ext = :p_ece_tp_location_code_ext
AND NVL(rsha.header_ref_value_1, '1') =
NVL(rsha.header_ref_value_1, '1')
AND rsha.header_id NOT IN
(SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE attribute1 = :p_request_id)))) B,
--rlm_schedule_headers c,
-- hr_organization_units hrorg,
--mtl_customer_items mci,
FND_LOOKUPS FND1,
FND_LOOKUPS FND2,
FND_LOOKUPS FND3
-- ra_addresses_all radd2,
-- ra_site_uses_all rsu2
WHERE A.HEADER_ID(+) = :P_NEW_HEADER_ID
----AND B.HEADER_ID = :P_OLD_HEADER_ID
AND A.CUSTOMER_ITEM_ID(+) = B.CUSTOMER_ITEM_ID
AND A.SHIP_TO_ORG_ID(+) = B.SHIP_TO_ORG_ID
AND A.SHIP_FROM_ORG_ID(+) = B.SHIP_FROM_ORG_ID
AND A.INVENTORY_ITEM_ID(+) = B.INVENTORY_ITEM_ID
AND NVL(A.INTRMD_SHIP_TO_ID(+),
NVL(B.INTRMD_SHIP_TO_ID,
0)) = NVL(B.INTRMD_SHIP_TO_ID,
0)
AND A.ITEM_DETAIL_SUBTYPE(+) = B.ITEM_DETAIL_SUBTYPE
AND A.UOM_CODE(+) = B.UOM_CODE
AND NVL(A.CUST_PO_NUMBER(+),
NVL(B.CUST_PO_NUMBER,
0)) = NVL(B.CUST_PO_NUMBER,
0)
AND A.ITEM_DETAIL_TYPE(+) < :P_ITEM_DETAIL_TYPE
AND B.ITEM_DETAIL_TYPE < :P_ITEM_DETAIL_TYPE
AND TRUNC(A.START_DATE_TIME(+)) = TRUNC(B.START_DATE_TIME)
AND FND1.LOOKUP_CODE = NVL(A.ITEM_DETAIL_SUBTYPE,
B.ITEM_DETAIL_SUBTYPE)
AND FND1.LOOKUP_TYPE = :P_RLM_DETAIL_SUBTYPE_CODE
AND NVL(A.ITEM_DETAIL_TYPE,
'0') = FND2.LOOKUP_CODE
AND FND2.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
AND FND3.LOOKUP_CODE = B.ITEM_DETAIL_TYPE
AND A.SHIP_FROM_ORG_ID(+) = :P_SHIP_FROM_ORG_ID
AND B.SHIP_FROM_ORG_ID = :P_SHIP_FROM_ORG_ID
AND FND3.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
AND B.CUSTOMER_ITEM_ID IN
(SELECT DISTINCT CUSTOMER_ITEM_ID
FROM RLM_SCHEDULE_LINES_ALL
WHERE HEADER_ID = :P_NEW_HEADER_ID) &P_WHERE4 &P_WHERE3
-- CHANGES
&P_WHERE_DATE_A
UNION
SELECT NVL(A.START_DATE_TIME,
B.START_DATE_TIME) START_DATE,
NVL(A.CUST_PRODUCTION_SEQ_NUM,
B.CUST_PRODUCTION_SEQ_NUM) PROD_NUM,
A.HEADER_ID NEW_HEADER_ID,
B.HEADER_ID OLD_HEADER_ID,
A.LINE_ID,
B.LINE_ID,
A.QTY_TYPE_CODE NEW_CODE,
B.QTY_TYPE_CODE OLD_CODE,
NVL(A.SHIP_FROM_ORG_ID,
B.SHIP_FROM_ORG_ID) SHIP_FROM_ORG_ID,
-- hrorg.name ship_from_name ,
NVL(A.SHIP_TO_ORG_ID,
B.SHIP_TO_ORG_ID) SHIP_TO_ORG_ID,
NVL(A.BILL_TO_ADDRESS_ID,
B.BILL_TO_ADDRESS_ID) BILL_TO_ADDRESS_ID,
NVL(A.SHIP_TO_ADDRESS_ID,
B.SHIP_TO_ADDRESS_ID) SHIP_TO_ADDRESS_ID,
NVL(A.SHIP_TO_NAME_EXT,
B.SHIP_TO_NAME_EXT) SHIP_TO_NAME,
NVL(A.INTRMD_SHIP_TO_ID,
B.INTRMD_SHIP_TO_ID) INTRMD_SHIP_TO_ID,
NVL(A.CUSTOMER_ITEM_ID,
B.CUSTOMER_ITEM_ID) CUSTOMER_ITEM_ID,
--mci.customer_item_desc customer_item_desc,
NVL(A.INVENTORY_ITEM_ID,
B.INVENTORY_ITEM_ID) INVENTORY_ITEM_ID,
NVL(A.ITEM_DETAIL_SUBTYPE,
B.ITEM_DETAIL_SUBTYPE) ITEM_DETAIL_SUBTYPE,
FND1.MEANING DETAIL_SUBTYPE,
NVL(A.UOM_CODE,
B.UOM_CODE) UOM_CODE,
NVL(A.CUST_PO_NUMBER,
B.CUST_PO_NUMBER) CUST_PO_NUMBER,
NVL(A.INDUSTRY_ATTRIBUTE1,
B.INDUSTRY_ATTRIBUTE1) CUST_RECORD_YEAR,
A.ITEM_DETAIL_QUANTITY,
A.ITEM_DETAIL_TYPE,
FND2.MEANING NEW_DETAIL_TYPE,
B.ITEM_DETAIL_QUANTITY,
B.ITEM_DETAIL_TYPE,
FND3.MEANING OLD_DETAIL_TYPE
FROM RLM_SCHEDULE_LINES_ALL A,
(SELECT * FROM RLM_SCHEDULE_LINES_ALL b_in
WHERE TRUNC(b_in.START_DATE_TIME) >=
(SELECT TRUNC(SCHED_HORIZON_START_DATE)
FROM RLM_SCHEDULE_HEADERS
WHERE HEADER_ID = :P_NEW_HEADER_ID)
AND HEADER_ID = (SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE header_id =
(SELECT MAX(rsha.header_id)
FROM apps.rlm_schedule_headers_all rsha,
apps.rlm_schedule_lines_all rsla
WHERE rsha.customer_id = :p_customer_id
AND rsha.schedule_type = :p_schedule_type
AND rsla.inventory_item_id = b_in.inventory_item_id ---
AND rsla.org_id = rsha.org_id
AND (((rsla.cust_po_number = b_in.cust_po_number)AND
EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID))
OR
NOT EXISTS (SELECT 'x'
FROM FND_LOOKUP_VALUES_VL FLV,
RA_CUSTOMERS RC
WHERE FLV.LOOKUP_TYPE = 'TEST_RLM_CHECK_CUST'
AND FLV.MEANING = RC.CUSTOMER_NAME
AND RC.CUSTOMER_ID = :P_CUSTOMER_ID) )---
and rsha.header_id = rsla.header_id
and rsla.ship_from_org_id = :p_ship_from_org_id
AND rsha.ece_tp_location_code_ext = :p_ece_tp_location_code_ext
AND NVL(rsha.header_ref_value_1, '1') =
NVL(rsha.header_ref_value_1, '1')
AND rsha.header_id NOT IN
(SELECT header_id
FROM apps.rlm_schedule_headers_all
WHERE attribute1 = :p_request_id)))) B,
--rlm_schedule_headers c,
-- hr_organization_units hrorg,
--mtl_customer_items mci,
FND_LOOKUPS FND1,
FND_LOOKUPS FND2,
FND_LOOKUPS FND3
-- ra_addresses_all radd2,
-- ra_site_uses_all rsu2
WHERE A.HEADER_ID = :P_NEW_HEADER_ID
---- AND B.HEADER_ID(+) = :P_OLD_HEADER_ID
--a.header_id=c.header_id and
-- a.header_id = 803 and
-- b.header_id (+) = 804 and
AND B.CUSTOMER_ITEM_ID(+) = A.CUSTOMER_ITEM_ID
AND B.SHIP_TO_ORG_ID(+) = A.SHIP_TO_ORG_ID
AND B.SHIP_FROM_ORG_ID(+) = A.SHIP_FROM_ORG_ID
AND B.INVENTORY_ITEM_ID(+) = A.INVENTORY_ITEM_ID
AND NVL(B.INTRMD_SHIP_TO_ID(+),
NVL(A.INTRMD_SHIP_TO_ID,
0)) = NVL(A.INTRMD_SHIP_TO_ID,
0)
AND B.ITEM_DETAIL_SUBTYPE(+) = A.ITEM_DETAIL_SUBTYPE
AND B.UOM_CODE(+) = A.UOM_CODE
AND NVL(B.CUST_PO_NUMBER(+),
NVL(A.CUST_PO_NUMBER,
0)) = NVL(A.CUST_PO_NUMBER,
0)
AND B.ITEM_DETAIL_TYPE(+) < :P_ITEM_DETAIL_TYPE
AND A.ITEM_DETAIL_TYPE < :P_ITEM_DETAIL_TYPE
AND TRUNC(B.START_DATE_TIME(+)) = TRUNC(A.START_DATE_TIME)
AND FND1.LOOKUP_CODE = NVL(B.ITEM_DETAIL_SUBTYPE,
A.ITEM_DETAIL_SUBTYPE)
AND FND1.LOOKUP_TYPE = :P_RLM_DETAIL_SUBTYPE_CODE
AND A.ITEM_DETAIL_TYPE = FND2.LOOKUP_CODE
AND FND2.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
AND NVL(B.ITEM_DETAIL_TYPE,
'0') = FND3.LOOKUP_CODE
AND A.SHIP_FROM_ORG_ID = :P_SHIP_FROM_ORG_ID
AND B.SHIP_FROM_ORG_ID(+) = :P_SHIP_FROM_ORG_ID
AND FND3.LOOKUP_TYPE = :P_RLM_DETAIL_TYPE_CODE
&P_WHERE5 &P_WHERE3
-- CHANGES
&P_WHERE_DATE_BThe above query is related to the Oracle Release Management 11.5.10.2
The main header table is RLM_SCHEDULE_HEADERS_ALL which contains the information like schedule_reference_number and other details. In one schedule there can be many item records for different dates which are stored in the child table RLM_SCHEDULE_LINES_ALL. Both the tables are linked with HEADER_ID. Each schedule in header table has one horizon start date and horizon end date. Customer used to send these schedules every day for each item because of there business needs.
The requirement is to create a query to calculate the Net Change between the two schedules (Between the new and old). All the item records from child table for new schedule will be printed but only those item records from old schedule will be printed where schedule date in child table is within the horizon start date and end date of new schedule.
There are following indexes on the table RLM_SCHEDULE_LINES_ALL
IDX$$_199350001 Normal INVENTORY_ITEM_ID, SHIP_TO_ORG_ID, SHIP_FROM_NAME_EXT
IDX$$_199350002 Normal HEADER_ID, INVENTORY_ITEM_ID
RLM_SCHEDULE_LINE_CUSTOM Normal ITEM_DETAIL_TYPE, HEADER_ID
RLM_SCHEDULE_LINE_N1 Normal HEADER_ID, INTERFACE_LINE_ID
RLM_SCHEDULE_LINE_N2 Normal SHIP_FROM_ORG_ID, SHIP_TO_ORG_ID, CUSTOMER_ITEM_ID
RLM_SCHEDULE_LINE_N99 Normal INVENTORY_ITEM_ID
RLM_SCHEDULE_LINE_U1 Normal LINE_ID
XXRLM_RLM_SCHEDULE_LINES Normal SHIP_TO_ORG_ID, SHIP_FROM_NAME_EXT, PROCESS_STATUS, ITEM_DETAIL_TYPE, INVENTORY_ITEM_ID, CUSTOMER_ITEM_ID
Database Version: 11.1.0.7.0Optimizer Parameters:
SQL> show parameter optimizer
NAME TYPE VALUE
_optimizer_push_pred_cost_based boolean TRUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.1.0.6
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean FALSE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL>
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 8
SQL>
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL>
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL>
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL>
SQL>
SQL> SELECT SNAME,
2 PNAME,
3 PVAL1,
4 PVAL2
5 FROM SYS.AUX_STATS$;
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 03-30-2011 06:20
SYSSTATS_INFO DSTOP 03-30-2011 06:20
SYSSTATS_INFO FLAGS 0
SYSSTATS_MAIN CPUSPEEDNW 976.063
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
13 rows selected
SQL>Output of the explain plan will be in the next thread because of size constraint.Here is the output of explain plan
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | R
| 0 | SELECT STATEMENT | |
| 1 | SORT UNIQUE | |
| 2 | UNION-ALL | |
|* 3 | FILTER | |
| 4 | NESTED LOOPS | |
| 5 | NESTED LOOPS | |
| 6 | NESTED LOOPS | |
|* 7 | HASH JOIN | |
| 8 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 9 | INDEX SKIP SCAN | RLM_SCHEDULE_LINE_CUSTOM |
|* 10 | HASH JOIN RIGHT OUTER | |
|* 11 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 12 | INDEX SKIP SCAN | RLM_SCHEDULE_LINE_CUSTOM |
| 13 | NESTED LOOPS | |
| 14 | NESTED LOOPS | |
| 15 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
PLAN_TABLE_OUTPUT
|* 16 | INDEX RANGE SCAN | IDX$$_123E00001 |
|* 17 | INDEX RANGE SCAN | RLM_SCHEDULE_LINE_CUSTOM |
|* 18 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 19 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 20 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 21 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 22 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
| 23 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
|* 24 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
|* 25 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
| 26 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
|* 27 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
| 28 | SORT AGGREGATE | |
| 29 | NESTED LOOPS | |
| 30 | NESTED LOOPS | |
| 31 | NESTED LOOPS ANTI | |
|* 32 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 33 | INDEX RANGE SCAN | RLM_SCHEDULE_HEADERS_N3 |
|* 34 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 35 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 36 | INDEX RANGE SCAN | IDX$$_199350002 |
PLAN_TABLE_OUTPUT
|* 37 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
| 38 | NESTED LOOPS | |
| 39 | NESTED LOOPS | |
| 40 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS |
|* 41 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 42 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 5
|* 43 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 44 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 45 | NESTED LOOPS | |
| 46 | NESTED LOOPS | |
| 47 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS |
|* 48 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 49 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 5
|* 50 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 51 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 52 | NESTED LOOPS | |
| 53 | NESTED LOOPS | |
| 54 | NESTED LOOPS | |
| 55 | NESTED LOOPS OUTER | |
| 56 | NESTED LOOPS | |
| 57 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
PLAN_TABLE_OUTPUT
|* 58 | INDEX RANGE SCAN | IDX$$_123E00001 |
|* 59 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 60 | INDEX RANGE SCAN | RLM_SCHEDULE_LINE_CUSTOM |
|* 61 | VIEW PUSHED PREDICATE | |
|* 62 | FILTER | |
|* 63 | FILTER | |
|* 64 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
|* 65 | INDEX RANGE SCAN | IDX$$_199350001 |
|* 66 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 67 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 68 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
| 69 | SORT AGGREGATE | |
| 70 | NESTED LOOPS | |
| 71 | NESTED LOOPS | |
| 72 | NESTED LOOPS ANTI | |
|* 73 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 74 | INDEX RANGE SCAN | RLM_SCHEDULE_HEADERS_N3 |
|* 75 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_HEADERS_ALL |
|* 76 | INDEX UNIQUE SCAN | RLM_SCHEDULE_HEADERS_U1 |
|* 77 | INDEX RANGE SCAN | IDX$$_199350002 |
|* 78 | TABLE ACCESS BY INDEX ROWID | RLM_SCHEDULE_LINES_ALL |
PLAN_TABLE_OUTPUT
| 79 | NESTED LOOPS | |
| 80 | NESTED LOOPS | |
| 81 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCOUNTS |
|* 82 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 83 | TABLE ACCESS BY INDEX ROWID| HZ_PARTIES | 5
|* 84 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 85 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 86 | NESTED LOOPS | |
| 87 | NESTED LOOPS | |
| 88 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCOUNTS |
|* 89 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 |
| 90 | TABLE ACCESS BY INDEX ROWID| HZ_PARTIES | 5
|* 91 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 |
|* 92 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U2 |
| 93 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
|* 94 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
|* 95 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 |
| 96 | TABLE ACCESS BY INDEX ROWID | FND_LOOKUP_VALUES |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
3 - filter("HEADER_ID"= (SELECT "HEADER_ID" FROM "APPS"."RLM_SCHEDULE_HEADERS
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"= (SELECT MAX("RSHA"."
"APPS"."RLM_SCHEDULE_LINES_ALL" "RSLA","APPS"."RLM_SCHEDULE_HEADER
"RSHA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RLM_SCHEDULE_HEADERS_ALL
"RSHA"."HEADER_ID"="HEADER_ID" AND TO_NUMBER("ATTRIBUTE1")=1090072
"RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989' AND "RSHA"."CUSTOMER_
"RSHA"."SCHEDULE_TYPE"='PLANNING_RELEASE' AND NVL("RSHA"."HEADER_R
"RSLA"."INVENTORY_ITEM_ID"=:B1 AND "RSHA"."HEADER_ID"="RSLA"."HEAD
"RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B2 AN
"AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APP
WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=US
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
7 - access("B_IN"."CUSTOMER_ITEM_ID"="CUSTOMER_ITEM_ID")
9 - access("HEADER_ID"=1197995)
PLAN_TABLE_OUTPUT
filter("HEADER_ID"=1197995)
10 - access("A"."CUSTOMER_ITEM_ID"(+)="B_IN"."CUSTOMER_ITEM_ID" AND
"A"."SHIP_TO_ORG_ID"(+)="B_IN"."SHIP_TO_ORG_ID" AND
"A"."SHIP_FROM_ORG_ID"(+)="B_IN"."SHIP_FROM_ORG_ID" AND
"A"."INVENTORY_ITEM_ID"(+)="B_IN"."INVENTORY_ITEM_ID" AND
"A"."ITEM_DETAIL_SUBTYPE"(+)="B_IN"."ITEM_DETAIL_SUBTYPE" AND "A".
AND TRUNC(INTERNAL_FUNCTION("A"."START_DATE_TIME"(+)))=TRUNC(INTER
IME")))
filter(NVL("A"."INTRMD_SHIP_TO_ID"(+),NVL("B_IN"."INTRMD_SHIP_TO_ID",0))=
SHIP_TO_ID",0) AND NVL("A"."CUST_PO_NUMBER"(+),NVL("B_IN"."CUST_PO
O_NUMBER",'0'))
11 - filter("A"."SHIP_FROM_ORG_ID"(+)=2904)
12 - access("A"."HEADER_ID"(+)=1197995)
filter("A"."HEADER_ID"(+)=1197995 AND TO_NUMBER("A"."ITEM_DETAIL_TYPE"(+)
16 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LANGUAGE"=USERENV('LANG'))
filter("SECURITY_GROUP_ID"="FND_GLOBAL"."LOOKUP_SECURITY_GROUP"("LV"."LOO
W_APPLICATION_ID"))
17 - access("LOOKUP_CODE"="B_IN"."ITEM_DETAIL_TYPE")
filter(TO_NUMBER("B_IN"."ITEM_DETAIL_TYPE")<3)
18 - filter("B_IN"."SHIP_FROM_ORG_ID"=2904 AND TRUNC(INTERNAL_FUNCTION("B_IN".
PLAN_TABLE_OUTPUT
>= (SELECT TRUNC(INTERNAL_FUNCTION("SCHED_HORIZON_START_DATE")) FR
"RLM"."RLM_SCHEDULE_HEADERS_ALL" "RLM_SCHEDULE_HEADERS_ALL" WHERE
NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
TRUNC(INTERNAL_FUNCTION("B_IN"."START_DATE_TIME"))<= (SELECT
TRUNC(INTERNAL_FUNCTION("SCHED_HORIZON_END_DATE")) FROM "RLM"."RLM
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"=1197995 AND
NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
19 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
20 - access("HEADER_ID"=1197995)
21 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
22 - access("HEADER_ID"=1197995)
24 - access("LOOKUP_TYPE"='RLM_DETAIL_SUBTYPE_CODE' AND "VIEW_APPLICATION_ID"=
"LOOKUP_CODE"=NVL("A"."ITEM_DETAIL_SUBTYPE","B_IN"."ITEM_DETAIL_SU
PLAN_TABLE_OUTPUT
"LANGUAGE"=USERENV('LANG'))
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
25 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LOOKUP_CODE"=NVL("A"."ITEM_DETAIL_TYPE",'0') AND "LANGUAGE"=USERE
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
27 - access("HEADER_ID"= (SELECT MAX("RSHA"."HEADER_ID") FROM "APPS"."RLM_SCHE
"RSLA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RSHA","APPS"."RLM_SCHEDU
"RLM_SCHEDULE_HEADERS_ALL" WHERE "RSHA"."HEADER_ID"="HEADER_ID" AN
TO_NUMBER("ATTRIBUTE1")=109007290 AND "RSHA"."ECE_TP_LOCATION_CODE
"RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL AND "RSLA"."INVEN
"RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."SHIP_FROM_ORG_ID
("RSLA"."CUST_PO_NUMBER"=:B2 AND EXISTS (SELECT 0 FROM "AR"."HZ_C
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
PLAN_TABLE_OUTPUT
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
32 - filter("RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL)
33 - access("RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989')
34 - filter(TO_NUMBER("ATTRIBUTE1")=109007290)
35 - access("RSHA"."HEADER_ID"="HEADER_ID")
36 - access("RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."INVENTORY_ITEM_I
37 - filter("RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B1 AN
0 FROM "AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PART
"B" WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
41 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
43 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
44 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
AND "B"."LANGUAGE"=USERENV('LANG'))
PLAN_TABLE_OUTPUT
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
48 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
50 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
51 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
AND "B"."LANGUAGE"=USERENV('LANG'))
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
58 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LANGUAGE"=USERENV('LANG'))
filter("SECURITY_GROUP_ID"="FND_GLOBAL"."LOOKUP_SECURITY_GROUP"("LV"."LOO
W_APPLICATION_ID"))
59 - filter("A"."SHIP_FROM_ORG_ID"=2904)
60 - access("A"."ITEM_DETAIL_TYPE"="LOOKUP_CODE" AND "A"."HEADER_ID"=1197995)
filter(TO_NUMBER("A"."ITEM_DETAIL_TYPE")<3)
61 - filter(NVL("B"."INTRMD_SHIP_TO_ID"(+),NVL("A"."INTRMD_SHIP_TO_ID",0))=NVL
O_ID",0) AND "B"."ITEM_DETAIL_SUBTYPE"(+)="A"."ITEM_DETAIL_SUBTYPE
"B"."UOM_CODE"(+)="A"."UOM_CODE" AND NVL("B"."CUST_PO_NUMBER"(+),N
("A"."CUST_PO_NUMBER",'0') AND TRUNC(INTERNAL_FUNCTION("B"."START_
NCTION("A"."START_DATE_TIME")))
62 - filter("HEADER_ID"= (SELECT "HEADER_ID" FROM "APPS"."RLM_SCHEDULE_HEADERS
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"= (SELECT MAX("RSHA"."
"APPS"."RLM_SCHEDULE_LINES_ALL" "RSLA","APPS"."RLM_SCHEDULE_HEADER
PLAN_TABLE_OUTPUT
"RSHA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RLM_SCHEDULE_HEADERS_ALL
"RSHA"."HEADER_ID"="HEADER_ID" AND TO_NUMBER("ATTRIBUTE1")=1090072
"RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989' AND "RSHA"."CUSTOMER_
"RSHA"."SCHEDULE_TYPE"='PLANNING_RELEASE' AND NVL("RSHA"."HEADER_R
"RSLA"."INVENTORY_ITEM_ID"=:B1 AND "RSHA"."HEADER_ID"="RSLA"."HEAD
"RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B2 AN
"AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APP
WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=US
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
63 - filter("A"."SHIP_FROM_ORG_ID"=2904)
64 - filter("B_IN"."CUSTOMER_ITEM_ID"="A"."CUSTOMER_ITEM_ID" AND
"B_IN"."SHIP_FROM_ORG_ID"="A"."SHIP_FROM_ORG_ID" AND TO_NUMBER("B_
TRUNC(INTERNAL_FUNCTION("B_IN"."START_DATE_TIME"))>= (SELECT
TRUNC(INTERNAL_FUNCTION("SCHED_HORIZON_START_DATE")) FROM "RLM"."R
"RLM_SCHEDULE_HEADERS_ALL" WHERE "HEADER_ID"=1197995 AND
NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
PLAN_TABLE_OUTPUT
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
65 - access("B_IN"."INVENTORY_ITEM_ID"="A"."INVENTORY_ITEM_ID" AND
"B_IN"."SHIP_TO_ORG_ID"="A"."SHIP_TO_ORG_ID")
66 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1
',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL(TO_NUMBE
INFO'),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99))
67 - access("HEADER_ID"=1197995)
68 - access("HEADER_ID"= (SELECT MAX("RSHA"."HEADER_ID") FROM "APPS"."RLM_SCHE
"RSLA","APPS"."RLM_SCHEDULE_HEADERS_ALL" "RSHA","APPS"."RLM_SCHEDU
"RLM_SCHEDULE_HEADERS_ALL" WHERE "RSHA"."HEADER_ID"="HEADER_ID" AN
TO_NUMBER("ATTRIBUTE1")=109007290 AND "RSHA"."ECE_TP_LOCATION_CODE
"RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL AND "RSLA"."INVEN
"RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."SHIP_FROM_ORG_ID
("RSLA"."CUST_PO_NUMBER"=:B2 AND EXISTS (SELECT 0 FROM "AR"."HZ_C
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
PLAN_TABLE_OUTPUT
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
73 - filter("RSHA"."CUSTOMER_ID"=64742 AND "RSHA"."SCHEDULE_TYPE"='PLANNING_RE
NVL("RSHA"."HEADER_REF_VALUE_1",'1') IS NOT NULL)
74 - access("RSHA"."ECE_TP_LOCATION_CODE_EXT"='AG-60989')
75 - filter(TO_NUMBER("ATTRIBUTE1")=109007290)
76 - access("RSHA"."HEADER_ID"="HEADER_ID")
77 - access("RSHA"."HEADER_ID"="RSLA"."HEADER_ID" AND "RSLA"."INVENTORY_ITEM_I
78 - filter("RSLA"."SHIP_FROM_ORG_ID"=2904 AND ("RSLA"."CUST_PO_NUMBER"=:B1 AN
0 FROM "AR"."HZ_CUST_ACCOUNTS" "CUST_ACCT","AR"."HZ_PARTIES" "PART
"B" WHERE "B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742) OR NOT EXISTS (SELECT 0 FROM
"CUST_ACCT","AR"."HZ_PARTIES" "PARTY","APPLSYS"."FND_LOOKUP_VALUES
"B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."LANGUAGE"=USERENV(
"B"."MEANING"=SUBSTRB("PARTY_NAME",1,50) AND "CUST_ACCT"."PARTY_ID
"CUST_ACCT"."CUST_ACCOUNT_ID"=64742)) AND "RSLA"."ORG_ID"="RSHA"."
82 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
84 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
85 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
PLAN_TABLE_OUTPUT
AND "B"."LANGUAGE"=USERENV('LANG'))
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
89 - access("CUST_ACCT"."CUST_ACCOUNT_ID"=64742)
91 - access("CUST_ACCT"."PARTY_ID"="PARTY"."PARTY_ID")
92 - access("B"."LOOKUP_TYPE"='ETN_RLM_CHECK_CUST' AND "B"."MEANING"=SUBSTRB("
AND "B"."LANGUAGE"=USERENV('LANG'))
filter("B"."LANGUAGE"=USERENV('LANG') AND "B"."MEANING"=SUBSTRB("PARTY_NA
94 - access("LOOKUP_TYPE"='RLM_DETAIL_SUBTYPE_CODE' AND "VIEW_APPLICATION_ID"=
"LOOKUP_CODE"=NVL("B"."ITEM_DETAIL_SUBTYPE","A"."ITEM_DETAIL_SUBTY
"LANGUAGE"=USERENV('LANG'))
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
95 - access("LOOKUP_TYPE"='RLM_DETAIL_TYPE_CODE' AND "VIEW_APPLICATION_ID"=0 A
"LOOKUP_CODE"=NVL("B"."ITEM_DETAIL_TYPE",'0') AND "LANGUAGE"=USERE
filter("LANGUAGE"=USERENV('LANG') AND "SECURITY_GROUP_ID"="FND_GLOBAL"."L
P"("LV"."LOOKUP_TYPE","LV"."VIEW_APPLICATION_ID"))
Note
- 'PLAN_TABLE' is old version
313 rows selectedPlease suggest me how can I work on the query part to improve the performance.
Thanks
Vishalaksha -
Need help writing Performance Management Report
Hi Experts
I need some help retrieving specific Performance Management data for a report.
I have the employee pernr.
1. From this I need to determine which teams the employee belonged to for the period 1 Oct - 31 Sept.
2. What was the total performance score for the TEAM for that same period.
Can someone please help me out. The table data seems to be quite complex.
Thannks in advance
Anton Kruse
Moderator Message: Specs-dumping is not allowed. Please get back if you have a specific question
Edited by: kishan P on Mar 7, 2012 5:10 PMHi Arnold,
I think the solution provided by Vadim is the only way and it's working.
Shrikant -
Help: Bad performance in marketing documents!
Hello,
When creating an AR delivery note which has about 10 lines, we have really noticed that the creation of lines becomes slower and slower. This especially happens when making tab in the system field "Quantity". In fact, before going to the next field quickly, it stays in Quantity field for about 5 seconds!
The number of formatted searches in AR delivery note is only 5. And only one is automatic. The number of user fields is about 5.
We have heard about the bad performance when the number of lines increases in the documents when having formatted searches, but it is odd to happen this with about 10 lines in the document.
We are using PL16 and this issue seems to have been solved already at PL10.
Could you throw some light on this?
Thanks in advance,It is solved now.
It had to be with the automatic formated search in 2 head fields.
If the automatic search is removed, the performance is OK.
Hope it helps you, -
Need help for performance tunning
Hello,
I have 16K records return by query, it takes long time to proceed for 7K it takes 7.5 sec.
Note: I used all seeded tables only.
If possible please help me to tune it.
SELECT msi.inventory_item_id,msi.segment1,msi.rimary_uom_code , msi.primary_unit_of_measure
FROM mtl_system_items_b msi, qp_list_lines qpll,qp_pricing_attributes qppr,
mtl_category_sets_tl mcs,mtl_category_sets_b mcsb,
mtl_categories_b mc, mtl_item_categories mcb
WHERE msi.enabled_flag = 'Y'
AND qpll.list_line_id = qppr.list_line_id
AND qppr.product_attr_value = TO_CHAR (msi.inventory_item_id(+))
AND qppr.product_uom_code = msi.primary_uom_code
AND mc.category_id = mcb.category_id
AND msi.inventory_item_id = mcb.inventory_item_id
AND msi.organization_id = mcb.organization_id
AND TRUNC (SYSDATE) BETWEEN NVL (qpll.start_date_active,TRUNC (SYSDATE)) AND NVL (qpll.end_date_active,TRUNC (SYSDATE))
AND mcs.category_set_name = 'LSS SALES CATEGORY'
AND mcs.language = 'US'
AND mcs.category_set_id = mcsb.category_set_id
AND mcsb.structure_id = mc.structure_id
AND msi.organization_id = :p_organization_id
AND qpll.list_header_id = :p_price_list_id
AND mcb.category_id = :p_category_id;
Thanks and regards
Akil.Thanks Helios ,
here is answers
Databse version
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit
PL/SQL Release 11.1.0.7.0
explain plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
|
0 | SELECT STATEMENT
| |
1 | 149 | 9439
(1)|
|
1 | NESTED LOOPS | | 1 |
149 | 9439 (1)|
|*
2 | HASH JOIN OUTER | | 1 |
135 | 9437 (1)|
|*
3 | HASH JOIN | | 1 |
71 | 9432 (1)|
|
4 | NESTED LOOPS | | 2 |
76 | 53 (0)|
|*
5 | TABLE ACCESS BY INDEX
ROWID| QP_LIST_LINES | 2 |
44 | 49 (0)|
|*
6 | INDEX SKIP SCAN | QP_LIST_LINES_N2 |
702 | | 20
(0)|
|*
7 | INDEX RANGE SCAN | QP_PRICING_ATTRIBUTES_N3 | 1 |
16 | 2 (0)|
|*
8 | TABLE ACCESS BY INDEX
ROWID | MTL_SYSTEM_ITEMS_B | 46254
| 1490K|
9378 (1)|
|*
9 | INDEX RANGE SCAN | MTL_SYSTEM_ITEMS_B_N9 | 46254 | |
174 (1)|
|
10 | TABLE ACCESS FULL | XX_WEB_ITEM_IMAGE_TBL |
277 | 17728 | 5 (0)|
|* 11 | INDEX RANGE SCAN | MTL_ITEM_CATEGORIES_U1 |
1 | 14 | 2
(0)|
Predicate Information (identified
by operation id):
2 -
access("XWIIT"."IMAGE_CODE"(+)="MSI"."SEGMENT1")
3 -
access("QPPR"."PRODUCT_ATTR_VALUE"=TO_CHAR("MSI"."INVENTORY_ITEM_ID")
AND
"QPPR"."PRODUCT_UOM_CODE"="MSI"."PRIMARY_UOM_CODE")
5 - filter(NVL("QPLL"."START_DATE_ACTIVE",TRUNC(SYSDATE@!))<=TRUNC(SYSDATE@!)
AND
NVL("QPLL"."END_DATE_ACTIVE",TRUNC(SYSDATE@!))>=TRUNC(SYSDATE@!))
6 -
access("QPLL"."LIST_HEADER_ID"=TO_NUMBER(:P_PRICE_LIST_ID))
filter("QPLL"."LIST_HEADER_ID"=TO_NUMBER(:P_PRICE_LIST_ID))
7 -
access("QPLL"."LIST_LINE_ID"="QPPR"."LIST_LINE_ID")
filter("QPPR"."PRODUCT_UOM_CODE" IS NOT NULL)
8 - filter("MSI"."ENABLED_FLAG"='Y')
9 - access("MSI"."ORGANIZATION_ID"=TO_NUMBER(:P_ORGANIZATION_ID))
11 -
access("MCB"."ORGANIZATION_ID"=TO_NUMBER(:P_ORGANIZATION_ID)
AND
"MSI"."INVENTORY_ITEM_ID"="MCB"."INVENTORY_ITEM_ID"
AND
"MCB"."CATEGORY_ID"=TO_NUMBER(:P_CATEGORY_ID))
filter("MCB"."CATEGORY_ID"=TO_NUMBER(:P_CATEGORY_ID))
Note
- 'PLAN_TABLE' is old version
TKprof Plan
TKPROF: Release 11.1.0.7.0 - Production on Fri Nov 15 06:12:26 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: LSSD_ora_19760.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
SELECT msi.inventory_item_id,
msi.segment1,
primary_uom_code,
primary_unit_of_measure,
xwiit.image_url
FROM mtl_system_items_b msi,
qp_list_lines qpll,
qp_pricing_attributes qppr,
mtl_item_categories mcb,
xx_web_item_image_tbl xwiit
WHERE msi.enabled_flag = 'Y'
AND qpll.list_line_id = qppr.list_line_id
AND qppr.product_attr_value = TO_CHAR (msi.inventory_item_id)
AND qppr.product_uom_code = msi.primary_uom_code
AND msi.inventory_item_id = mcb.inventory_item_id
AND msi.organization_id = mcb.organization_id
AND TRUNC (SYSDATE) BETWEEN NVL (qpll.start_date_active,
TRUNC (SYSDATE))
AND NVL (qpll.end_date_active,
TRUNC (SYSDATE))
AND xwiit.image_code(+) = msi.segment1
AND msi.organization_id = :p_organization_id
AND qpll.list_header_id = :p_price_list_id
AND mcb.category_id = :p_category_id
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 3.84 3.85 0 432560 0 1002
total 6 3.84 3.85 0 432560 0 1002
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 173
Rows Row Source Operation
501 NESTED LOOPS (cr=216280 pr=0 pw=0 time=115 us cost=9439 size=149 card=1)
2616 HASH JOIN OUTER (cr=211012 pr=0 pw=0 time=39 us cost=9437 size=135 card=1)
78568 HASH JOIN (cr=210997 pr=0 pw=0 time=3786 us cost=9432 size=71 card=1)
78571 NESTED LOOPS (cr=29229 pr=0 pw=0 time=35533 us cost=53 size=76 card=2)
78571 TABLE ACCESS BY INDEX ROWID QP_LIST_LINES (cr=9943 pr=0 pw=0 time=27533 us cost=49 size=44 card=2)
226733 INDEX SKIP SCAN QP_LIST_LINES_N2 (cr=865 pr=0 pw=0 time=4122 us cost=20 size=0 card=702)(object id 99730)
78571 INDEX RANGE SCAN QP_PRICING_ATTRIBUTES_N3 (cr=19286 pr=0 pw=0 time=0 us cost=2 size=16 card=1)(object id 99733)
128857 TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=181768 pr=0 pw=0 time=9580 us cost=9378 size=1526382 card=46254)
128857 INDEX RANGE SCAN MTL_SYSTEM_ITEMS_B_N9 (cr=450 pr=0 pw=0 time=1657 us cost=174 size=0 card=46254)(object id 199728)
277 TABLE ACCESS FULL XX_WEB_ITEM_IMAGE_TBL (cr=15 pr=0 pw=0 time=22 us cost=5 size=17728 card=277)
501 INDEX RANGE SCAN MTL_ITEM_CATEGORIES_U1 (cr=5268 pr=0 pw=0 time=0 us cost=2 size=14 card=1)(object id 99557)
Note: I modified query and it gives good result, now it takes 3 to 4 sec for 16000 records.
If possible can you plz explain what we have to take care while doing performance tunning
I am a fresher so don't have that much idea.
and also Thanks Hussein for your replay -
Does Global Temporary Table help in performance?
I have a large database table that is growing daily. The application I have has a page for the past day data and another for some chosen period of time. Since I'm looking at a very large amount of data for each page (~100k rows) and having charts based on time, I have performance issues. I tried collections for each of these and found out that it is making everything slower and I think because the collection is large and it is not indexed.
Since I don't need the data to be maintained for the session and in fact for each time that I submit a page I need to get the updated data at least for the past day page, I wonder if Global Temporary Table is a good solution for me.
The only reason I want to store the data in a table is to avoid running similar queries for different charts and reports. Is this a valid reason at all?
If this is a good solution, can someone give me a hint on how to do this?
Any help is appreciated.It all depends on how efficient your query is. You can have a billion row table and still get a fraction of a second response if the data is indexed, and the number of data blocks to be visited to retrieve the data is small. It's all about reducing the number of I/Os to find and retrieve your data with the query. Many aspects of the data, stats, table/index structure etc can influence the efficiency of your query. The SQL forum would be a better place to get into the query tuning, but if this test is fast, you can probably focus elsewhere for now. It will resolve your full resultset, and then just do a count of the result (to avoid sending 100k rows back to the client). We are trying to get an idea of how long it takes to resolve your resultset. Using litterals rather than item names in your sql should be fine for this test. Avoid using V() around item names in your SQL.
select count(*) from ( <your-query-goes-here> ); -
Very urgent-----help in performance tuning
hai all,
I had used inner join for getting data from 5 tables.
performance is very low in this case.
now i want to increase the performance. how can i do this.
coding for the select statement is ......
SELECT agpnr bname1 bname2 bpstlz bort01 bstras b~street2
bname1_maco bname2_maco baliasname bispadrbsnd
INTO CORRESPONDING FIELDS OF TABLE it_tab
FROM jgtgpnr AS a
INNER JOIN jgtsadr AS b ON
aadrnr = badrnr
INNER JOIN jjtvm AS c ON
agpnr = ckunnr
INNER JOIN kna1 AS k ON
agpnr = kkunnr
INNER JOIN knvv AS v ON
agpnr = vkunnr
WHERE ( ajktokd = 'MADV' OR ajktokd = 'MADO' )
AND c~vkorg = pr_vkorg
AND v~vkorg = pr_vkorg
AND gpnr IN so_gpnr
AND k~aufsd IN so_block
AND v~aufsd IN so_blck
please give me a good suggesstion for this.
thanks in advance.Hi
Try to use for all entries
Eg
if u have itab1 and itab2.
select vbeln netwr from vbak into table itab1.
if not itab1[] is initial
select vbeln matnr matkl from vbap into table itab2
for all entries in itab1 where vbeln = itab1-vbeln.
endif.
Hope this will help u.
regards
P.Thangaraj -
Pls help in performance tuning SQL
Hi All,
Can someone please help me to tune this quesry. Rt now it is takin 20 mins tro retuns 80,000 rows and its using dblink
SELECT COUNT(*) FROM
(SELECT /*+driving_site(main)*/CORP_ACTG_PRD_YEAR,
CORP_ACTG_PRD_NBR,
FCN_CODE,
LOCAL_CRNC_CODE,
GL_LOCAL_AMT,
CORP_ID,
PGRD_COST_CTR_ID,
MAJOR_CODE,
EXP_MINOR_CODE,
PGRD_EXP_CODE,
PGRD_EXP_DESC,
DIV_CODE,
MKT_CODE,
PROD_CODE,
PGRD_PROJECT_CODE,
PGRD_PROJ_SHORT_DESC
FROM --#GifDBLink# main,
[email protected] main,
select actg_prd_year, actg_prd_nbr from DM_GIF_ESSBASE_CTRL
where cur_prd_ind='Y' and src_id=84
union
select decode(actg_prd_nbr,1,actg_prd_year-1,actg_prd_year) actg_prd_year,
decode(actg_prd_nbr,1,12,actg_prd_nbr-1) actg_prd_nbr
from DM_GIF_ESSBASE_CTRL
where cur_prd_ind='Y' and src_id=84
union
select decode(actg_prd_nbr,12,actg_prd_year+1,actg_prd_year) actg_prd_year,
decode(actg_prd_nbr,12,1,actg_prd_nbr+1) actg_prd_nbr
from DM_GIF_ESSBASE_CTRL
where cur_prd_ind='Y' and src_id=84 ) minor
where main.CORP_ACTG_PRD_YEAR = minor.actg_prd_year
and main.CORP_ACTG_PRD_NBR = minor.actg_prd_nbr) T;user13365939 wrote:
anyone?Incorrect.
You are only one who can provide the information that was requested in this thread.
Please see the FAQ, read the instructions and provide the necessary information.
Re: 3. How to improve the performance of my query? / My query is running slow. -
Need help in Performance tuning
Hi All,
I am facing some performance issues in my program. The program taking a hell lot of time to execute and some times timing out without giving the out put. This is a report program with ALV output. It is handling mainly Sales related data.
The program is fetching a huge volume of data from different tables and processing this bulk data inside the loops several times. In most of the queries I am unable to supply all key fields, because my requirement is like that only. I have many places in my program i am using inner loop and function modules inside loop etc.
Any pointers on this will be a great help.
Regards,
Jijeesh P G1) Make sure that any READ or LOOP inside an outer LOOP accesses the inner table with an appropriate key (either using BINARY search when reading a standard table or using sorted/hashed tables for inner tables only). This helps in most cases.
2) If the tables witdh is more than aprox. 30 bytes LOOP ASSIGNING <wa> may help a bit. Declare <wa> for each table separately using the tables line type (otherway type casting would cost some additional time).
3) You may use FM SAPGUI_PROGRESS_INDICATOR in the outer loops to inform the user while he is waiting.
4) A COMMIT from time to time will reset the measured time for timeout ( and therefore avoids timeouts - do NOT use without checking step 1) ).
4) The programm may use virtual memory if a huge amount of data is selected ( I have seen dumps in due to the fact that nor more disk space was available). So - if STEPS 1)-3) failed - look a the process for rollling in/out). -
Hi Gurus,
I m new to the group and SAP BW as well,so i need ur valuable inputs for a Performance related Project.
I m going to start a new project in a wks time so and i m working as a Performance Tuning Consultant on that(Load & Query Performance),but i don't have any idea about this,so i need ur valuable advice on that,plz.
Can anyone plz suggest me the possible ways of suggestions so that i can tell the client as a gud consultant to start with but these days i m going though BW Performance & Authorization(BW360) which is really helpful for me but apart from that i need ur valuable inputs as well.
Thanks in Advance.
regards
Amithi Amit,
check this.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
also
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/10b589ad-0701-0010-0299-e5c282b7aaad
regards. -
How application module helps for performance improve
Hi Everyone,
I have a sample web-application in which I am connecting with single AM instance (AM for database view object), retrieving some information and then close the connection. I am doing this as,
// making AM instance
<application module instance> = Configuration.createRootApplicationModule(<AM name>, config);
// performing operations
<operation result> = <application module instance>.<access VO with any operation>();
System.out.println("Get result here");
// disconnecting AM instance
<application module instance>.getDBTransaction().disconnect();
Configuration.releaseRootApplicationModule(<application module instance>, true);
These are the activities which are performed by a single user. Now, I am doing stress test on same activities. I am testing the same code with 300 concurrent users (using JMeter with JSP URL). These are working fine. Also I checked multiple times, it always working fine.
Now, I need to do something through which I can improve the performance. I know, I can use AM pool configurations to make this more effective. I have gone through the Oracle documents and checked the same test case with default or recommended pool configurations and I found similar kind of results (there is not much difference).
On other hand, I tried with 'releaseRootApplicationModule' method with false parameter and found better results in default as well as recommended pool configurations.
My question is, is the change of pool configurations recommended by Oracle really work? or do I need to concentrate more on coding part with default pool configurations?
Here, I would like to know, what are the best practice (in code as well as pool configurations), I need to follow if I really want to improve the performance in real scenarios (when our application will access with large no. of concurrent users).
I really look forward some help from experts. I have given a lot of time on this to know how really we can make our application more effective in terms of performance.
I really appreciate for your reply.
Regards,
Dilip Gupta.>
We added the createRootApplicationModule() API (in the oracle.jbo.client.Configuration class) to simplify acquiring an application module from the pool for brief programmatic manipulation before it is released back to the AM pool.
Steve Muench.
>
check [url http://radio-weblogs.com/0118231/2009/08/20.html#a959]Check Your App for Misuse of Configuration.createRootApplicationModule()
Edited by: Mohammad Jabr on May 10, 2012 7:14 AM
Maybe you are looking for
-
Hi Experts, My requirement is MIS status report. The scenario is like, 1.we have a few industry practices like Health care, telecoms it services - 2.in the same way we have technical practices like sap. java. .net (the same will be utilized to for
-
Macbook Pro screen damage - dust melted in
Hi I used my Macbook Pro retina intensively and it gets hot. I also use it on location all the time so it's subject to dust. I have a brush and I always make sure thats it's dusted down. Today I cleaned my screen and noticed that there is what looks
-
I purchased a HP Pavillion a6700f with Vista last month and tried to hook up my four year old self powered Boston Acoustic 735 digital speakers to it. It uses a single analog line that I plugged into the green jack on the back of the computer as in
-
Why can't I print on my Epson printer?
Why can't I print on my Epson wireless printer?
-
DVD...?
I have a nioce iDVD Project with video and sound which I'd like to get into my Apple TV. I can't figure it out. I cannot make a QTime of it ...so what should I do. Is this typical with any i