Over a million developers have joined DZone.

How to Control Your Expanding MongoDB Database

DZone's Guide to

How to Control Your Expanding MongoDB Database

· Performance Zone
Free Resource

Transform incident management with machine learning and analytics to help you maintain optimal performance and availability while keeping pace with the growing demands of digital business with this eBook, brought to you in partnership with BMC.

The key question asked by DJ Walker-Morgan in this recent post from MongoHQ is an important one: do you actually know how big your database is? As Walker-Morgan points out, most people probably have a number they can point to, but the number may not be communicating exactly what they think it is. However, it really should:

If it’s on your own disk drive you may not be bothered about overly large databases, but in the cloud where you are billed on the amount of resources consumed, we’re talking about real money and how to save it.

Walker-Morgan illustrates the problem, then, by creating an example database and running some experiments. One issue Walker-Morgan observes, for example, is a misunderstanding of the sometimes-inconsistency between total data and database size (in MongoDB, at least). This can occur when collections are deleted, because the database hangs on to the space freed up by removing the data, because it assumes it will be filled with new records. It's simple fix, but if you're not aware that the database is doing that, you may be seeing some inflated sizes.

In Walker-Morgan's example database, at least, he manages to reduce the total size from 2.28 GiB to 112 MiB - that's a pretty serious reduction!

In the full post, Walker-Morgan also looks at a few other ways to control an ever-expanding database and keep things from getting out of hand, as well as some quick tips on the various methods that can help. Do what you can to optimize performance as well, and you'll be doing well with MongoDB.

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}