Pages in Mongodb

Mongodb Tutorial 6 - Application Engineering


Durability of Writes Write Concern How to make sure the writes persistent? Assume application talking to a database server in the scheme below. The settings of two parameters affect the write concern: w(wait for acknowledgement) j(journal) effect comment 1 false fast, small window of vulnerability default setting 1 true slow, no vulnerability can be done inside driver at collection, database, or client level 0 - unacknowledged write do not recommend 2 - wait for 2 nodes in replica set to acknowledge write w can be 0-3 for a set with 3 nodes majority - wait for majority to acknowledge, avoid rollback on failover - tag values - set tags on nodes - If the journal has been written to disk and the server crashes, on recovery the server can look in the journal and recreate all the writes that were not yet persisted to the pages.

Mongodb Tutorial 1 - Introduction


To run mongo commands from the source of a JavaScript file, cat source.js | mongo # or mongo < source.js # or just mongo source.js To import/export data, $ mongoimport -d <database> -c <collection> -f <file> $ mongoimport -d <dababase> -c <collection> < file.json $ mongoexport -d <dababase> -c <collection> –out file.json $ mongorestore -d <database> -c <collection> file.bson # by default writes BSON file to dump/ in current directory $ mongodump -d <database> -c <collection [–out <path>] What is MongoDB?

MongoDB Tutorial 5 - Aggregation Framework


The aggregation framework has its roots in SQL’s world of groupby clause. Introduction Example used: imagine a SQL table of products. name category manufacture price ipad tablet Apple 499 nexus s cellphone Samsung 350 To get number of products from each manufacture with SQL, select manufacture, count(*) from products group by manufacture; with mongodb, > use agg > db.

MongoDB Tutorial 4 - Performance


Storage engine Storage engine sits between mongodb server and the file storage. Use db.serverStatus().storageEngine; to check. WiredTiger for many applications, this is faster - document level concurrency, lock free implementation. optimistic concurrency model which assumes two writes not gonna be on same document. if on same, one write unwound and try again. - compression of data and indexes. WiredTiger manages memory. - append only, no in place updates MMAP V1 Uses mmap system call undercovers.