php


Laravel/DataTable fails at displaying ~80,000 rows


I'm trying to use DataTables with server side processing to display 80,000 rows (paginated), but Laravel crashes with the error:
PHP Fatal error: Maximum execution time of 300 seconds exceeded in /Users/fin/Documents/dev/evway-new/vendor/nesbot/carbon/src/Carbon/Carbon.php on line 291.
Here's my controller method where I'm fetching the rows:
public function data()
{
$employees = Employee::get(); // ~80,000 employees
return Datatables::of($employees)
->edit_column('created_at',function(Employee $employee) {
return $employee->created_at->diffForHumans();
})
->add_column('actions',function($employee){
$actions = '</i>
</i>';
$actions .= '<i class="livicon" data-name="plus" data-size="18" data-loop="true" data-c="#f56954" data-hc="#f56954" title="clone employee"></i>';
$actions .= '<i class="livicon" data-name="remove" data-size="18" data-loop="true" data-c="#f56954" data-hc="#f56954" title="delete employee"></i>';
return $actions;
}
)
->make(true);
}
and here is my JS where I'm configuring DataTable:
$(function() {
var table = $('#table').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('admin.employees.data') !!}',
columns: [
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' },
{ data: 'status', name: 'status' },
{ data: 'actions', name: 'actions', orderable: false, searchable: false }
]
});
});
What am I doing wrong? Am I fetching the Employees from the DB in the wrong way? is get() a bad idea?
I haven't really worked with Datatable plugin But your very first statement is the culprit. $employees = Employee::get(); // ~80,000 employees .. This loads all 80k records into the memory. And then you pass this collection to Datatables::of() method. Instead of this I think you should be using Datatables::of(Employee::query()) , which I am assuming will handle the pagination and will load only the required number of employees –
I think you should increase your php.ini
max_execution_time = 360 ; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE)
max_input_time = 120 ; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 128M

Related Links

Twitter API status update don't work as cron
Changing multidimensional array's values into a new array
UTF-8 not compatible [duplicate]
Issue with IE asking to open or save file
PHP old syntax issue
How to implement a PHP code to a html button?
php 5.6.7 fwrite vs fputs utf-8 encoding
How to Complete the program to display “A private static variable” without instantiating the class
PHP MYSQL search always brings back 0 results
Error upgrading Magento CE 1.6.2 to 1.9.1
How to do a regex for $ symbol and 1-6 all capital letters for a stock symbol?
PHP / SOAP Get values of array in stdClass
Fetching all .ch files from FTP into website
PDOException could not found driver (SQLite)
Use CodeIgniter to render to a view at a specific anchor
I want to achieve in laravel 5 the same thing as the cakephp of HttpSocket ()

Categories

HOME
google-chrome
amazon-web-services
python-2.7
automapper
exchange-server
code-formatting
biztalk
openfoam
repair
anchor
scrape
graphdb
csrf
boomi
cloudsim
anova
fido-u2f
kamailio
generator
rxjs5
quantitative-finance
candlestick-chart
firemonkey-style
high-availability
prompt
hdmi
msdeploy
audit
cucumber-junit
overwrite
osx-lion
cloudera-manager
image-optimization
devtools
cmis
transform
love2d
unification
export-to-pdf
swfupload
cloudera-sentry
1wire
nothing
lightning-workbench
mura
http-basic-authentication
bpms
controllers
system.net.mail
seccomp
raw-sockets
android-async-http
gulp-uglify
seadragon
certificate-authority
m4
grinder
http.client
vdm-sl
swagger-maven-plugin
angular-amd
karma-coverage
deque
nsmutabledata
nanomsg
sql-processor
famo.us
iodocs
windows-rt
box2dweb
communicate
forio-contour
jchartfx
application-blocks
discovery
boinc
yii-booster
xs
cyrillic
ip-geolocation
gitx
playorm
audiotoolbox
system-information
struts2-s2hibernate
gamesalad
net-use
cassini
3-tier
ixmldomdocument
raw-data
asdoc
projectpier
prism-2
acceleration
jvm-bytecode

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile