Amego Amego - 6 months ago 38
Ajax Question

Dose ajax live search effects SQL database?

Im just wondering will SQL database be damaged, if you make a lot of queries
for example using ajax live search, as when you add or delete a letter it will make a new query

thank you for you time :)


Your database will not be damaged. Your website may become slow and laggy, not because of DB queries, but because of the many http requests while the user types. To make an effective live search there are a few things you can do:

  1. At the front end, only make requests to your PHP/Mysql once you have enough characters that you can get significant results. For example, only run the search after 4 characters are typed.
  2. Use rate-limiting at the front-end. This means wait for inactivity before you make another http request. Instead of making 4 requests a second if your user types 4 characters, wait until the user pauses for a bit (eg: 750 milliseconds) before you fire off a request.
  3. In Mysql, design your table to include a FULLTEXT index on the columns you wish to search frequently
  4. Design your queries to be as targeted as possible. For instance if you're running a search for job openings, you could have the user first select the industry and region she is interested in. That way you can add WHERE industry='...' AND region='...' to your query and it will run much faster. Anything that will allow you to focus the query.