Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Tablesorter with lots of row - Initialization Time #678

Closed
Fabien04 opened this issue Jul 10, 2014 · 13 comments
Closed

Multiple Tablesorter with lots of row - Initialization Time #678

Fabien04 opened this issue Jul 10, 2014 · 13 comments

Comments

@Fabien04
Copy link

Hi,
I upgrade the last Tablesorter, and i have Tablesorter initialization : 7002 ms.
I use multiple Tablesorter on the same page, about five, with more than 2000rows for all.
I try lots of modification, but it's takes lots of time to initialize.
Someone have an idea for this new problem that I encounter ?
Thanks

@Mottie
Copy link
Owner

Mottie commented Jul 10, 2014

Hi @Fabien04!

This is how I would approach the problem:

  • Set the delayInit option to true on all but the first (or most important) tables. What this does is initializes the table without parsing through all of the table data. It delays it until the user clicks on the header to sort the table.
  • If any of the non-"important" tables have an initial sort, remove them. An initial sort bypasses the setting of that option because the table data needs to be cached before it can be sorted.
  • To further speed up initialization, I would recommend NOT using the zebra widget unless you are using the filter widget. The same thing can be accomplished using css in modern browsers (IE7/8 users don't "need" to see striped rows).

@Fabien04
Copy link
Author

Nice, i delete zebra filter and i won about 1000ms.
I already delete initial sort, i saw your words in another github post.

I try delay init option too, but when i use this option, an error occur :
"TypeError: c.cache is undefined
$.each(c.cache[0].normalized, function(i, el) {"

If I may ask you... because i lost a lot of time for find any solution ...

@thezoggy
Copy link
Collaborator

if you dont need to support browsers that cant do css3,
http://caniuse.com/#search=nth-child

you should just use css3 nth-child(odd) to do your zebra striping rather than the zebra filter (since it has to add/remove classes) which can be costly depending on how many visible rows you have

@Mottie
Copy link
Owner

Mottie commented Jul 10, 2014

@Fabien04!

Make sure you are using the most up-to-date version of the plugin. There shouldn't be any error - see this demo.

@Fabien04
Copy link
Author

Thank you for replies, and thanks thezoggy, nice tips if i need to keep zebra style.
It's ok i used the last version of this nice plugin. but i forget, i use Pager widget. i really need for good presentation.
If i delete all pager widget, i can use delay option, and i lose initialization time. 5.5ms to 1.5ms. Wonderful...
It's not possible to keep the same result with pager plugin ?

@Mottie
Copy link
Owner

Mottie commented Jul 11, 2014

Hi @Fabien04!

Currently the pager needs to process (parse) all of the rows before it can finish initialization. In fact, when I tested the pager with delayInit set to true I got a javascript error 😱!

I have already found a solution, which I will push to the working branch once I fix the other bug were the filter widget doesn't work if the delayInit is set to true 🙀!

@Fabien04
Copy link
Author

Thanks a lot ! Waiting for read that.
And sorry to give you this problem

@Mottie
Copy link
Owner

Mottie commented Jul 11, 2014

LOL you didn't cause the problem, it was just there waiting to be found.

Sadly, I am going to be busy for the next week entertaining family, so I won't have hardly any time to work on this. I'll try to get what I can done today before they arrive, but no guarantees!

@Mottie
Copy link
Owner

Mottie commented Jul 11, 2014

Ok @Fabien04!

Please try the updates I just pushed to the working branch and see if that fixes your initialization time worries ;)

@Fabien04
Copy link
Author

Hi Mottie,

Thanks for tips and for take time to do that.
So i use this fix, and it's not better. it's take more time to initialize with delayInit ... o_O
The result is :
When i don't use delayInit fonction, i have Tablesorter initialization 5200 ms.
When i use on all table (five) : Tablesorter initialization : 6400 ms.
When i use on the biggest table only, Tablesorter initialization : 6785 ms.
And last, when i don't init tablesorter function on all table and run only the biggest, i have more than when i don't use this option, about 5800ms.
I use pager plugin and not pager widget. Maybe i doing something wrong...
I continue to find a solution. Thank you for your help

@Fabien04
Copy link
Author

I have some success, on two table where i used html5 filter, don't think it's a filter problem, i just say it.
I forget i use childrow too.

The result are :
Tablesorter 1 : 9131 ms -> 3569 ms for 608rows
Tablesorter 2 : 6354 ms -> 2492 ms for 405rows
Nice upgrade for that, but it's take some time to initialize 6 second for two table and 1000rows.
Before i can't use these tables, the browser stop script and show message with script not answering.

The exact result for my five table :
Table 1 : 128 -> 105 -> 133
Table 2 : 4027 -> 5922 -> 5776
Table 3 : 433 -> 286 -> 491
Table 4 : 200 -> 140 -> 216
Table 5 : 248 -> 178 -> 264
First column: without delayinit / Second : delayinit on all / Third : delayinit on biggest.

We can see that delayInit option is good for little table, but not for the biggest... it's worse.
For my biggest table, i have 930 row. So it's not far to my first test with my two table,
about 1013rows for 6061ms, and second test, about 930 rows for 5776ms.

It's exactly what i have. i can't say more for now ^^
The project i work on it, will grow and stored more rows. Do you think i going to have some difficult for continu to use pager plugin ?

@Mottie
Copy link
Owner

Mottie commented Jul 14, 2014

Do any of your tables have an initial sort or initial filter set? That would cause the delayInit setting to be ignored. Try setting the debug option to true and see which tables are being processed ( i.e. the cache is being built ) and check those specifically for initial sorting or filters.

Also, make sure to update both the filter and pager widgets from the working branch, as they were both updated.

@Fabien04
Copy link
Author

Ok last try i use only that :

$("#listing").tablesorter({  
    theme: 'blue',
    delayInit : true,
    debug: true,          
}).tablesorterPager();

Completed detecting parsers (610ms)
Completed initializing 0 widgets (0ms)
Completed applying 0 widgets (0ms)
Overall initialization time (958ms)
Pager initializing
Pager: no rows for pager to render
Listing : 5677 ms

With a lots of test for empty rows.
I update both filter and pager widget.

So i do some test soon, no more time for this job i need to do another thing.
I tell you soon as possible what i do. Thank you

@Mottie Mottie closed this as completed in 4ef7bcd Jul 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants