Question

Some vendor told us that we should not use database link between our database and theirs as the queries executed over a database link would not be cached, nor optimized.

I can't find any information confirming/infirming this.

Naively I would not see why Oracle would not be able to do query caching when using a db link.

Was it helpful?

Solution

There are some restrictions with database links. You can't execute DDL remotely for example.

Queries run against remote tables are not processed in exactly the same way as regular tables:

The local Oracle Database server breaks the distributed query into a corresponding number of remote queries, which it then sends to the remote nodes for execution. The remote nodes execute the queries and send the results back to the local node. The local node then performs any necessary post-processing and returns the results to the user or application.

In most cases, the breaking process is adequate and you will just get the expected overhead of the database link (network delay between the databases, two query analyses/processing instead of one, etc..). The remote subqueries will be treated as normal queries by the remote database and the data will get into the remote cache as with regular queries.

You might get into performance problems if you attempt to join a local table to a remote table (or tables from two distinct db links) since the data has to be carried to a single database to perform the join. In that case, you might want to change the breaking up process (for example performing a complex join in a remote database instead of the local database).

The documentation details a number of ways you can tune distributed queries.

OTHER TIPS

A distributed query cannot be optimized in the same way that local tables can, however, distributed queries are optimized and caches, therefore the vendor is incorrect.

You can see this by running something like the following. You will see the execution count rise with each run.

SELECT /* 23409268-09389 */ * FROM schema_name.table_name@db_link WHERE rownum<=1;
SELECT Executions, sql_text FROM v$sql WHERE sql_text LIKE 'select /* 23409268-09389%';

My guess is that the vendor wants their data accessed through web services and any joins with the data from your own database to be done in an application layer. The performance of such a configuration would likely be vastly inferior to a join over a database link even if it were not cached.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top