RavenDB 4.0Unbounded results sets
Unbounded result sets are a pet peeve of mine. I have seen them destroy application performance more then once. With RavenDB, I decided to cut that problem at the knees and placed a hard limit on the number of results that you can get from the server. Unless you configured it differently, you couldn’t get more than 1,024 results per query. I was very happy with this decisions, and there have been numerous cases where this has been able to save an application from serious issues.
Unfortunately, users hated it. Even though it was configurable, and even though you could effectively turn it off, just the fact that it was there was enough to make people angry.
Don’t get me wrong, I absolutely understand some of the issues raised. In particular, if the data goes over a certain size we suddenly show wrong results or error, leaving the app in a “we need to fix this NOW”. It is an easy mistake to make. In fact, in this blog, I noticed a few months back that I couldn’t get entries from 2014 to show up in the archive. The underlying reason was exactly that, I’m getting the number of items per month, and I’ve been blogging for more than 128 months, so the data got truncated.
In RavenDB 4.0 we removed the limit. If you don’t specify a limit in a query, you’ll get exactly how many results there are in the database. You can ask RavenDB to raise an error if you didn’t specify a limit clause, which is a way for you to verify that you won’t run into this issue in production, but it is off by default and will probably better match the new user expectations.
The underlying issue of loading too many results is still there, of course. And we still want to do something about it. What we did was raise alerts.
I have made a query on a large set (160,000 results, about 400 MB in all) and the following popped up in the RavenDB Studio:
This tells the admin that it have some information that it needs to look at. This is intentionally non obtrusive.
When you click on the notifications, you’ll get the following message.
And if you’ll click on the details, you’ll see the actual details of the operations that triggered this warning.
I actually created an issue so we’ll supply you with more information (such as the index, the query, duration and the total size that it generated over the network).
I think that this gives the admin enough information to act upon, but will not cause hardship to the application. This make it something that we Should Fix instead Get the OnCall Guy.