HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Mongodb: Possible to enlarge a capped collection?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
enlargemongodbcollectionpossiblecapped

Problem

If a collection is created as capped, is it possible to increase the cap without losing data?

Or to increase the cap without recreating the whole collection?

Thanks

Solution

No, you can't alter a capped collection size to make it larger (or smaller for that matter) without dropping it and recreating it - it is created with a fixed size. However you could use mongodump to dump out the existing data, then drop the collection, recreate it with the larger size and then restore the dumped data.

Assuming you are making it bigger, all the data will fit in the new collection. Unfortunately, this will mean that you will need to stop writing to that collection for the duration of this work, there is no way to do it without taking some down time for the collection in question.

There is an existing feature request to add resizing capabilities to MongoDB, but as of writing this it is not yet scheduled. See here for voting and watching purposes:

https://jira.mongodb.org/browse/SERVER-1864

Context

StackExchange Database Administrators Q#86820, answer score: 7

Revisions (0)

No revisions yet.