Performance in Oracle insert to table from select with function calls

190 Views Asked by At

I am writing a query to calculate some values and save them onto a table on a periodic basis. The values I needs are being returned from a function call.

These values need to be saved on to a table, and I have a dbms schedule job to insert these to a table. The job executes the following;

BEGIN
execute immediate 'truncate table tbl1';
INSERT /*+ append*/ INTO tbl1(v1, v2, v3, v4)
SELECT
    function1(input), 
    function2(input),
    function3(input),
    SYSDATE
FROM tbl;
END;

The scheduled jobs runs for over 8 hours, for over 500k records! I understand the logic int he functions are time consuming, and there is the context switching in selecting from functions. Is there another way for me to achieve this, with better performance?

I am on Oracle 12c. Are there any suggestions on how I can make this job run faster?

1

There are 1 best solutions below

0
On

Is the function complex ?

If not, can't the function be called after each insert into tbl and store the result in a new column ? So when the job is called, the function1, 2 and 3 are replaced by the colmuns where the value is stored.