What's the ->$scope does it defaults to ->get() maybe so it loads all into memory?
Yajra Datatables - Loads all the data from database on server but works well on local environment.
I have used this package for a quite a long time but I am getting a weird issue on a live server. On local environment the response from the controller is correct and response data count is correct for whatever I put in pageLength value. But in Live Server, it is fetching all 20,000+ records.
If I use 10 as a page length then the first query is fast i.e normal, but when i paginate to page 2, again all the records are fetched. and the response size is again huge.
Local - Response Size is 7kb

Live - Response Size is 80mb

-- BlogController.php
$articles = Article::query()
->with(['media', 'editor', 'categories', 'author', 'views'])
->select('articles.*')
->$scope();
return DataTables::of($articles)
->editColumn('title', function ($data) {
return '<div>' . $data->title . '</div>';
})
->addIndexColumn()
->rawColumns(['title'])
->make(TRUE);
-- Blade File
$(document).ready(() => {
let articleTable = $("#article-tables").DataTable({
processing: true,
serverSide: true,
"scrollX": true,
"scrollY": false,
responsive: false,
paging: true,
pageLength: 50,
ajax: {
url: "{{ route('api.cms.article.datatables') }}",
type: "GET",
},
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false},
{data: 'title', name: 'title', orderable: false},
],
"fnDrawCallback": function () {
initSwitchToggler()
initTooltip()
initPopOver()
}
});
});
Operating System : Oracle Linux (Live) | MacOs (Local) PHP Version : 8.0.19 Laravel Version : 8.83 Laravel-Datatables Version: 1.5
Please or to participate in this conversation.