Wednesday, February 11, 2009

DRIVING_SITE SQL Hint

We all are know about Oracle Data Base Link and I called it dblink in short throughout this article. Usisg dblink you can easily access remote Database Object. Now Please think the following situation:

Situation:

Suppose you have 2 tables: 1. table1 in local DB 2. table2 in remote DB.The table1 size is 10 MB and table2 size is 100 MB. We need to join those two tables and we access only in local DB.

If you now think about performance, it is important to where the sql query executed and the join perform. For above situation, it is better to bring table1 from local DB to Remote DB and execute the sql in remote server and finally bring back the result in local DB.

Lets do the job

The DRIVING_SITE hint forces query execution to be done at a different site than that selected by Oracle. This hint can be used with either rule-based or cost-based optimization. The syntax of this hint is:

/*+DRIVING_SITE(table)*/

where table is the name or alias for the table at which site the execution should take place.

Example:

SELECT /*+DRIVING_SITE(table2)*/ * FROM tabl1, table2@remote_db
WHERE table1.DEPTNO = table2.DEPTNO;

If this query is executed without the hint, rows from table2 will be sent to the local site and the join will be executed there. With the hint, the rows from table1 will be sent to the remote site and the query will be executed there, returning the result to the local DB.

14 comments:

SURDET said...

Good tutorial. Good your describe

Anonymous said...

thanks, good describing.

Tani said...

Very Good post on Oracle Data Base Link. Simple and clear even begainer can understand it easily.Keep sharing this type of content which is full of knowledge.

oracle r12 new features

Anonymous said...

TRUNCATE TABLE scott.table1;
INSERT /*+APPEND*/ INTO SCOTT.table1 SELECT /*+DRIVING_SITE(h)*/ * FROM SCOTT.table1@hrremote_publink h;

how it's useful for the above table insert from remote db link ?

Anonymous said...

Good Description .

sasi said...


Superb! Your blog is incredible. I am delighted with it. Thanks for sharing with me more information.
Hadoop Training in Chennai
Hadoop Training in Bangalore
Big Data Course in Coimbatore
Big data training in chennai
Big Data Course in Chennai
Big Data Training in Coimbatore
Angularjs Training in Bangalore
web designing course in madurai

Jaya said...


Such a great blog.Thanks for sharing.........
IELTS Coaching in Hyderabad
IELTS Coaching in Bangalore
IELTS Coaching in Pune
IELTS Coaching in Gurgaon
IELTS Coaching in Delhi

hema said...


Great Post with valuable information. I am glad that I have visited this site. Share more updates.

Spoken English Classes in Anna Nagar
Spoken English Classes in Medavakkam
Spoken English Classes in Chennai

jeya sofia said...

Excellent Blog, I like your blog and It is very informative. Thank you

English Speaking Course online
Online Spoken English Classes

nayar said...

Great post.Thanks for sharing such a worthy information...
Python Training in Bangalore
Python Classes in Pune
Python Training in Hyderabad
Python Classes in Gurgaon

sam said...

This is a fabulous post I saw because of it. It is really what I expected to see trust in future you will continue in sharing such a mind boggling post

Best PTE institute in ambala
PTE Coaching in ambala
Best IELTS Institute in Ambala

Niyaz said...

Awesome article! You are providing us very valid information. This is worth reading. Keep sharing more such articles.
why become a data scientist
why data science

Reshma said...

Great post. Thanks for sharing.....
RPA Training in Bangalore
RPA Course in Bangalore

Anonymous said...

Thanks for sharing very important information, keep us posted more Python Training in Nanded
Best IT Training Provider