Performance Issue with Not-Huge Table

Performance Issue with Not-Huge Table

redandwhiteredandwhite Posts: 5Questions: 0Answers: 0
edited March 2011 in General
This table generally contains between 500-2000 rows. At 500 on a fast machine it performs fine; at 2000 or on a not-so-fast-machine, it's nearly unusable. I'm sure I'm doing lots of things wrong, so please enlighten me:

[code]
var tbl = $('#keywordTbl').dataTable({
"bDestroy": true,
"bInfo": true,
"bJQueryUI": true,
// "bLengthChange": true,
"sScrollY": "400px",
"bPaginate": false,
"bStateSave": false,
"bAutoWidth": true,
"aaSorting": [[1, "desc"]],
"bSortClasses": false,
"aoColumns": [
null,
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": false },
null
]
});
tbl.fnSetColumnVis(5, false);

var hideKeywords = ($("#showHideExcluded").val() == "true");
if (hideKeywords) {
tbl.fnFilter('included', 5);
} else {
tbl.fnFilter('', 5);
}
[/code]

In IE, user's constantly see the warning that a script on the page is making the browser run slow and would they like to stop it. That's just during load/initial display. Would love to know where to start.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    The first two things I would suggest is to set the column visibility and the filtering in the initialisation which will save a good few clock cycles (since it's going three draws at the moment, rather than just one).

    See what difference that makes, but 2000 rows is typically around the point that we start to see performance in IE drop off significantly. IE( I believe is much better for this, but with IE8<, 2000 rows is roughly the point to start consider using server-side processing. Also, make sure you aren't initialising the table in a display:none element - that absolutely kills IE.

    Beyond that, it would be starting to look at optimisation of DataTables. I've already done a good deal of work on the optimisation (make sure you are using the latest version of DataTables :-) ) but any suggestions for how to improve it are always welcome!

    Allan
  • redandwhiteredandwhite Posts: 5Questions: 0Answers: 0
    Ok, I got the visibility working in the initialization, but how do I do that with the filtering? Can't seem to find that in the documentation.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    http://datatables.net/usage/options#oSearch :-)

    I'm working on a longer term plan to improve the documentation at this very moment... :-)

    Allan
  • redandwhiteredandwhite Posts: 5Questions: 0Answers: 0
    Hmmm those don't seem equivalent. What I'm doing is using a hidden column to hide certain rows. Perhaps that's not the right approach. I think that the search option is going to interfere with users ability to actually search by typing stuff in, right?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Oops sorry - oSearch is for the global filter. There is aoSearchCols ( http://datatables.net/usage/options#aoSearchCols ) for individual column filtering.

    I think you should be okay with your filtering approach since the filter is cumulative. Just don't allow them to change the individual column filter for the hidden column :-).

    Allan
This discussion has been closed.