RavenDB Logo

Compacting a RavenDB database

One of my RavenDB databases grew to an unrealistic size – 36GB when it contains around 500,000 documents which are mostly small. After some back-and-forth with the RavenDB support team, I was suggested to compact the database. Sounds easy, if you know what you’re doing, since documentation on that is … let’s say lacking… Here’s what you do, for my own future reference…

RavenDB Logo

Using cUrl, do a POST request to http://servername/admin/compact?database=DatabaseName

Here’s a sample call:

cUrl -F 'database=UsersDatabase' http://localhost:8080/admin/compact?database=UsersDatabase

Notice that if you’re using any form of authentication, you need to provide that too. Here’s how it’s done for NTLM Authentication:

cUrl --ntlm --user username:password -F 'database=UsersDatabase' http://localhost:8080/admin/compact?database=UsersDatabase

NOTICE: Your database will be off-line during the compact process and won’t be accessible.