0

we are writing a query in oracle which needs to gets data from joining two tables which are in different databases located on different servers.

For this, we are using Dblinks in the query . But, this is causing the query to execute very slowly.

Is there any other way to do it instead of using Dblinks?

3
  • 1
    The only other solution is to keep a copy of the table on the "other" server (e.g. automatically refreshed using a materialized view) Commented May 22, 2014 at 11:09
  • It would be great, if you can eloborate please Commented May 22, 2014 at 11:18
  • docs.oracle.com/cd/E11882_01/server.112/e10706/… Commented May 22, 2014 at 11:21

1 Answer 1

0

Of course, a materialized view (as proposed) would solve your problem. But sometimes MV's are to expensive. I wonder, if you could use a "with statement" referencing the remote DB Table.

The actual Select statement then uses this with statement once and must be build from inside out like this:

with XXX as (
Select stuff from foo_table@bar_link
)

select * from XXX left join your_local_table using (your key)

If your Oracle is configured correctly, it should execute the "expensive" part of loading foreign data only once. So you spare the DB-Drivespace for a MV... Give it a try! It is important to do NOT use stuff from your remote DB in the Where statement. Because then sometimes, your remote DB is queried every row your are checking in the where clause...

Good luck

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.