jQuery Data table is very slow with request to Server Side
jQuery Data table is very slow with request to Server Side
I have used jQuery DataTable in my site that displays all the law list for our clients, I am currently using jQuery DataTable plugin for pagination, searching and sorting. It works fine except one problem Data Loading is very slow when i click on pagination many time. I am really not sure what is problem.
Cheers! Thanks in advance!
Here my website: http://law.darwinkh.org/en/legal-database
Here my code
if($('#legal-database').length) {
var tableLaw = jQuery('#legal-database').dataTable({
"processing": true,
"serverSide": true,
"oLanguage": {
"sSearch": "Search",
"sProcessing": "Processing...",
"sLoadingRecords": "Processing...",
"sLengthMenu": "Show _MENU_ entries",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sEmptyTable": "No data available in table",
"oPaginate": {
"sFirst": "First",
"sLast": "Last",
"sNext": "Next",
"sPrevious": "Previous"
}
},
"ajax": {
"url": "http://law.darwinkh.org/en/legal-database/law-grid-data",
"type": "POST",
"data": {
catid: 0 },
"cache": false
},
"columns": [
{ "data": "id" },
{ "data": "title" },
{ "data": "year" },
{ "data": "type" },
{ "data": "slug" }
],
"order": [[ 0, "desc" ]],
initComplete: function () {
` }`
});
}
Answers
It looks like the server-side script (
law-grid-data
) is hanging sometimes (43s I just saw!). As to why that would be, I'm not sure since I can't see the script. Perhaps a database lock? Either way, you'd need to debug the script as the problem appears to be there.Allan
Thanks allan for response. Do you want see php code or mysql query? could you advise how to show debug script?
I don't really provide support for custom scripts on the server-side.
I would suggest enabling the MySQL slow query log if it isn't already and just check if it is the SQL query that is taking the time (my guess is that it will be this).
If it is, then you'd need to debug the SQL - probably using
EXPLAIN
. It might be that there is a lock somewhere from someone else doing a write, or if it is in a cluster than it might be locked.Allan