rethinkdb: “RqlRuntimeError: Array over size limit” even when using limit()

两盒软妹~` 提交于 2019-12-01 21:32:13

问题


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"))

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. How can I get a constant number of the latest documents by date?

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


回答1:


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.




回答2:


This code is decision problem.

ro:= r.RunOpts{ArrayLimit: 500000}
r.DB("wrk").Table("log").Run(sessionArray[0],ro)




回答3:


// This code for Python r.db('awesome_db').table("main").run(sesion, r.runOpts{arrayLimit: 500000})



来源:https://stackoverflow.com/questions/21102344/rethinkdb-rqlruntimeerror-array-over-size-limit-even-when-using-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!