开发者

mysql search queries and pagination with php or javascript

Im developin开发者_C百科g a site where its users can search for other users on the same website.

The queries can be very long and complex, so i would like to save some of the work done, so i dont have to repeat the same work again.

I was thinking i could save the results in a table, so when i use pagination it woudnt have to do the same query all over again, it could just get the results from the result table. How does this sound?

Maybe there is another better way? Is it possible to save queries in php sessions? Is this a good idea? Also im not sure what kind of pagination i should make, the one that goes like , prev , 1 , 2, 3 ,4 , next, or the "facebook style" where u just add 20 more results to the page every time scroller hits 10% of bottom window.

Any thoughts on the matter? :))

Best of regards, Alexander


Just optimize your search query (if needed).
In fact, database intended to "to repeat the same work again". Nothing wrong with it.


Would all users be submitting similar queries? If so, you may want to look into caching, such as memcached.

As for the pagination, if you want users to see the next X results automatically, somewhat like what's described here.


No need to output results to a table. If you're really concerned, index and even do stored procedures, but it's likely not necessary.

I like building an Ajax query with DataTables, then using their Pipeline feature to grab a few sets of results ahead of and behind the data that the user has actually requested--based on filter, pagination, and sorting variables that are pre built-in to the front-end code. Because you're spreading out the queries, it appears to the user that it's not taking any time at all to do. I have it running on tables of several hundred thousand results very effectively. And, it's VERY easy to do.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜