Side by side indexes in RavenDB
One of the new features we just finished working on is the notion of side by side indexes. You can see how to access it on the image, but what is it?
As usual lately, this is part and parcel of our current focus in operations. The basic notion is simple. You have an index in production that you want to update, but just updating it on the fly isn’t going to work.
The problem is that updating the index force a complete reindexing of the data, and in most production systems, we have enough documents that this can take a while. That means that during the indexing process, your application would see partial results, and may see that for a while. Common work around was to add support in your application to change the index name, so you would create a new index, wait for it to become non stale and then you would update the application configuration so you would query the new index.
With the side by side option, this is all handled for you. When you save an index with side by side option, you get the following options:
Basically, we create the index under a temporary name, and start indexing it. And you can choose when RavenDB automatically will make the switch (note that there is an OR condition between those, so any of those that match would work).
This give you the option of changing an index, and have no interruptions of service, because RavenDB will take care of all of that for you. You can even mark an index with a “force to change via side-by-side”, which will protect it from accidental changes.
Comments
Typo: side-by-size
What use cases is this actually useful? Performance tuning only? If I want to add a new indexed property for my application to query conditionally, obviously the old index isn't going to cut it.
Nice!
Why not add "OR" between the three conditions? Less documentation to write..
Regards Daniel
Is this functionality available programmatically - through "IndexCreation.CreateIndexes(...)" for example?
Daniel, Certainly it is. You do that by defining a IndexReplaceInformation document with the prefix: Raven/Indexes/Replace/ + indexName
Jahmai, Provided your changes are backwards compatible, you can change the index, and check it in, so it starts indexing well before its needed. Once its stable you can deploy code that uses it.
Just wanted to make sure you are aware the "screen shot" or mock up says Side-By-SIZE not Side-by-Side as pointed out by Jahmai.
Looks like a very nice feature :)
Online index changes, nice.
The still one remaining major pain point is if you need to change your index substantially that queries inherently mismatch between v1 and v2.
I don't really have a solution to that other than get index v2 running then swap the code path using a toggle flag or something.
Chris, I'm not sure that this issue can be solved. If your queries require change, that is a client side topic, beyond what RavenDB can do.
Comment preview