What is the maximum size of a single document in MongoDB?
The maximum size of a single document in MongoDB is 16 megabytes (MB).
Click to reveal answer
intermediate
Why should you avoid frequent growth of a document's size in MongoDB?
Frequent growth can cause document moves in storage, which slows down performance and increases fragmentation.
Click to reveal answer
intermediate
How does MongoDB handle document growth internally?
MongoDB allocates extra space when a document grows to reduce the need for moving it frequently, but if growth exceeds this space, the document is moved to a new location.
Click to reveal answer
beginner
What is a common strategy to manage large or growing data in MongoDB documents?
Use references or subdocuments to split large data into smaller parts instead of growing a single document too large.
Click to reveal answer
beginner
How does document size affect MongoDB query performance?
Larger documents take more time to read and write, which can slow down queries and increase resource use.
Click to reveal answer
What is the maximum size allowed for a MongoDB document?
A1 MB
B100 MB
C16 MB
D512 KB
✗ Incorrect
MongoDB limits each document to 16 megabytes to ensure efficient storage and retrieval.
What happens if a document grows beyond its allocated space in MongoDB?
AIt is moved to a new location with more space
BIt is deleted automatically
CIt causes the database to crash
DIt stays in place and overwrites data
✗ Incorrect
MongoDB moves the document to a new location with enough space to accommodate the growth.
Why is it better to split large data into smaller documents or references?
ATo avoid hitting the document size limit and improve performance
BBecause MongoDB does not support large documents
CTo make queries slower
DTo increase storage costs
✗ Incorrect
Splitting data helps keep documents within size limits and improves read/write efficiency.
How does document size affect query speed in MongoDB?
ADocument size has no effect
BLarger documents slow down queries
CSmaller documents slow down queries
DQueries are faster with larger documents
✗ Incorrect
Larger documents require more time to read and write, slowing down queries.
What is a sign that a document is growing too frequently?
ADecreased storage use
BFaster query responses
CAutomatic document compression
DIncreased fragmentation and slower performance
✗ Incorrect
Frequent growth causes fragmentation and slows down database operations.
Explain how MongoDB handles document size limits and what happens when a document grows beyond its allocated space.
Think about storage space and document relocation.
You got /4 concepts.
Describe strategies to manage document growth and maintain good performance in MongoDB.
Consider how to keep documents small and efficient.
You got /4 concepts.
Practice
(1/5)
1. What is the main reason to keep MongoDB documents reasonably small?
easy
A. To make documents harder to read
B. To avoid using indexes
C. To increase the number of collections
D. To improve database speed and reduce storage costs
Solution
Step 1: Understand document size impact
Larger documents take more space and slow down database operations.
Step 2: Connect size with performance and cost
Smaller documents improve speed and reduce storage needs, saving costs.
Final Answer:
To improve database speed and reduce storage costs -> Option D
Quick Check:
Small documents = faster and cheaper [OK]
Hint: Smaller documents mean faster queries and less storage [OK]
Common Mistakes:
Thinking bigger documents are always better
Confusing collections with document size
Ignoring storage cost impact
2. Which MongoDB command shows statistics including average document size and storage size?
easy
A. db.collection.stats()
B. db.collection.insert()
C. db.collection.find()
D. db.collection.update()
Solution
Step 1: Identify command for collection stats
The command db.collection.stats() returns detailed stats about the collection.
Step 2: Confirm it includes document size info
This command shows average document size, storage size, and growth info.
Final Answer:
db.collection.stats() -> Option A
Quick Check:
Stats command = db.collection.stats() [OK]
Hint: Use .stats() to check collection size and growth info [OK]
Common Mistakes:
Using find() which only queries documents
Confusing insert() or update() with stats
Not knowing stats() returns size info
3. Given a collection with documents growing in size over time, what will db.collection.stats() likely show?
medium
A. Increasing avgObjSize and storageSize values
B. Decreasing avgObjSize and storageSize values
C. No change in avgObjSize but increasing storageSize
D. Only the number of documents changes
Solution
Step 1: Understand document growth effect
As documents grow, their average size (avgObjSize) increases.
Step 2: Connect growth to storage size
More or bigger documents increase storageSize to hold data.
Final Answer:
Increasing avgObjSize and storageSize values -> Option A
Quick Check:
Growth means bigger avgObjSize and storageSize [OK]
Hint: Growth means both average document and storage sizes rise [OK]
Common Mistakes:
Assuming storage size stays constant
Thinking avgObjSize decreases with growth
Ignoring storage size changes
4. You run db.collection.stats() but get an error. Which is a likely cause?
medium
A. You used find() instead of stats()
B. You misspelled the collection name
C. You forgot to connect to MongoDB
D. You ran stats() on a database instead of a collection
Solution
Step 1: Check command usage context
A common error is misspelling the collection name, causing 'ns not found' error since the collection doesn't exist.
Step 2: Identify error cause
db.collection.stats() requires an existing collection; misspelling prevents access.
Final Answer:
You misspelled the collection name -> Option B
Quick Check:
stats() works on existing collections only [OK]
Hint: Verify collection name spelling before running stats() [OK]
Common Mistakes:
Misspelling the collection name
Forgetting to connect to MongoDB
Confusing find() with stats()
5. You have a collection where documents grow unpredictably. What is a good strategy to manage document size and growth?
hard
A. Ignore document size and rely on hardware upgrades
B. Keep all data in one large document to avoid joins
C. Split large documents into smaller related documents using references
D. Delete old documents frequently to reduce size
Solution
Step 1: Understand document growth challenges
Unpredictable growth can cause documents to become too large and slow.
Step 2: Apply best practice for size management
Splitting large documents into smaller ones with references keeps sizes manageable and improves performance.
Final Answer:
Split large documents into smaller related documents using references -> Option C
Quick Check:
Split documents to manage size and growth [OK]
Hint: Use references to split big documents for better growth control [OK]
Common Mistakes:
Keeping all data in one big document
Ignoring size issues hoping hardware helps
Deleting data instead of managing structure
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.