MongoDB Flashcards
Atomicity _________ isolation durability
Consistency
Atomicity consistency ___________ durability
Isolation
____________ consistency isolation durability
Atomicity
Atomicity consistency isolation ____________
Durability
ACID
Atomicity consistency isolation durability
.explain() Verbosity levels
queryPlanner
executionStats
allPlansExecution
____________
executionStats
allPlansExecution
queryPlanner
queryPlanner
_______________
allPlansExecution
executionStats
queryPlanner
executionStats
________________
allPlansExecution
Create index in background
{background:true}
Create text index
{field:”text”}
Default write concern
w:1
Enable sharding
sh.enableSharding(‘collection’)
Shard collection
sh.shardCollection(‘collection’, {shard:key});
Get shard status
sh.status();
Add shard to cluster
sh.addShard(‘rs/server:port’);
Create time to live TTL index
{expireAfterSeconds:360}
List indexes
db.collection.getIndexes();
Remove index
db.collection.dropIndex({index:signature});
Add to replica set
rs.add(“hostname:port”);
Shard query that hits a single shard
Targeted query
Shard query that hits all nodes
Scatter gather or broadcast query
Default chunk size
64mb
Create hashed index
db.col.createIndex( { col: “hashed”});
Components of ObjectId
Date
Machine identifier
Process ID
Counter
Aggregation pipeline stage memory limit
100MB
Allow aggregation pipeline to use more than 100MB
{allowDiskUse:true}
MMAPv1 concurrency level
Collection level locking
WiredTiger concurrency level
Document level concurrency
WiredTiger compression levels
Snappy and zlib
What causes MMAPv1 document movement?
Document outgrows it’s allocated space
MMAPv1 document movement causes?
Indexes that point to file location to be updated
Disable power of two allocation
Db.runCommand( { “collMod” : , “noPadding”: true } ):
MMAPv1 max file size
2047MB
Manually split db.test chunk with number 3 into equal sized chunks
sh.splitFind(“db.test”, { “number”: 3}):
Split db.test AT number 3
sh.splitAt( “db.test”, { “number”: 3 });
What causes an election
Initiating replica set, and primary becoming unavailable
Rolled back data goes where?
Rollback/ folder in data path
What causes rollback?
Data written to primary but not a secondary after primary failure
Ensure data is written to most nodes
{w: “majority”}
Ensure data is written to the journal
{j: true}
What causes an election
Initiating replica set, and primary becoming unavailable
Rolled back data goes where?
Rollback/ folder in data path
Will update update a field to the same value?
No, it will skip it
Can you update the _id field?
No, it is immutable
By default, update will update how many documents?
1
By default, remove will remove how many documents?
All of them.
Remove just one document
Db.collection.remove({},{justOne:true);
Update more than one document
db.collection.update({col:”cond”},{multi: true});
Read preference choices
Primary primaryPreferred secondary secondaryPreferred nearest
Find all from testData collection with nearest read preference
db.testData.find().readPref(“nearest”);