简体   繁体   English

大表的DataTables性能

[英]DataTables performance for big table

First of all i am very glad to use dataTables - it is easy to use and nice solution if you have to work with tables in HTML pages. 首先,我非常高兴使用dataTables-如果您必须使用HTML页面中的表,那么它很容易使用并且是不错的解决方案。 When my table was about 700 rows and 10 cols everything was great! 当我的桌子大约有700行和10列时,一切都很棒!

But now my table is about 3000 records (rows) and maybe about 10 rows and performance of search dramatically decreased. 但是现在我的表大约有3000条记录(行),可能有大约10行,并且搜索性能急剧下降。 I updated version of datatables.js script from 1.9.4 to 1.10.7 - but i see no changes in speed while i am searching for something in my table. 我将datatables.js脚本的版本从1.9.4更新到了1.10.7-但是我在表中搜索内容时速度没有变化。 I tried it with pagination enabled or disabled - no difference. 我尝试过启用或禁用分页-没什么区别。

What can be done to increase performance and speed of search? 如何提高搜索性能和速度? I am abolutely sure that 3000 records is not big deal for great library like dataTables! 我完全肯定3000条记录对于像dataTables这样的大型图书馆来说并不重要!

UPDATE i use it with static page and TableTools add-on. 更新我将其与静态页面和TableTools加载项一起使用。 My options are 我的选择是

"sDom": 'T<"clear">lfrtip',
"oTableTools": {***tableTools options**},
"sPaginationType": "full_numbers",
"bPaginate": true,
"iDisplayLength": 30,
"bLengthChange": false,
"bInfo": true,
"oLanguage": { *** some translations *** }

Datatables in the way you are using it is fine if, like you said, you have a small number of records. 如果您的记录数很少,则按您使用的方式使用数据表就可以了。 But if you have many records, a JSON is sent to the client, it is going to be parsed by Datatables and shown in the table, so you should switch to AJAX. 但是,如果您有许多记录,则将JSON发送到客户端,它将由Datatables解析并显示在表中,因此您应该切换到AJAX。 Documentation to use Datatables with AJAX can be found here: 可以在以下位置找到将数据表与AJAX结合使用的文档:

https://www.datatables.net/examples/data_sources/ajax.html https://www.datatables.net/examples/data_sources/ajax.html

Load your data asynchronously, each page retrieval is a new request to the server. 异步加载数据,每次页面检索都是对服务器的新请求。 That will solve your searching issues (...given you write your queries properly.) : 这将解决您的搜索问题(...只要您正确编写查询即可。):

Datatables server-side processing example. 数据表服务器端处理示例。

I'm currently running Datatables for 100k records, no issues here. 我目前正在为10万条记录运行数据表,这里没有问题。

Good luck! 祝好运!

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

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