When your data set is larger then a couple of thousands of rows it can’t effectively be loaded in the page from Google Spreadsheet, CSV, Excel file, or other sources: each of these methods first read the data from the source, then print out complete table data on your page; so as the row count grows it makes both page generation time on server side and page load and initialisation time on client side slower and slower. And if your host has a certain memory or timeout limit defined for PHP scripts it can even ‘break’ the page because script would try to allocate more memory then it’s allowed. But no worries, wpDataTables has a solution for that – server-side processing!
Server side processing is available only for MySQL-based tables, it means that all filtering, sorting, pagination, and other data processing routines will be delegated to MySQL engine, and only several rows will be fetched from the server by a background AJAX request at a time.
Please refer to this documentation section for full explanation about the Server-side processing feature.
In this tutorial we will use a data set of 10.000 rows, you can download the SQL dump using this link.
A table without server-side processing with 10.000 rows would load for probably 3-5 minutes (if it would load at all). Let’s see how it performs with server-side processing enabled. Just try to filter or sort the table.
The step-by-step tutorial on how to create this table follows.
MySQL table with server-side processing example
|1||Yoshio W. Roach||Cakewalk||30 Oct 2014||Product Five||10||136,00|
|2||Sawyer M. Good||Cakewalk||26 Nov 2012||Product Seven||1||1.806,00|
|3||Flynn M. Bryant||Sibelius||23 Sep 2013||Product Four||4||154,00|
|4||Stephanie Q. Robles||Adobe||25 Mar 2014||Product Three||1||1.576,00|
|5||Lacey T. Rocha||Borland||10 Mar 2013||Product Five||7||1.990,00|
|6||Garrison J. Foreman||Adobe||04 Apr 2014||Product Three||3||810,00|
|7||Maisie M. Park||Macromedia||21 Feb 2014||Product Five||10||1.202,00|
|8||Salvador Y. Jennings||Lycos||01 May 2014||Product Two||1||834,00|
|9||Valentine D. Knight||Cakewalk||18 Dec 2012||Product Six||3||1.028,00|
|10||Abdul L. Brewer||Borland||17 Jan 2014||Product Six||3||1.100,00|