Need a replacement for jQuery datatables plugin as it’s too slow
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts I will will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.
So, my question was as follows:
I’ve been using jQuery datatables plugin for about two years now and it worked great so far. The problem occured now when I need to load about 45000 records at once (you click the button and wait for the page with the data to load) – the loading time is just too big to wait.
Here are the tests I made using Chrome web browser (the data is from it’s Network tab using ):
datatables plugin turned on:
5476 records:
24 requests ❘ 256.26KB transferred ❘ 19.80s
(onload: 19.80s, DOMContentLoaded: 18.58s)
45071 records:
34 requests ❘ 1.85MB transferred ❘ 11.1min
(onload: 11.1min, DOMContentLoaded: 11.0min)
datatables plugin turned off (the jQuery datatables initialization is comented out):
5476 records:
21 requests ❘ 255.84KB transferred ❘ 6.57s
(onload: 13.26s, DOMContentLoaded: 13.28s)
45071 records:
31 requests ❘ 1.84MB transferred ❘ 2.0min
(onload: 2.0min, DOMContentLoaded: 2.0min)
The increase in load time that datatables make is over 80% for the 45k rows, and almost 40% for the 5k rows.
So I was wondering if you guys know of any similar plugin that handles alot of rows (45000+) faster, or am I just missing the point by trying to load all 45000+ records in “one go”?
Any suggestions are appreciated!
The answer, by user Allan Jardine, was this:
From the DataTables FAQs ( http://datatables.net/faqs#speed ):
- Client-side processing – DOM sourced data: ~5’000 rows. Speed options: bSortClasses
- Client-side processing – Ajax sourced data: ~50’000 rows. Speed options: bDeferRender
- Server-side processing: millions of rows.
If you aren’t using deferred rendering at the moment, with your 45’000 rows, I would most certainly suggest that. Failing that, for DataTables options, you might need to look at server-side processing.
I was having the same problem. I found if I created the json object first then passed it to datatables I could load the table in about 2.5 seconds. I have done this with tables of at least 57,000 records. So I json_encode the array after I array_push all the rows then pass it to the data tables as one preformed object.
You have probably moved on by now but figured I would post.
Hey Nick,
Thanks for your comment! Yes, indeed, in the end I moved to server side processing, as it was suggested to me on StackOverflow. However, I’ll try it your way too the next time I’ll need to deal with datatables.