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

The Archive Base Latest Questions

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

Note: In this question I’m using the term autocomplete (or iterative search) to refer

  • 0

Note: In this question I’m using the term “autocomplete” (or “iterative search”) to refer to returning search-as-you-type results, e.g. like Google Search gives you. Also my question is not specific to web applications vs. fat client apps.

How are SQL SELECT queries normally constructed to provide decent performance for this type of query, especially over arbitrarily large data sets? In the case where the search will only query based on the first n characters (easiest case) am I still issuing a new SELECT result FROM sometable WHERE entry LIKE… on each keypress. Even with various forms of caching this seems like it might result in poor performance.

In cases where you want your search string to return results with prefix matches, substring matches, etc. it’s an even more difficult problem. Looking at a case of searching a list of contacts, you might return results that match FirstName + LastName, LastName + FirstName, or any other substring.

  • 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:35:49+00:00Added an answer on May 13, 2026 at 11:35 pm

    Searches like Google, Yahoo, etc. use full text indexes to generate a high performance list of key words.

    If you’re doing iterative searches on single word columns, you won’t need full text indexes and keywords. You can use LIKE on the indexed columns themselves.

    Since you’re doing the search as they type, you’re doing prefix only matching. Your indexed columns will still get normal performance with a LIKE clause and a wild card doing “prefix” searches.

    SELECT last_name FROM users WHERE last_name LIKE 'Adam%'
    

    If you need to search from the other end, you’ll want a reverse index, but, luckily, people don’t type backwards.

    You will issue a new SELECT statement for each “iterative search” but on a timer. Only if they stop typing, do you issue another query. You’ll limit the result set using LIMIT or TOP so that the query can complete as soon as it fills 10 records or so. Also, this way you’re only sending 10 records over the wire.

    SELECT last_name FROM users WHERE last_name LIKE 'Adam%' LIMIT 10
    

    Of course, for best performance, last_name would be the primary index. An index allows the database to get the value without hitting the actual record. Primary indexes are often contiguous, which makes them even faster.

    If by chance, you are searching on one column, but returning another, then use a compound index so that the database engine can still get the value from the index itself, without hitting the record.

    SELECT first_name FROM users WHERE last_name LIKE 'Adam%' LIMIT 10
    

    For the above query, the primary index would be (last_name, first_name).

    The timer is the key to performance. You can tweak the timer to get the performance you desire.

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

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure what you're really looking for, but import… May 14, 2026 at 8:42 pm
  • Editorial Team
    Editorial Team added an answer No, return i < 3 isn't the same as if… May 14, 2026 at 8:42 pm
  • Editorial Team
    Editorial Team added an answer There is an article on MSDN on How to extract… May 14, 2026 at 8:42 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.