Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to change the table access order?

989009Mar 20 2013 — edited Mar 21 2013
I am using oracle 10g 10.2.0.3.0

I have a select statement
SELECT /*+ leading v.Guest_Info v.Guest_Domain_Relation Guest_Address*/
*
  FROM (SELECT 
         Cdr.Guest_Domain_Relation_Id,
         Ci.Guest_Id        
          FROM Guest_Info         Ci,
               Guest_Domain_Relation Cdr
         WHERE Ci.Guest_Id = Cdr.Guest_Id) v,
       Guest_Address Ca
 WHERE v.Guest_Id = Ca.Guest_Id;
and Explain Plan shows
1	Plan hash value: 3785964411
2	 
3	---------------------------------------------------------------------------------------------------------
4	| Id  | Operation                     | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
5	---------------------------------------------------------------------------------------------------------
6	|   0 | SELECT STATEMENT              |                         |  1806 |   199K|     9  (23)| 00:00:01 |
7	|*  1 |  HASH JOIN                    |                         |  1806 |   199K|     9  (23)| 00:00:01 |
8	|   2 |   MERGE JOIN                  |                         |   482 | 48682 |     6  (17)| 00:00:01 |
9	|   3 |    TABLE ACCESS BY INDEX ROWID| Guest_ADDRESS          |   919 | 87305 |     4   (0)| 00:00:01 |
10	|   4 |     INDEX FULL SCAN           | XAK1Guest_ADDRESS      |   919 |       |     1   (0)| 00:00:01 |
11	|*  5 |    SORT JOIN                  |                         |   482 |  2892 |     2  (50)| 00:00:01 |
12	|   6 |     INDEX FULL SCAN           | XPKGuest_INFO          |   482 |  2892 |     1   (0)| 00:00:01 |
13	|   7 |   VIEW                        | index$_join$_003        |  3493 | 41916 |     3   (0)| 00:00:01 |
14	|*  8 |    HASH JOIN                  |                         |       |       |            |          |
15	|   9 |     INDEX FAST FULL SCAN      | XAK1Guest_DOMAIN_Relation |  3493 | 41916 |     1   (0)| 00:00:01 |
16	|  10 |     INDEX FAST FULL SCAN      | XPKGuest_DOMAIN_Relation  |  3493 | 41916 |     1   (0)| 00:00:01 |
17	---------------------------------------------------------------------------------------------------------
18	 
19	Predicate Information (identified by operation id):
20	---------------------------------------------------
21	 
Is there Anyway I can have Guess_Domain_Relation table join to Guest_info table first than join to Guess_Address?

I have tried couple ways to rewrite the query however it came out no luck

Thanks

Edited by: Y.L on Mar 20, 2013 1:59 PM
This post has been answered by riedelme on Mar 21 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 18 2013
Added on Mar 20 2013
11 comments
273 views