Rethinkdb: "RqlRuntimeError: array with size limit" even when using limit ()

I am trying to access a constant number of recent table documents sorted by the date key. Please note that the date, unfortunately, was implemented (not by me ...), so the value is set as a string, for example, "2014-01-14", or sometimes "2014-01-14 22:22:22", I get an error "RqlRuntimeError: Array over size limit 102173"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 at the moment I only need the last 50:

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

The end ended with the same error. So my questions are:

  • How can I get a constant number of recent documents by date?

  • Is row-based date sorting possible? Does this question relate to my first question?

+3
source share
1 answer

The reason you get the error message is because it orderByevaluates to limit, so it arranges the entire table in memory that is above the limit of the array. The way to fix this is to use and index. Try the following:

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

This should be equivalent to what you have, but uses an index, so it does not require loading the entire table into memory.

+3
source

All Articles