datatable optimization slow loading time
datatable optimization slow loading time
Link to test case: sorry, it is internal portal with sensitive data, so I can not post link to test the case
Debugger code (debug.datatables.net):
Table:
Information about 1 table available
log
Data source: DOM
Processing mode: Client-side
Draws: 8
Columns: 3
Rows - total: 24806
Rows - after search: 209
Display start: 150
Display length: 50
Versions:
LibraryInfoInstalledLatest
DataTables available1.10.20
AutoFill-2.3.7
Buttons1.6.1
ColReorder-1.5.5
Editor-2.0.5
FixedColumns-4.0.1
FixedHeader-3.2.0
KeyTable-2.6.4
Responsive-2.2.9
RowGroup-1.1.4
RowReorder-1.2.8
Scroller-2.0.5
SearchBuilder-1.3.0
SearchPanes-1.4.0
Select-1.3.3
Check for common issues:
15 tests complete. No failures or warnings found!
Error messages shown: no errors
Description of problem: page loads dom realy slow, main issue is rendering time, how can I optimize this? Maybe can someone show me example how to fix loading time with big datatables?
322 ms Loading
3935 ms Scripting
4849 ms Rendering
472 ms System
3678 ms Idle
13256 ms Total
Replies
This section of the FAQ should help, it discusses various techniques to improve performance,
Cheers,
Colin
Hello collin, corect me if I wrong, I should use Client-side processing - Ajax sourced data, this means i add ajax url, where table should send pagination data there should be loaded only selected page data and it must be formated as and object and returned to frontend?
With 24k rows, you should be OK with client-side processing provided you're not doing too much processing/rendering on those rows. With client-side, all data is sent to the browser, and the browser works out the paging, filtering and ordering. If you want only the selected page data to be sent, then that's exactly what
serverSide
does - as this greatly limits the data sent.There are examples for both which would probably help understand what's happening - check out the network tab on the developer tools. This is client-side, and for server-side,
Colin
Well I think I'm doing to much processing, becuase it loads very slow, could some one help me to turn this code to server side sript?
You are doing 8 queries for every row? Wow - yup, that will slow things down a fair bit. You really want to combine that into a single query with joins.
That seems to me that you are running it on all 24k rows rather than just the 10 (or whatever) DataTables uses for the current page. See this manual page for the parameters DataTables sends and you need to use for processing the request.
Allan
hello Allan, if I somehow transform it with JOINS, maybe this would be enough not to switch to server side with selected count for that page records and it would be all good with dom client side all the rows with JOIN mysql query, what do you think?
Possibly. With 24k rows, depending what is in the rows (i.e. the size of each) then the download of the data for all of them might be fast (or might be slow!). You are into the grey area there where there isn't a clear yes or no to server-side processing.
I'd suggest trying to may your SQL a single statement first - that will most certainly improve performance, regardless of which why you go, and then you can decide based on the resulting performance if you want to use server-side processing or not.
Allan
Well I tried to optimize queries but this does'nt help a lot, because the main issue is 21144 ms Rendering.
Have isolated the time to see how much is Datatables loading? How long does your page take without Datatables?
Kevin
Hello Kevin,
How to do this?
First I would temporarily remove the Datatables init code to see how long the page takes to load without Datatables. This should help to determine if Datatables rendering is the problem.
Kevin