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.

19 comments:

  1. Good tutorial. Good your describe

    ReplyDelete
  2. thanks, good describing.

    ReplyDelete
  3. 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

    ReplyDelete
  4. 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 ?

    ReplyDelete
  5. Good Description .

    ReplyDelete

  6. 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

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

    English Speaking Course online
    Online Spoken English Classes

    ReplyDelete
  8. 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

    ReplyDelete
  9. 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

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

    ReplyDelete
  11. I really appreciate your insights on optimizing SQL performance with the DRIVING_SITE hint! Your clear explanation of the scenario and the example helped me understand it better. Thanks for sharing such valuable tips for Oracle administration!

    online internship | internship in chennai | online internship for students with certificate | bca internship | internship for bca students | sql internship | online internship for btech students | internship for 1st year engineering students

    ReplyDelete
  12. Thanks for taking the time to share with us such a great article. I appreciate your work. Latest AI technology course in Coimbatore, 100% job-placement guaranteed.

    ReplyDelete
  13. It is so nice article thank you for sharing this valuable content. Devops course near me

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. It was a very useful information. https://www.kanan.co/classroom/ielts-coaching-in-bangalore/

    ReplyDelete