Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004

    Question Unanswered: LIKE is considered awful from performance point of view?

    Hi all,
    first of all I shoud mention it that I have posted a similar question in Oracle forum and recieve enough oracle-related feedback and solution, here.

    Now I want to know if LIKE searches are awful (performance wise) in SQL Server too, do you recommand any solution to enhance it by some indexing twick? I want to avoid using MS index service (if I spell it correctly) as far as I could

    Note: We have a lot of LIKE '%abc%' queries at this system.

    -Thanks in advance for your time and help

  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    hows this go again?

    sql will use an index if the like is like this...

    where fieldA like 'A%'

    but not if it is like this

    where fieldA like '%A'

    and not like this either...

    where fieldA like '%A%'
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Nov 2002
    Go Google Stage 2 Predicates or NonSargable queries

    It doesn't matter the platform, the concept is all the same

    You will get a scan regardless

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Jun 2003
    Provided Answers: 1
    Quote Originally Posted by Ach
    LIKE is considered awful from performance point of view?
    That's really an unfair way of portraying it. I mean, an Appendectomy is undesirable until the day you get appendicitis. Sometimes LIKE is the only way to go, and sometimes it is the best way to go. If possible, try to filter by additional columns that will use indexes prior to applying LIKE.
    If it's not practically useful, then it's practically useless.

    blindman "sqlblindman"

Posting Permissions

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