从JSON(db查询结果)加载大型javascript数组而不会崩溃页面?

时间:2022-08-16 00:12:21

I'm trying to load a million rows from a database query in chunks and keep it on the same page but paginated. Currently I have a button that retrieves 50,000 chunks using a LIMIT between and then append it to the end of the table. The query results is written to a JSON file which is retrieved onto a paginated table on the page.

我正在尝试从块中的数据库查询中加载一百万行并将其保留在同一页面上但是已分页。目前我有一个按钮,使用LIMIT检索50,000个块,然后将其附加到表的末尾。查询结果将写入JSON文件,该文件将检索到页面上的分页表中。

However the browser crashes shortly after loading it. Currently, there is a load more results button that appends a new query onto the existing JSON file which is then loaded into an array of rows in a paginated table. However upon reaching about 160MB JSON file size, roughly 250 thousand rows, the browser would crash.

但是加载后浏览器很快就崩溃了。目前,有一个加载更多结果按钮,将新查询附加到现有JSON文件,然后将其加载到分页表中的行数组中。但是,当达到约160MB JSON文件大小,大约25万行时,浏览器将崩溃。

Currently, my table is already paginated, retrieved from an array and filtered using angularJS filter on ng-repeat of the huge array to display only 1000 results per page on the table, and the load more query will append the new results to the end of the table. The reason for appending is because a single large query takes too long and I would like to have access to previous results loaded (for csv export reasons), is there a way to have a million rows paginated and not crash the page?

目前,我的表已经分页,从数组中检索并使用angularJS过滤器对巨大数组的ng-repeat进行过滤,以在表上每页显示1000个结果,并且加载更多查询将新结果附加到结尾桌子。添加的原因是因为单个大型查询需要花费太长时间而且我希望能够访问以前加载的结果(对于csv导出原因),有没有办法让一百万行分页并且不会崩溃页面?

Thanks in advance, hope you can help.

在此先感谢,希望你能提供帮助。

1 个解决方案

#1


0  

Use smaller pieces of code and use local storage to save your code. In addition, run a count the number of pages that will be in the code to know how to break it up.

使用较小的代码段并使用本地存储来保存代码。此外,运行计数代码中的页数以了解如何分解它。

#1


0  

Use smaller pieces of code and use local storage to save your code. In addition, run a count the number of pages that will be in the code to know how to break it up.

使用较小的代码段并使用本地存储来保存代码。此外,运行计数代码中的页数以了解如何分解它。