RavenDB 4.0: Unbounded Results Sets
An alert for large results sets in the most recent RavenDB database version shows admins where unbounded results may be impacting performance.
Join the DZone community and get the full member experience.
Join For FreeUnbounded result sets are a pet peeve of mine. I have seen them destroy application performance more than 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 decision, 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 has some information that it needs to look at. This is intentionally unobtrusive.
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 makes it something that we Should Fix instead Get the OnCall Guy.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments