开发者

Auto-suggest with quick response using PHP/KohanaPHP + MySQL + jQuery

开发者 https://www.devze.com 2022-12-22 04:05 出处:网络
I need开发者_运维百科 to know how to execute this in the best way possible so that the suggestions will load really quick and secured. I want something like how the Related Questions work here after t

I need开发者_运维百科 to know how to execute this in the best way possible so that the suggestions will load really quick and secured. I want something like how the Related Questions work here after typing a question title.


I guess jQueryUI will make the job with the new Autocomplete widget. However, the response time is related to both server response time (your php script execution time, server connection) and client side (user connection).


I've done some jQuery coding on top of Kohana and the important tip is that you don't want to make too many requests. E.g. don't call the server every time a letter is added, but only when user stops writing or presses space, etc.

Trying to send it too often seems to give a faster response when you think of it, but browsers have limited a number of connections for Ajax. Some IEs wait with sending requests if there is more than one Ajax query being made at the moment.

The rest is just making it quick on the server ;)

Fetch everything in one MySQL query.

Caution: If the query does some joins on large tables you probably need to redesign... Or do separate queries and build it up with PHP. Joining large tables is always slow. And you most often don't really need it :)

0

精彩评论

暂无评论...
验证码 换一张
取 消