Oracle SQL performance with database
links - db link
Oracle Database Tips by Donald Burleson
are some of the performance issues when running SQL across a database link (dblink)?
the limiting factor in SQL performance of a distributed query (over a db-link)
is the speed of the network (make sure that you have a high-speed network with
proper SDU), but there are other issues:
- tnsnames.ora -
Some recommend a separate listener and a larger value for SDU to
accommodate jumbo Ethernet frames.
"By using a separate listener for the gigabit network with a larger
SDU - you can better exploit jumbo Ethernet frames. beware -
interoperability just plain sucks."
- Pull vs. Push - In
general, performance can be faster if you "pull" the data (calling the
remote table from the master instance), as opposed to a "push" where you
perform the join on the remote table. This is especially true of you
have a large sort, because the rows may be transferred to the remote host
for sorting, and then back again afterwards.
- driving_site hint -
The driving site hint forces query execution to be done at a
different site than the initiating instance. This is done when the
remote table is much larger than the local table and you want the work
(join, sorting) done remotely to save the back-and-forth network traffic.
n this example, we use the driving_site hint to force the "work" to
be done on the site where the huge table resides:
t.deptno = h.deptno;
Note: The driving_site hint will not work with CTAS
(create table as select) and with create materialized view syntax because
they are DDL and these operations must take place on the original instance.
- Views - Some
recommend creating a view on the remote site referencing the local tables
and calling the remote table via the local view.
create view local_cust
as select * from cust@remote;
You can get the same effect
by using an inline view:
SELECT /*+ DRIVING_SITE(a) */
FROM (SELECT stuff FROM emp@remote) a
Alberto Dell'Era notes this tip for distributed query parallelism:
some problems myself while mixing db-links and parallel operations; i
solved them perfectly by creating a view at the remote site with the
same text as the query, and then performing a "select *" from the view.
Also, note that there are many hidden parameters that influence OPQ
performance (always consult Oracle technical support before changing an
Monitoring parallel query for
remote distributed queries is also challenging.
If you like Oracle tuning, you may enjoy the new book "Oracle
Tuning: The Definitive Reference", over 900 pages
of BC's favorite tuning tips & scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts.