How to write a hint in nest select
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: How to write a hint in nest select

  1. #1
    Join Date
    Jan 2001
    Posts
    2

    Talking

    A SQL like this

    select T1.column1 , ....
    from T1
    where T1.a not in
    (select T2.b from T2 where ....)


    The explain shows a full table scan on T2 . And I want to
    use a hint to force a index range scan on T2 . How to write ?

    Thanks for your time

  2. #2
    Join Date
    Jun 2000
    Location
    Hammersmith, London
    Posts
    20
    Jackil

    All you need to do is creating an index on t2.b and modify the where class to include t2.b = t1.a. This will ensure the usage of index on table T2.

    Raj

  3. #3
    Join Date
    Aug 2000
    Location
    Shanghai
    Posts
    433
    In fact , it's not possible to convert "not in " to a "=" cause.
    Anyway , I have successfully make these query using index on T2 . But what I want to know is just the syntax of
    writing a hint in the nest select statement
    thansk

  4. #4
    Join Date
    Nov 2000
    Posts
    212
    what about:

    select /*+INDEX(T2 T2_IDX) */
    T1.column1 , ....
    from
    where T1.a not in
    (select T2.b from T2 where ....)



  5. #5
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Well, if you realy have an index on T2.b, then much more efficient way for your query would be:

    select T1.column1 , ....
    from T1
    WHERE NOT EXISTS
    (SELECT null FROM T2 WHERE T2.b=T1.a);
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width