rethinkdb:“RqlRuntimeError:数组超出大小限制";即使使用 limit() [英] rethinkdb: "RqlRuntimeError: Array over size limit" even when using limit()

查看:42
本文介绍了rethinkdb:“RqlRuntimeError:数组超出大小限制";即使使用 limit()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问按日期"键排序的表的恒定数量的最新文档.请注意,不幸的是,日期已实现(不是由我...),因此该值被设置为字符串,例如2014-01-14",或有时2014-01-14 22:22:22".使用以下查询时,我收到 "RqlRuntimeError: Array over size limit 102173" 错误消息:

I'm trying to access a constant number of the latest documents of a table ordered by a "date" key. Note that the date, unfortunately, was implemented (not by me...) such that the value is set as a string, e.g "2014-01-14", or sometimes "2014-01-14 22:22:22". I'm getting a "RqlRuntimeError: Array over size limit 102173" error message when using the following query:

r.db('awesome_db').table("main").orderBy(r.desc("date"))

我试图通过指定一个常量限制来解决这个问题,因为现在我只需要最新的 50 个:

I tried to overcome this problem by specifying a constant limit, since for now I only need the latest 50:

r.db('awesome_db').table("main").orderBy(r.desc("date")).limit(50)

以同样的错误结束.所以,我的问题是:

Which ended with the same error. So, my questions are:

  1. 如何按日期获取恒定数量的最新文档?

  1. How can I get a constant number of the latest documents by date?

是否可以按基于字符串的日期字段排序?这个问题和我的第一个问题有关吗?

Is ordering by a string based date field possible? Is this issue has something to do with my first question?

推荐答案

这里出现错误的原因是 orderBylimit 之前被评估,所以它订购内存中超过数组限制的整个表.解决这个问题的方法是使用和索引.尝试执行以下操作:

The reason you get an error here is that the orderBy gets evaluated before the limit so it orders the entire table in memory which is over the array limit. The way to fix this is by using and index. Try doing the following:

table.indexCreate("date")
table.indexWait()
table.orderBy({index: r.desc("date")}).limit(50)

这应该等同于您在那里拥有的内容,但使用了索引,因此不需要将整个表加载到内存中.

That should be equivalent to what you have there but uses an index so it doesn't require loading the entire table into memory.

这篇关于rethinkdb:“RqlRuntimeError:数组超出大小限制";即使使用 limit()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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