分页/可排序列的方式(客户端还是服务器端)? [英] way(client side or server side) to go for pagination /sortable columns?

查看:89
本文介绍了分页/可排序列的方式(客户端还是服务器端)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个雇员表中有3000条记录,这些记录是通过一个查询从数据库中获取的.我每页可以显示20条记录.因此,将有150页,每页显示20条记录.关于分页和可排序的列方法,我有两个问题:

I have 3000 records in an employee table which I have fetched from my database with a single query. I can show 20 records per page. So there will be 150 pages for with each page showing 20 records. I have two questions on pagination and sortable column approach:

1)如果我实现了没有可排序列的简单分页,则应将所有3000条记录发送给客户端,并使用javascript或jquery进行分页客户端.因此,如果用户单击第二页,则呼叫将不会转到服务器端,并且会更快. 尽管我不确定在浏览器/客户端上发送3000条或更多记录会产生什么影响?那么最好的方法是一次将所有记录发送到客户端,然后在那儿进行排序,还是在单击页面时将调用发送到服务器端,然后只返回特定的页面结果呢?

1) If I implement a simple pagination without sortable columns, should I send all 3000 records to client and do the pagination client side using javascript or jquery. So if user clicks second page, call will not go to server side and it will be faster. Though I am not sure what will be the impact of sending 3000 or more records on browser/client side? So what is the best approach either sending all the records to client in single go and do the sorting there or on click of page send the call to server side and then just return that specific page results?

2)在这种情况下,我需要提供分页以及可排序的列(6列).因此,用户可以在此处单击任何列,例如员工名称或部门名称,然后名称应按升序或降序排列. 我又想了解有关时间响应/内存的最佳方法吗?

2) In this scenario, I need to provide the pagination along with sortable columns (6 columns). So here user can click any column like employee name or department name, then names should be arranged in ascending or descending order. Again I want to know the best approach in terms of time response/memory?

推荐答案

几乎可以肯定,将数据发送到客户端是瓶颈(尤其是对于移动客户端),因此,您应始终努力发送尽可能少的数据.话虽如此,在服务器端进行分页几乎绝对是更好的选择.这是一个更具扩展性的解决方案.数据量可能会增长,因此未来最好只在服务器上进行分页.

Sending data to your client is almost certainly going to your bottleneck (especially for mobile clients), so you should always strive to send as little data as possible. With that said, it is almost definitely better to do your pagination on the server side. This is a much more scalable solution. It is likely that the amount of data will grow, so it's a safer bet for the future to just do the pagination on the server.

此外,请记住,几乎没有任何用户会真正浏览数百个结果页面,因此,传输所有数据也很浪费. 可能与您相关.

Also, remember that it is fairly unlikely that any user will actually bother looking through hundreds of result pages, so transferring all the data is likely wasteful as well. This may be a relevant read for you.

这篇关于分页/可排序列的方式(客户端还是服务器端)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆