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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:39:45+00:00 2026-05-26T05:39:45+00:00

I am implementing an autocomplete field in a website, and my endpoint queries a

  • 0

I am implementing an autocomplete field in a website, and my endpoint queries a mysql to get the data. This particular field can only be retrieved from a database ‘list’ which has a about 600,000 entries, where only 4000 of them are unique. Once a day or so, a new unique list item will be added.
I’m using a call like this, where query is whatever the user has started typing in the autocomplete box:

SELECT DISTINCT item FROM list WHERE item like '%query%' LIMIT 10;

This query takes about .8 milliseconds, and the majority of the time is due to the SELECT DISTINCT, I believe. Is there any way to increase the performance of this task?
I’m fine to create new tables/views, but I’m not sure what will help.

  • 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-26T05:39:45+00:00Added an answer on May 26, 2026 at 5:39 am

    When you use the % sign at the beginning in a query with LIKE no index will be used, and every single row of your table will be scanned, no matter how your indexes look like.

    Think about an address book with letter tabs, if I’m looking for 'Mads%', I can point my finger to the letter M and read from there, but If I look for '%dse%', I’ve to read every entry.

    • If you can you should drop the percent sign at the beginning of the string, in this case the index on item will be used (be sure to add it, you can also index a part of the field in case it’s a long field).
    • Otherwise, you should use full text search instead.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing jQuery-ui autocomplete function in my website. In IE6, the autocomplete box
I'm implementing a AJAX autocomplete/autosuggest feature, and not only do I want to do
I'm interested in implementing autocomplete in Python. For example, as the user types in
implementing publishActivity in PHP using the REST API using this code: $activity = array(
I implementing a EventQueue and get notified when AWTEvents are send. I wait till
Now, I'm developing a command-line application somewhat like bash. For implementing the autocomplete functionality,
I am implementing a jquery autocomplete on a search form and am getting the
What is the idea behind implementing a tagging system like Stack Overflow? This is
I am implementing YUI autocomplete in my project. I have created a web service
I'm implementing my own autocompletion on an <input> field inside a UIWebView, and the

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.