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

  • Home
  • SEARCH
  • 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 8200745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:33:15+00:00 2026-06-07T06:33:15+00:00

From anybody with real experience, how do LIKE queries perform in MySQL on multi-million

  • 0

From anybody with real experience, how do LIKE queries perform in MySQL on multi-million row tables, in terms of speed and efficiency, if the field has a plain INDEX?

Is there a better alternative (that doesn’t filter results out, like the FULLTEXT 50% rule) for perform database field searches on multi-million row tables?

EXAMPLE:

Schema (comments table)

id (PRIMARY) title(INDEX) content time stamp

Query

SELECT * FROM 'comments' WHERE 'title' LIKE '%query%'
  • 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-06-07T06:33:19+00:00Added an answer on June 7, 2026 at 6:33 am

    From anybody with real experience, how do LIKE queries perform in
    MySQL on multimillion row tables, in terms of speed and effiency, if
    the field has a plain INDEX?

    Not so well (I think I had some searches in the range of 900k, can’t say I have experience in multimillion row LIKEs).

    Usually you should restrict the search any way you can, but this depends on table structure and application use case.

    Also, in some Web use cases it’s possible to actually improve performances and user experience with some tricks, like indexing separate keywords and create a keyword table and a rows_contains_keyword (id_keyword, id_row) table. The keyword table is used with AJAX to suggest search terms (simple words) and to compile them to integers — id_keywords. At that point, finding the rows containing those keywords becomes really fast. Updating the table one row at a time is also quite performant; of course, batch updates become a definite "don’t".

    This is not so unlike what is already done by full text MATCH..IN BOOLEAN MODE if using only the + operator:

    SELECT * FROM arts WHERE MATCH (title) AGAINST ('+MySQL +RDBMS' IN BOOLEAN MODE);
    

    You probably want an InnoDB table to do that:

    Boolean full-text searches have these characteristics:

    • They do not automatically sort rows in order of decreasing relevance.
      …
    • InnoDB tables require a FULLTEXT index on all columns of the MATCH() expression to perform boolean queries. Boolean queries against a MyISAM search index can work even without a FULLTEXT index, although a search executed in this fashion would be quite slow.
      …
    • They do not use the 50% threshold that applies to MyISAM search indexes.

    Can you give more information on the specific case?

    update: the AJAX way

    Setup: you break up all titles into words. This will soon give you a title_words table ( id integer not null autoincrement, word varchar(50) ) and a large title_contains_word ( word_id integer, title_id integer ) table.

    If you have 10 million titles, with an average of four words (plausible for books, less so for papers), you can expect a five thousand-row title_words table and a forty-million table containing two INTEGER columns; that is around 400 MB of extra data.

    For the search, the user starts entering a word, which you can autocomplete from the titlewords. Once this is done, the query becomes a list of word IDs; and of course words that aren’t in any title cannot even be entered, so the negative result is given immediately, and for free.

    The actual search can now happen in several ways, but one that I like has a SELECT COUNT(*) FROM title_contains_word WHERE word_id={id} running after each user’s selection, before the real search is started.

    This allows building a composite query or a common table expression starting from the rarest words. Indeed, if any word has a count below, say, 20, you can SELECT all those (on average) eight TCW rows and get the IDs of all their related words, then simply verify (outside MySQL) that there is a title ID such that there exists a pair (titleID, wordID) for all the wordIDs of your query.

    Even if you have to resort to the roughest possible form,

    SELECT a.title_id 
    FROM title_contains_word AS tcw1
    JOIN title_contains_word AS tcw2 USING (title_id)
    JOIN title_contains_word AS tcw3 USING (title_id)
    JOIN title_contains_word AS tcw4 USING (title_id)
    ...
    WHERE (tcw1.word_id = {id1})
      AND (tcw2.word_id = {id2})
      ...
    

    the JOIN will be made from very small virtually-buffered tables that will take very little time to scan.

    Once you have all the relevant title IDs, then you can run a straight SELECT from the multimillion-row large DB using the primary key title_id. This last search should also be blazing fast.

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

Sidebar

Related Questions

Can anybody tell how to retrieve data from database like that of Facebook's notification
Has anybody gone through the process of converting a real-world business application from ASP.NET
does anybody know we can translate from real image captured using cameras be converted
Does anybody know why the same code from this page http://emacsformacosx.com/ would not render
Can anybody help me how can I invoke a JSP page from a Servlet
Can anybody explain to me how objects are stored and removed from heap memory
Has anybody ever successfully written code to extract data from a SharePoint 2007 list
Can anybody know how to remove all the indexes from database ?
Anybody knows where the :// or the // comes from in most URIs syntaxes?
Does anybody know how to remove a line from a textfile. I'm looking for

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.