1

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.

4

1 回答 1

1

我只是建议一个简单的搜索按钮是最简单的解决方案,并为您的服务器节省最多的资源,但那里有教程。我认为这个可能会给你一些想法http://phpmysqltalk.com/1610-cakephp-jquery-autocomplete-tutorial.html 记住要有一个像 3-4 这样的最小字母来减少查询和缓存听起来是必须的。

于 2012-11-01T19:02:19.690 回答