iLaYa  ツ
iLaYa ツ

Reputation: 4017

Taking more time to fetch records using DataTables

I am using DataTables for Paginating my result. Here is the code i am using

$('#datatable_paging').dataTable(
                {
                    "sPaginationType": "full_numbers",
                    "bLengthChange": false,
                    "iDisplayLength":15,
                    "bFilter": true,
                    "bSort": false,
                    "bInfo": true,
                    "bAutoWidth": false
                    }
                );

Now, it's working fine but the problem is it's taking time to load the result, because i am fetching all the records without LIMIT(Example: 2000). I did search in the internet and i found this links.

  1. DataTables server-side processing example for PHP
  2. DataTables server-side processing example for Code-Igniter

Before process the server side coding i want to make sure that is there any settings to LIMIT my query with the code which i have posted above?

Upvotes: 2

Views: 2262

Answers (2)

Nikhil Agrawal
Nikhil Agrawal

Reputation: 285

You can put a LIMIT in the server side database query, it will reduce the time required to transfer data from database to PHP and then form php to js. Please let me know if there is any constrain which can hinder the use of LIMIT clause.

Upvotes: 0

Ben Thurley
Ben Thurley

Reputation: 7141

You need to look at server side processing to load the records.
http://datatables.net/examples/data_sources/server_side.html

This way you only need return enough records to display one page and each time you click next it will do a quick ajax request to get the next lot of records.

Upvotes: 2

Related Questions