问题
The Question
My question is are there any limitations on the amount of rows that are returned via query using either Mysql or Laravel?
Firstly Im using Laravel 5.2 and i am trying to retrieve my data from my logs table which has recently hit over 10k rows, Now since then (or around that time) the usual laravel syntax to retrieve the data isnt working
Syntax
$logs = Log::all()
return $logs; //This is then handled by Vue.js on the client side
It used to work fine now it doesnt, nothing is returned and no errors are displayed in the chrome devtools, just an empty string.
Ive only just recently been in the database and notice that information is still being added to the logs daily so my code is working still, But when i try to retrieve the information to show it on the client side it doesnt work.
What i think the problem is
Which has lead me to believe that Laravel or MySQL has some sort of limitations on the amount of rows that are retrieved? Im not sure how to check my query limitations and what not.
What i've done
I have already looked over stackoverflow for the answer but I've not found anything useful, I've come across someone saying that 9 million rows is alright as long as the table is correctly indexed etc.
I asked a question before but all the answers and suggestions were incorrect so hopefully this new found information can shed some light on the problem.
回答1:
The problem ended up being that my query Log::all(); was pulling back over 1.1mb of information while my server limit on queries was bang on 1.1mb. Two people helped me to identify and solve the problem.
@RobertoGeuke:
"Can you try to fetch the last 100 rows with
Log::orderBy('id', 'desc')->take(100)->get();and see if that works?You can increase your
take()method with 1000 in steps and see when it fails. It will give the limit a number, maybe it will help."
This helped me clarify that my query was requesting too much information from the database but i still wasn't sure if it was a row limitation or a memory limitation.
@SergChernata:
"You're probably just hitting a memory limit: Laravel Eloquent ORM maximum rows it could retrieve
[Increase Memory Limits?] there's a number of ways: How to increase memory limit for PHP over 2GB?"
This helped me pin point the problem and also gave me options to increase the memory limitation.
来源:https://stackoverflow.com/questions/41571682/limit-on-amount-of-rows-retrieved-mysql-laravel