简体   繁体   English

限制MySql,Laravel检索的行数

[英]Limit on amount of rows retrieved MySql, Laravel

The Question 问题

My question is are there any limitations on the amount of rows that are returned via query using either Mysql or Laravel? 我的问题是使用Mysql或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 首先,我使用Laravel 5.2,我试图从最近击中超过1万行的日志表中检索我的数据,此后(或大约在那时),通常的laravel语法来检索数据是行不通的

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. 它以前可以正常工作,现在不工作,没有返回任何内容,并且在chrome devtools中没有显示任何错误,只是一个空字符串。

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? 哪个使我相信Laravel或MySQL对检索的行数有某种限制? 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. 我已经在stackoverflow上找到了答案,但是我没有发现任何有用的东西,我碰到有人说只要对表进行正确索引等就可以使用900万行。

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. 我之前问过一个问题,但是所有答案和建议都不正确,因此希望这些新发现的信息可以为您解决这个问题。

The problem ended up being that my query Log::all(); 问题最终是我的查询Log::all(); was pulling back over 1.1mb of information while my server limit on queries was bang on 1.1mb. 在我的服务器查询限制为1.1mb的同时,又拉回了1.1mb的信息。 Two people helped me to identify and solve the problem. 有两个人帮助我确定并解决了问题。

@RobertoGeuke: @RobertoGeuke:

"Can you try to fetch the last 100 rows with Log::orderBy('id', 'desc')->take(100)->get(); and see if that works? “您能否尝试使用Log::orderBy('id', 'desc')->take(100)->get();来获取最后100行,看看是否可行?

You can increase your take() method with 1000 in steps and see when it fails. 您可以逐步将take()方法增加1000,并查看何时失败。 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: @SergChernata:

"You're probably just hitting a memory limit: Laravel Eloquent ORM maximum rows it could retrieve “您可能刚刚达到内存限制: Laravel雄辩的ORM可以检索的最大行数

[Increase Memory Limits?] there's a number of ways: How to increase memory limit for PHP over 2GB? [增加内存限制?]有多种方法: 如何将PHP的内存限制增加到2GB以上? "

This helped me pin point the problem and also gave me options to increase the memory limitation. 这帮助我查明了问题所在,还为我提供了增加内存限制的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM