Reputation: 25
I am running a live search through a text box that when a user types it returns matching rows from a mysql database. The problem is this is one of the main features of the site and has really increased the memory load on my mysql database. Because every key stroke sends a request to the php script to query the database.
I have php ignore any search term less than 3 characters long, but besides that what else could I do?
There are some options here: Live search optimisation in Javascript
But I was wondering if I should pull from a cached xml sheet, or is there somehow some way to cache mysql itself.
What does google, or some of the other large sites that rely on this feature heavily do?
Upvotes: 0
Views: 630
Reputation: 2481
I would try to optimize the SQL query as much as possible:
Also, in the PHP side:
Also, consider a parallel NoSQL db
And
Zend_Search_Lucene is great for low/medium traffic sites (reportedly has issues when scaling)
Upvotes: 0
Reputation: 10074
Use indexing engines to index your data and speed up your search results. Like: http://sphinxsearch.com/ or http://lucene.apache.org/core/
Setup cron job to index data, there is PHP API for sphinx, and Zend Framework Module. Indexing speed uo things a lot, if used correctly.
Upvotes: 1