DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Query using LIKE

  1. #1
    Join Date
    Aug 2007
    Posts
    62

    Query using LIKE

    Hi,

    I've read that using LIKE clause in the where query will inhibit index usage on the column.

    E.g.
    select * from ABC
    where id like 'bc12%' and country='US';

    If i have the above query and an index on column id, the query will not use the index. To allow index usage, the full id should be typed in the query. However, this will add to the inconvenience of end users as they will have to typed in the full id.

    Is there any way which i can reduce the cost of having LIKE query?

    Greatly appreciate it if you can show me a link or 2. Thanks in advance!

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    it will use an index if appropriate

  3. #3
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    now where did you read that? (i am sure it will have adjuncts and you may have missed that)
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  4. #4
    Join Date
    Aug 2007
    Posts
    62
    Do you mean to say that for
    select * from ABC
    where id like 'bc12%' and country='US';

    if i have a query which is long enough e.g. id like 'bc123%' as compared to 'bc%' (when the full id is 'bc12345d'), the query can actually use the index in the first case?

  5. #5
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    it will use the index if appropriate in all cases

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