RDB4 - Projection exception: Jint / "The maximum number of statements executed have been reached."

202 views
Skip to first unread message

Rusty Moorman

unread,
Aug 17, 2018, 3:12:11 PM8/17/18
to RavenDB - 2nd generation document database
I'm running into an exception with a fairly simple projection involving a nested list and some .firstOrDefault() let statements. This only occurs when the nested collection is sufficiently large (~100 items).

I've attached a failing unit test, tested against 4.0.6 / 4.0.7 nightly / 4.1.0 nightly.
ProjectionLargeNestedCollectionException.cs

Paweł Pekról

unread,
Aug 17, 2018, 3:39:43 PM8/17/18
to rav...@googlegroups.com
Hi,

starting from RavenDB 4, such projections are handled via JavaScript engine called Jint. By default RavenDB limits number of steps that this engine can execute to 10_000. You can increase that limit by increasing the 'Patching.MaxStepsForScript' configuration option.


Please note that exceeding the 10_000 default limit is often a good indication that JS code (in this case projection) is fairly complex. In your case the projection looks simple, but for each retrieved order you need to loop each of the OrderItems (100) and for each of those items you need to scan through categories (100) to find a desired category and then retrieve the result.

Hope that helps,
P.

On Fri, Aug 17, 2018 at 9:12 PM Rusty Moorman <ru...@eventbooking.com> wrote:
I'm running into an exception with a fairly simple projection involving a nested list and some .firstOrDefault() let statements. This only occurs when the nested collection is sufficiently large (~100 items).

I've attached a failing unit test, tested against 4.0.6 / 4.0.7 nightly / 4.1.0 nightly.

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maxim Buryak

unread,
Aug 19, 2018, 10:29:14 AM8/19/18
to rav...@googlegroups.com
Also, I'd like to add that you may want to consider movig that computation to indexin time, by generating that value and stating that the field is a "stored" field ( see https://ravendb.net/docs/article-page/4.0/csharp/studio/database/indexes/indexes-overview#fields-configuration-options), this could be beneficial, in cases when CategoryList documents are rarely changed, so you won't enter massive indexing phases due to modification of a popular CategoryList

Oren Eini (Ayende Rahien)

unread,
Aug 20, 2018, 6:47:52 AM8/20/18
to ravendb
Another approach would be to model the Categories as a dictionary, which would avoid the linear search per Order Line.

On Sun, Aug 19, 2018 at 6:28 PM, Maxim Buryak <ma...@ravendb.net> wrote:
Also, I'd like to add that you may want to consider movig that computation to indexin time, by generating that value and stating that the field is a "stored" field ( see https://ravendb.net/docs/article-page/4.0/csharp/studio/database/indexes/indexes-overview#fields-configuration-options), this could be beneficial, in cases when CategoryList documents are rarely changed, so you won't enter massive indexing phases due to modification of a popular CategoryList
On Fri, Aug 17, 2018 at 10:39 PM Paweł Pekról <ppe...@ravendb.net> wrote:
Hi,

starting from RavenDB 4, such projections are handled via JavaScript engine called Jint. By default RavenDB limits number of steps that this engine can execute to 10_000. You can increase that limit by increasing the 'Patching.MaxStepsForScript' configuration option.


Please note that exceeding the 10_000 default limit is often a good indication that JS code (in this case projection) is fairly complex. In your case the projection looks simple, but for each retrieved order you need to loop each of the OrderItems (100) and for each of those items you need to scan through categories (100) to find a desired category and then retrieve the result.

Hope that helps,
P.
On Fri, Aug 17, 2018 at 9:12 PM Rusty Moorman <ru...@eventbooking.com> wrote:
I'm running into an exception with a fairly simple projection involving a nested list and some .firstOrDefault() let statements. This only occurs when the nested collection is sufficiently large (~100 items).

I've attached a failing unit test, tested against 4.0.6 / 4.0.7 nightly / 4.1.0 nightly.

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages