db link issue
Hi,
I got an issue about db link, please help!
The belowing sql 1 takes more than 10 min, but sql 2 only needs about 20 sec.
--sql 1----------
with with_table as (
select person_id,attribute1,in_date from person_table@dblink1 t1
union all
select person_id,attribute1,in_date from person_table@dblink2 t2
)
select cp_list.attribute1,sys_in.person_num,yes_in.person_num
from
(select distinct attribute1 from with_table) cp_list,
(select attribute1,count(person_id) person_num from with_table where in_date=trunc(sysdate) group by attribute1) sys_in,
(select attribute1,count(person_id) person_num from with_table where in_date=trunc(sysdate)-1 group by attribute1) yes_in