简体   繁体   English

如何更快地显示 20000 行数据?

[英]How do I display 20000 rows of data more quickly?

I am using datatables jquery to display the table with nodejs to make a query to the database.我正在使用数据表 jquery 显示带有 nodejs 的表以查询数据库。 It is currently taking 18s to display 20000 rows of data目前显示20000行数据需要18s

when i directly query the database it takes less then a second to display the data.当我直接查询数据库时,显示数据所需的时间不到一秒钟。

First of all, even if it is possible to show 20K records in a grid, your user will definitely not be interested to see all of these at one go.首先,即使可以在一个网格中显示 20K 条记录,您的用户也绝对不会有兴趣一次性查看所有这些记录。 Rather show a small set of data in the UI grid and provide search, sort and pagination options.而是在 UI 网格中显示一小组数据并提供搜索、排序和分页选项。

Go for both server-side (NodeJS) and client-side (jQuery) pagination.使用服务器端 (NodeJS) 和客户端 (jQuery) 分页。 Fetch data from the database one page at a time and let the client request one page at a time.一次一页地从数据库中获取数据,让客户端一次请求一页。 Make the page size configurable.使页面大小可配置。

If server-side performance (especially database query) is not a concern then fetch all 20K data at one go.如果服务器端性能(尤其是数据库查询)不是问题,那么一次性获取所有 20K 数据。 Reduces complexity at server side by avoiding pagination.通过避免分页来降低服务器端的复杂性。 However, still at client-side implement pagination to avoid rendering issue and to improve usability.但是,仍然在客户端实现分页以避免呈现问题并提高可用性。 Note that, by fetching all data at one go memory consumption of both server and client-side processes will increase.请注意,通过一次性获取所有数据,服务器和客户端进程的内存消耗都会增加。

If it works today well, it will definitely break if there is a possibility that your data grows over time.如果它今天运行良好,如果您的数据有可能随着时间的推移而增长,它肯定会崩溃。 If not and you still want to fetch all 20K records and display at one go, then go ahead, good luck :)如果没有,并且您仍然想一次性获取所有 20K 条记录并显示,那么请继续,祝您好运 :)

What kind of data?什么样的数据?

Rather than display 20K rows of details, summarize the data and show no more than a screenful of data.与其显示 20K 行的详细信息,不如汇总数据并且只显示一屏数据。 You could do this with some kind of graph.你可以用某种图表来做到这一点。 Or summarizing the data.或者汇总数据。 Or...或者...

And you could have links on the consolidated data for those who need to drill down to the details.您可以为需要深入了解详细信息的人提供有关合并数据的链接。

This seems to be a UI issue.这似乎是一个 UI 问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM