Hi I have a site develop in cakephp, in a page I have an input type text where a user can insert string like “ban” I make a query to the database to retrieve the data to obtain record which contain that string (in the example: “banana”, “banned”…). Every time that the user digit another letter I make another query to retrieve data which containt taht string every time. The query is done in jquery every time that a user press a letter.
I have for example 1 milion of record into my table and I don’t know if a user start to digit letter if this solution is fast.
Another solution is: when I open that page I make a query to find all record and put it into an array. every time that a user digit a letter I search that string into the array to obtain a subarray with the result.
Which is the best solution in terms of speed, RAM. Consider that in that table I can have 1 milion of record and many user can enter into that page simultaneously.
My database is MYSQL.
I’d just suggest a simple search button is the easiest solution and saves the most resources for your server but there are tutorials out there.
I think this one might give you some ideas http://phpmysqltalk.com/1610-cakephp-jquery-autocomplete-tutorial.html
Remember to have a min letter of like 3-4 to reduce queries and caching sounds like a must.