连接两个远程表,比连接两个本地表要昂贵的多!所以建议先在远程环境做好连接后,在远程的机器上建立一个视图,我们本地再访问这个视图。原因是用视图封装以后,数据操作在远程就做了,不用传输到本地再作处理,减少了数据传输。
SQL太长,只显示结果10046跟踪的结果。
1.在远程数据库上建视图用时: 00: 00: 35.73
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 3847 1.90 10.13 0 0 0 57677
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3849 1.90 10.14 0 0 0 57677
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to dblink 3849 0.00 0.00
SQL*Net message from dblink 3849 0.05 7.15
SQL*Net more data from dblink 8684 0.00 0.78
SQL*Net message to client 3847 0.00 0.00
SQL*Net more data to client 8889 0.00 0.09
SQL*Net message from client 3847 0.01 25.25
********************************************************************************
2.直接在本地连表查询用时: 00: 00: 38.56
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.07 0 0 0 0
Execute 1 0.01 0.00 0 0 0 0
Fetch 3847 1.17 12.36 0 0 0 57677
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3849 1.18 12.44 0 0 0 57677
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to dblink 3847 0.00 0.00
SQL*Net more data to dblink 1 0.00 0.00
SQL*Net message from dblink 3847 0.01 9.39
SQL*Net more data from dblink 8683 0.00 0.81
SQL*Net message to client 3847 0.00 0.00
SQL*Net more data to client 8889 0.00 0.09
SQL*Net message from client 3847 0.01 25.75
********************************************************************************