Hi Tom,
I have a problem following
I have 2 database at 2 different site and my job is transfer user a scheduler job at site B, pulling data from site A via dblink_b2a. about 14m records/day
when I execute single statement:
insert /*+ append */ into table_b
from select * from table_b@dblink_b2a
where condition >= v_start_time
and condition < v_end_time
;=> duration time about 15-20 minutes
But when I put it in procedure and run scheduler job, it ran very slowly ~15 hours and not completed yet.
My sample procedure:
create or replace procedure transfer_Data
as
v_start_time date := trunc(sysdate - 1);
v_end_time date := trunc(sysdate);
begin
insert /*+ append */ into table_b
from select * from table_b@dblink_b2a
where condition >= v_start_time
and condition < v_end_time
;
end; Please tell me reasons and advises for this case
Hope your responding as soon as you can
Thank you and best regards!
How did you run
insert /*+ append */ into table_b
from select * from table_b@dblink_b2a
where condition >= v_start_time
and condition < v_end_time ;directly in SQL? Did you use literal values for the start and end times? That is the most likely difference.
But since PLSQL will uppercase any SQL, you should have two SQL's in your library cache
- lower case one - the one you ran from SQL
- upper case one - the one you ran from PLSQL
For each one, get the SQL_ID and then get the execution plan using DBMS_XPLAN.
That will tell you if the plans were different (which could easily explain the difference in performance)