neighbourhoodie-nnh-logo
Consulting & Development CouchDB Support & Services Greenkeeper Training

Sharding — Reducing the Number of Shards posted 06/10/2020 by The Neighbourhoodie CouchDB Team

This post is part of our CouchDB Tips Series (RSS) that we publish every week. The team at Neighbourhoodie works on and with CouchDB every day and we are happy to pass on all the tips and tricks we learn along the way. If you like what you see, check out our Professional Services for CouchDB, including production support and training. If you want to continuously ensure that your CouchDB is running optimally, sign up for Opservatory, our 24/7 CouchDB analysis and diagnostics tool.

In contrast to increasing the number of shards for a database, reducing the number of shards is not a built-in operation. In addition, as shard splitting is only available in CouchDB 3.x and later, this advice is good for version 2.x as well.

Neighbourhoodie has built the couch-continuum tool that automates the bulk changing of database parameters, including the number of shards for a database:

This tool can both increase and decrease the number of shards for a database in both CouchDB 2.x and 3.x.

There is just one caveat: it can not operate without taking the original database offline for the duration of its restore. So you can only do this during a maintenance window.