user926367
user926367

Reputation:

php + mysql - performance - instant auto complete response

I'm building an autocomplete feature for an input box which is similar to Google's Instant Search.

I need to have an instant response for the autocomplete feature. The table I'm executing the query with the term in it has hundreds of thousands of records and more that a hundred of columns. For example: 500,000 records, 120 columns.

So, I have two issues:

  1. Executing a query with the most possible speed.
  2. Fast response on showing the result in search box's auto complete drop down.

By the way, I'm using the Joomla framework which might cause some slow down, too.

Upvotes: 3

Views: 1180

Answers (4)

Justin Iurman
Justin Iurman

Reputation: 19016

  1. Create indexes on some necessary sql fields.
  2. Use delay depending on the number of key pressed (and also, the time between 2 key pressed if you want).
  3. Add your own cache logic.
  4. LIMIT the result of the query

Upvotes: 4

Laoneo
Laoneo

Reputation: 1566

If possible consider to use a nosql database like Mongodb or Cassandra for this table as they are made for that kind of data, especially if the data will grow. To transport the data from the server to the client use json.

Upvotes: 1

kta
kta

Reputation: 20130

Auto-complete can be triggered when the user input is at-least 3 characters long.

Upvotes: 1

Jenson M John
Jenson M John

Reputation: 5689

Use Indexing on Field which you want to show in autocomplete from your Database.

http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html

Upvotes: 0

Related Questions