MongoDB Index Operations Cheat Sheet

Background builds and pruning

Last Updated: November 21, 2025

Focus Areas

Focus
Trigger background builds
Monitor usage with system.profile

Commands & Queries

db.collection.createIndex({ userId: 1 }, { background: true })
Build index
db.collection.dropIndex('idx')
Drop index
db.system.profile.find()
Review slow queries

Summary

Background builds keep MongoDB online while indexes refresh.

💡 Pro Tip: Enable profiler to find unused indexes before deleting.
← Back to Databases & APIs | Browse all categories | View all cheat sheets