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 7888385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:49:08+00:00 2026-06-03T05:49:08+00:00

Having this table: CREATE TABLE `example` ( `id` int(11) unsigned NOT NULL auto_increment, `keywords`

  • 0

Having this table:

CREATE TABLE `example` (
`id` int(11) unsigned NOT NULL auto_increment,
`keywords` varchar(200) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB;

We would like to optimize the following query:

SELECT id FROM example WHERE keywords LIKE '%whatever%'

The table is InnoDB, (so no FULLTEXT for now) which would be the best index to use in order to optimize such query?

We’ve tried a simple :

ALTER TABLE `example` ADD INDEX `idxSearch` (`keywords`);

But an explain query shows that need to scan the whole table
if our queries where LIKE ‘whatever%’ instead, this index performs well, but otherwise has no value.

Is there anyway to optimize this for innoDB ?

Thanks!

  • 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-03T05:49:09+00:00Added an answer on June 3, 2026 at 5:49 am

    Indexes are built from the start of the string towards the end. When you use LIKE 'whatever%' type clause, MySQL can use those start-based indexes to look for whatever very quickly.

    But switching to LIKE '%whatever%' removes that anchor at the start of the string. Now the start-based indexes can’t be used, because your search term is no longer anchored at the start of the string – it’s “floating” somewhere in the middle and the entire field has to be search. Any LIKE '%... query can never use indexes.

    That’s why you use fulltext indexes if all you’re doing are ‘floating’ searches, because they’re designed for that type of usage.

    Of major note: InnoDB now supports fulltext indexes as of version 5.6.4. So unless you can’t upgrade to at least 5.6.4, there’s nothing holding you back from using InnoDB *AND fulltext searches.

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

Sidebar

Related Questions

Given this table: CREATE TABLE [Comments] ( [Id] [int] IDENTITY(1, 1) NOT NULL, [Text]
I'm having a table looking something like this: CREATE TABLE `Calls` ( `calendar_id` int(11)
I am having a table with records like this in MS Access: ID field2
I'm having an issue bending my head around this one. I have a table
Having this code: using (BinaryWriter writer = new BinaryWriter(File.Open(ProjectPath, FileMode.Create))) { //save something here
I have a table that contains several thousand rows, having a Varchar column that
So imagine that you have a table of Products (ID int, Name nvarchar(200)) ,
Having this line Cursor c = db.rawQuery(PRAGMA table_info(?), new String[] {tableName}); and getting this:
I'm having trouble writing this Query. I have 2 tables, vote_table and click_table. in
So i'm having this problem. I have two tables (Oracle), one is called Destination

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.