You are currently browsing legacy 5.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Clean Change Vector

  • A database's change vector contains entries from each instance of the database in the database group. However, even when an instance no longer exists (because it was removed or replaced) its entry will remain in the database change vector. These entries can build up over time, leading to longer change vectors that take up unnecessary space.

  • UpdateUnusedDatabasesOperation lets you specify the IDs of database instances that no longer exist so that their entries can be removed from the database change vector.

  • This operation does not affect any documents' current change vectors, but from now on when documents are modified or created their change vector will not include the obsolete entries.


public UpdateUnusedDatabasesOperation(string database, HashSet<string> unusedDatabaseIds)
Parameter Type Description
database string Name of the database
unusedDatabaseIds HashSet<string> The database IDs to be removed from the change vector


In the 'General Stats' view in the management studio, you can see your database's current change vector (it's the same as the change vector of the database's most recently updated/created document).

Below we see the change vector of an example database "NorthWind". It includes three entries: one of the NorthWind instance currently housed on cluster node A (whose ID begins with N79J...), and two of instances that were also previously housed on node A but which no longer exist.

Fig. 1

Database change vector displayed in the General Stats view

This code removes the obsolete entries specified by their database instance IDs:

                new UpdateUnusedDatabasesOperation(documentStore.Database, new HashSet<string>
await documentStore.Maintenance.Server.SendAsync(
                new UpdateUnusedDatabasesOperation(documentStore.Database, new HashSet<string>

Next time a document is modified, you will see that the database change vector has been cleaned.

Fig. 2

Database change vector after the operation