Query Performance is low with single function
790469Nov 19 2010 — edited Nov 19 2010Hi all,
I neetd to calculate the net salary of around 2000 employees.i use function to get it from payrun tables
i.e..
CREATE OR REPLACE function xxri_total_net(p_date IN VARCHAR2,p_empno IN NUMBER)
return number
as
v_earn number;
v_ded number;
begin
select nvl(sum(result_value),0)
into
v_earn from xxgod_soe_test where employee_number=p_empno
and base_classification_name='Earnings' and
to_char(date_earned,'MON-YYYY')=p_date and base_name='Pay Value';
select nvl(sum(result_value),0)
into v_ded from xxgod_soe_test where employee_number=p_empno
and base_classification_name like '%Deductions%' and
to_char(date_earned,'MON-YYYY')=p_date and base_name='Pay Value';
return v_earn-v_ded;
end;
It works fine with 10 sec as execution time,
but when i add it to my reports query it goes slow..
i m adding it as column,
xri_total_net(TO_CHAR(pAaV.effective_date,'MON-YYYY'),papf.employee_number) Net_Salary,
i even tried xri_total_net(TO_CHAR(:p_start_date,'MON-YYYY'),papf.employee_number) Net_Salary,
Kindly help me out to reduce the execution time.
Thanks,
Techie.