Hi,
I am updating transaction file (around 7 lacs records) with member id from the member master table (has around 20K records).
To update the member id, using a key which is combination of code & member name.
Though the matching records in the transaction table is only about 15000, it takes about 5-6 hours to update.
I have the index key in place.
The query used is given below, I have tried using 2 different ways of updating the data but have same issue.
One is thru the loop & another is direct update. Can someone please let me what & where is the issue & why its taking time for update.
The SQL is given below:
-----------------
# 1:
update t_samrat2_trn x
set x.samrat2_trn_dlr_cd = (select h.samrat_mrg_parent_cd
from t_samrat_mbr_merge h
where upper(x.samrat2_trn_key) = upper(h.samrat_mrg_key)
and upper(h.samrat_mrg_f_a) = 'Y'
and (h.samrat_mrg_year * 100 + h.samrat_mrg_month) = (p_proc_yr * 100 + p_proc_mn)
and (x.samrat2_trn_pr_yr * 100 + x.samrat2_trn_pr_mn) = (p_proc_yr * 100 + p_proc_mn)
and upper(trim(x.samrat2_trn_region)) = upper(p_proc_rg)
and x.samrat2_trn_dlr_cd is null)
where exists (select h.samrat_mrg_parent_cd
from t_samrat_mbr_merge h
where upper(x.samrat2_trn_key) = upper(h.samrat_mrg_key)
and upper(h.samrat_mrg_f_a) = 'Y'
and (h.samrat_mrg_year * 100 + h.samrat_mrg_month) = (p_proc_yr * 100 + p_proc_mn)
and (x.samrat2_trn_pr_yr * 100 + x.samrat2_trn_pr_mn) = (p_proc_yr * 100 + p_proc_mn)
and upper(trim(x.samrat2_trn_region)) = upper(p_proc_rg)
and x.samrat2_trn_dlr_cd is null)
---------------
# 2
for cur_mbrup in (select t.samrat2_trn_key,
a.samrat_mrg_key,
a.samrat_mrg_parent_cd
from t_samrat2_trn t,
t_samrat_mbr_merge a
where upper(trim(t.samrat2_trn_region)) = upper(p_proc_rg)
and (t.samrat2_trn_pr_yr * 100 + t.samrat2_trn_pr_mn) = (p_proc_yr * 100 + p_proc_mn)
and upper(t.samrat2_trn_key) = upper(a.samrat_mrg_key)
and (a.samrat_mrg_year * 100 + a.samrat_mrg_month) = (p_proc_yr * 100 + p_proc_mn)
and upper(a.samrat_mrg_f_a) = 'Y'
and t.samrat2_trn_dlr_cd is null
order by t.samrat2_trn_key,
a.samrat_mrg_key,
a.samrat_mrg_parent_cd)
loop
update t_samrat2_trn x
set x.samrat2_trn_dlr_cd = cur_mbrup.samrat_mrg_parent_cd
where upper(trim(x.samrat2_trn_key)) = upper(trim(cur_mbrup.samrat_mrg_key))
and x.samrat2_trn_pr_yr * 100 + x.samrat2_trn_pr_mn = (p_proc_yr * 100 + p_proc_mn)
and upper(trim(x.samrat2_trn_region)) = upper(p_proc_rg) ;
commit;
end loop;
------------------------------
TIA,
Raj
I am updating transaction file (around 7 lacs records) with member id from the member master table (has around 20K records).
To update the member id, using a key which is combination of code & member name.
Though the matching records in the transaction table is only about 15000, it takes about 5-6 hours to update.
I have the index key in place.
The query used is given below, I have tried using 2 different ways of updating the data but have same issue.
One is thru the loop & another is direct update. Can someone please let me what & where is the issue & why its taking time for update.
The SQL is given below:
-----------------
# 1:
update t_samrat2_trn x
set x.samrat2_trn_dlr_cd = (select h.samrat_mrg_parent_cd
from t_samrat_mbr_merge h
where upper(x.samrat2_trn_key) = upper(h.samrat_mrg_key)
and upper(h.samrat_mrg_f_a) = 'Y'
and (h.samrat_mrg_year * 100 + h.samrat_mrg_month) = (p_proc_yr * 100 + p_proc_mn)
and (x.samrat2_trn_pr_yr * 100 + x.samrat2_trn_pr_mn) = (p_proc_yr * 100 + p_proc_mn)
and upper(trim(x.samrat2_trn_region)) = upper(p_proc_rg)
and x.samrat2_trn_dlr_cd is null)
where exists (select h.samrat_mrg_parent_cd
from t_samrat_mbr_merge h
where upper(x.samrat2_trn_key) = upper(h.samrat_mrg_key)
and upper(h.samrat_mrg_f_a) = 'Y'
and (h.samrat_mrg_year * 100 + h.samrat_mrg_month) = (p_proc_yr * 100 + p_proc_mn)
and (x.samrat2_trn_pr_yr * 100 + x.samrat2_trn_pr_mn) = (p_proc_yr * 100 + p_proc_mn)
and upper(trim(x.samrat2_trn_region)) = upper(p_proc_rg)
and x.samrat2_trn_dlr_cd is null)
---------------
# 2
for cur_mbrup in (select t.samrat2_trn_key,
a.samrat_mrg_key,
a.samrat_mrg_parent_cd
from t_samrat2_trn t,
t_samrat_mbr_merge a
where upper(trim(t.samrat2_trn_region)) = upper(p_proc_rg)
and (t.samrat2_trn_pr_yr * 100 + t.samrat2_trn_pr_mn) = (p_proc_yr * 100 + p_proc_mn)
and upper(t.samrat2_trn_key) = upper(a.samrat_mrg_key)
and (a.samrat_mrg_year * 100 + a.samrat_mrg_month) = (p_proc_yr * 100 + p_proc_mn)
and upper(a.samrat_mrg_f_a) = 'Y'
and t.samrat2_trn_dlr_cd is null
order by t.samrat2_trn_key,
a.samrat_mrg_key,
a.samrat_mrg_parent_cd)
loop
update t_samrat2_trn x
set x.samrat2_trn_dlr_cd = cur_mbrup.samrat_mrg_parent_cd
where upper(trim(x.samrat2_trn_key)) = upper(trim(cur_mbrup.samrat_mrg_key))
and x.samrat2_trn_pr_yr * 100 + x.samrat2_trn_pr_mn = (p_proc_yr * 100 + p_proc_mn)
and upper(trim(x.samrat2_trn_region)) = upper(p_proc_rg) ;
commit;
end loop;
------------------------------
TIA,
Raj