Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 659765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:04:53+00:00 2026-05-13T23:04:53+00:00

If your goal is to test if a string exists in a MySQL column

  • 0

If your goal is to test if a string exists in a MySQL column (of type ‘varchar’, ‘text’, ‘blob’, etc) which of the following is faster / more efficient / better to use, and why?

Or, is there some other method that tops either of these?

INSTR( columnname, 'mystring' ) > 0

vs

columnname LIKE '%mystring%'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:04:54+00:00Added an answer on May 13, 2026 at 11:04 pm

    FULLTEXT searches are absolutely going to be faster, as kibibu noted in the comments above.

    However:

    mysql> select COUNT(ID) FROM table WHERE INSTR(Name,'search') > 0;
    +-----------+
    | COUNT(ID) |
    +-----------+
    |     40735 | 
    +-----------+
    1 row in set (5.54 sec)
    
    mysql> select COUNT(ID) FROM table WHERE Name LIKE '%search%';
    +-----------+
    | COUNT(ID) |
    +-----------+
    |     40735 | 
    +-----------+
    1 row in set (5.54 sec)
    

    In my tests, they perform exactly the same. They are both case-insensitive, and generally they perform full-table scans, a general no-no when dealing with high-performance MySQL.

    Unless you are doing a prefix search on an indexed column:

    mysql> select COUNT(ID) FROM table WHERE Name LIKE 'search%';
    +-----------+
    | COUNT(ID) |
    +-----------+
    |         7 | 
    +-----------+
    1 row in set (3.88 sec)
    

    In which case, the LIKE with only a suffix wildcard is much faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the goal is to retrieve the number of users in one table which have:
I am building a tool which goal is to download a file based on
I have been playing with BeautifulSoup, which is great. My end goal is to
I'm working with Solr 1.4, and I want to test mergeindexes. Imagine these following
Your basic SP with a default parameter: ALTER PROCEDURE [usp_debug_fails] @DATA_DT_ID AS int =
Suppose your git history looks like this: 1 2 3 4 5 1–5 are
In your applications, what's a long time to keep a transaction open before committing
Does your work environment use Harvest SCM? I've used this now at two different
In your experience, how often should Oracle database statistics be run? Our team of
Does your software handle newline characters from other systems? Linux/BSD linefeed ^J 10 x0A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.