限制MySql,Laravel检索的行数 [英] Limit on amount of rows retrieved MySql, Laravel

查看:73
本文介绍了限制MySql,Laravel检索的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

我的问题是,使用Mysql或Laravel通过查询返回的行数是否有限制?

My question is are there any limitations on the amount of rows that are returned via query using either Mysql or Laravel?

首先,我使用Laravel 5.2,我试图从最近超过1万行的日志表中检索我的数据,此后(或大约在那时),通常的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

语法

$logs = Log::all()

return $logs; //This is then handled by Vue.js on the client side

它以前可以正常工作,现在不工作,在chrome devtools中什么也没有返回,也没有错误显示,只是一个空字符串.

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.

我认为问题所在

哪个使我相信Laravel或MySQL对检索到的行数有某种限制?我不确定如何检查查询限制,什么不知道.

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.

我做了什么

我已经在stackoverflow上找到了答案,但是我没有发现任何有用的东西,我碰到有人说只要表已正确索引就可以有900万行.

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.

推荐答案

问题最终是我的查询Log::all();回撤了1.1mb的信息,而我对查询的服务器限制是1.1mb.两个人帮助我确定并解决了问题.

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:

@RobertoGeuke:

您可以尝试使用Log::orderBy('id', 'desc')->take(100)->get();获取最后100行,看看是否行得通吗?

"Can you try to fetch the last 100 rows with Log::orderBy('id', 'desc')->take(100)->get(); and see if that works?

您可以增加 您的take()方法(步长为1000),并查看失败的时间.它会 给限制一个数字,也许会有所帮助."

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:

@SergChernata:

您可能刚刚达到内存限制: Laravel可以检索的雄辩口才ORM最大行

"You're probably just hitting a memory limit: Laravel Eloquent ORM maximum rows it could retrieve

[增加内存限制?]有多种方法: 如何为超过2GB的PHP增加内存限制? "

[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.

这篇关于限制MySql,Laravel检索的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆