Keytable extension is slow with huge table

Keytable extension is slow with huge table

jolevesqjolevesq Posts: 4Questions: 2Answers: 0

Hi,

I use Keytable extension with a huge table (over 100 000 rows) and with the scroller extension. Every time I move set the focus on the cell with the mouse or the keyboard it tooks fews second for the focus or the shift cell to happend.

With the profiler, I narrow my problem down to the function below.

/**
     * Find the unique elements in a source array.
     *
     * @param  {array} src Source array
     * @return {array} Array of unique items
     * @ignore
     */
    var _unique = function ( src )
    {
        // A faster unique method is to use object keys to identify used values,
        // but this doesn't work with arrays or objects, which we must also
        // consider. See jsperf.com/compare-array-unique-versions/4 for more
        // information.
        var
            out = [],
            val,
            i, ien=src.length,
            j, k=0;
    
        again: for ( i=0 ; i<ien ; i++ ) {
            val = src[i];
    
            for ( j=0 ; j<k ; j++ ) {
                if ( out[j] === val ) {
                    continue again;
                }
            }
    
            out.push( val );
            k++;
        }
    
        return out;
    };

It works very well with small table but when records exceed 10 000 records it start to slow down. Is there something I can do to speed it up?

Thanks

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    What version of DataTables are you using? If not 1.10.15 could you update to that please?

    Thanks,
    Allan

  • jolevesqjolevesq Posts: 4Questions: 2Answers: 0

    Thanks for the quick answer. I was using 1.10.11. I updated to 1.10.15 and speed is much more better!

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Awesome. I put a change into 1.10.14 (and then another small related change in 1.10.15) which will dramatically improve performance for API interactions with large tables (KeyTable uses the public API, which is why we see this improvement).

    Allan

This discussion has been closed.