Firebase limitToLast()是否会随着孩子的记录数增加而花费更长的时间? [英] Does Firebase limitToLast() take increasing longer as a child's record count grows?

查看:53
本文介绍了Firebase limitToLast()是否会随着孩子的记录数增加而花费更长的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Firebase,带有一个名为lines的孩子. lines包含大约50万条记录,每个记录有8个键/值对.

I have a Firebase with a child named lines. lines contains about 500k records, each with eight key/value pairs.

当我的应用加载时,它会尝试使用以下方法获取lines中的最后128条记录:

When my app loads, it tries to grab the last 128 records in lines using the following:

fb = new Firebase("https://myapp.firebaseio.com/lines");
fb.limitToLast(128).once("value", function(snapshot) {
  // do something
});

我发现我的应用程序的初始加载时间越来越慢.唯一更改的是lines下有多少条记录.随着lines下记录的数量增加,我是否应该期望limitToLast()花费的时间越来越长?如果是这样,我可以尝试随着时间的推移删除记录,但是给人的印象是limitToLast()查询只能获取指定的内容.

I'm finding that my app's initial load time is getting slower and slower. The only thing that's changing is how many records there are under lines. Should I expect limitToLast() to take increasingly longer as the number of records under lines goes up? If so, I can try and cull the records over time, but I was under the impression that the limitToLast() query would only grab what is specified.

推荐答案

随着行下记录数量的增加,我是否希望limitToLast()花费的时间更长?

Should I expect limitToLast() to take increasing longer as the number of records under lines goes up?

是的.继续阅读为什么会这样.

Yes. Keep reading for why that is.

如果是这样,我可以尝试随着时间的推移剔除记录

If so, I can try and cull the records over time

那确实是推荐的解决方案.

That is indeed the recommended solution.

但是我给人的印象是limitToLast()查询只会获取指定的内容.

but I was under the impression that the limitToLast() query would only grab what is specified.

它将仅发送与查询匹配的子项到客户端.但是要知道要发送给哪个孩子,需要考虑他们所有人.因此,尽管可以使用limitToLast()来减少带宽,但它们并不能减少Firebase服务器上的磁盘IO".

It will only send the children matching your query to the client. But to know which children to send it needs to consider all of them. So while limitToLast() can be used to reduce bandwidth, they don't reduce "disk IO" on the Firebase servers.

我将磁盘IO"放在引号中,因为此处涉及许多因素.但总的来说:让数据库考虑更多的节点会使其变慢.或相反:如果您减少了数据库的工作量,则可以更快地完成工作.

I put "disk IO" in quotes there, because there are many factors involved here. But in general: giving the database more nodes to consider, will make it slower. Or the opposite: if you give the database less work to do, it will be done with that work faster.

这篇关于Firebase limitToLast()是否会随着孩子的记录数增加而花费更长的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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