Slow response time

Slow response time

ccheungccheung Posts: 1Questions: 1Answers: 0

Hi Allan,

I am running into some performance issues for a DataTable that I am working on, and was hoping you could offer some insight. I’m sorry I can’t link to a test case, since it’s running on an internal test server at the moment. I’ll try to provide as much detail as I can.

At the moment, trying to load a DataTable of about 900 rows takes approximately 12 seconds.

Our DataTable setup:

The developer before me used the following techniques to load the table data.

  • JQuery AJAX call to get the data from the server (this takes about 1.3 seconds)
  • Create a JavaScript array to represent each row in the table, and set each column value as an index in the array, like:
    var cols = []; cols[0] = data.rowId; cols[1] = data.name; etc.

  • Create a DataTable using minimal initialization parameters, like:
    var datatable = $("#table").dataTable({ dom: 'frti', bPaginate: false, scrollY: "530px", scrollX: true )};

  • Add the array as a row to the table by using fnAddData(), like:
    datatable.fnAddData(cols, false);

  • Followed by a datatable.fnDraw() call outside of the loop

Subsequently, there is no data or column initialization inside the dataTables() call, since we don’t use the ajax or column parameters inside the DataTables initialization.

Things we have tried:

We tried doing a number of things to speed up the load time, but doing things like pagination and Scroller failed because there is logic that gets called on the table rows (like populating drop down selections, greying out cells, disabling cells) that do not work for all pages after the first one, since the rows have not been rendered yet. I’m guessing this is because that logic code uses JQuery selectors to try and grab elements that have not been drawn. I tried setting deferRender: false but the logic still fails.

We considered switching to server side processing for DataTables, but that is failing since:

  • We don’t do the AJAX call inside the DataTables() initialization (it’s currently done using a JQuery AJAX call prior to the DataTable call, and then the data is added into the table later)
  • We are using fnAddData(), which you’ve mentioned before is incompatible with server side processing

Do you have any suggestions on how to proceed? Are there any other options for us in terms of speeding up performance other than the things I’ve mentioned?

Thanks so much!

This discussion has been closed.