SlideShare a Scribd company logo
What’s new in 2.6
DriverTeam Lead,Node.js driver,MongoDB INC
Christian Kvalheim
#mongodb
Me
• Driver Team Lead
• Node.js driver developer
• @christkv
• http://www.christiankvalheim.com
Agenda
• Aggregation Cursors
• maxTimeMS
• New or Enhanced update operations
• New Security Model
• Ordered/Unordered Bulk Operations
• Background index building on secondaries
• parallelCollectionScan command
Aggregation Cursors
Aggregation Cursors
• Aggregation framework can now return a cursor
var test = db.getSisterDB('test');!
test.t.drop();!
!
for(var i = 0; i < 100; i++) {!
db.t.insert({a:i});!
}!
!
var c = test.t.aggregate([{$match: {}}], {cursor: { batchSize:1 }});!
!
while(c.hasNext()) {!
print(c.next().a);!
}!
Aggregation Cursors
• You can control the behavior of the aggregation cursor
passing in the cursor option with the batchSize
> db.runCommand({aggregate: "t", pipeline: [], cursor: {batchSize: 1}!
! , allowDiskUse: true})!
{!
! "cursor" : {!
! ! "id" : NumberLong("39465949628"),!
! ! "ns" : "test.t",!
! ! "firstBatch" : [!
! ! ! {!
! ! ! ! "_id" : ObjectId("532808ea4be168cc8e9dd7dd"),!
! ! ! ! "a" : 0!
! ! ! }!
! ! ]!
! },!
! "ok" : 1!
}!
Aggregation Cursors
• Cursor id is just a normal MongoDB cursor meaning it
works like other cursors using the wire protocol call
getMore.
maxTimeMS
maxTimeMS
• Ever wanted to set a specific query or command
timeout ?
• maxTimeMS is what you’ve been looking for.
> db.t.find({"$where": "sleep(1000)"}).maxTimeMS(50)!
New or Enhanced update
operations
New or Enhanced update operations
• $mul
• $bit
• $min/$max
• $currentDate
• $push enhancements
$mul
var test = db.getSisterDB('test');!
test.t.drop();!
!
db.t.insert({ _id: 1, item: "ABC", price: 10.99 });!
!
db.t.update({ _id: 1 },!
{ $mul: { price: 1.25 } });!
!
print(db.t.findOne({_id:1}).price);!
$bit
• supports and/or/xor (xor is new)
var test = db.getSisterDB('test');!
test.t.drop();!
!
db.t.insert({ _id: 1, expdata: NumberLong(1) });!
!
db.t.update({ _id: 1 },!
{ $bit: { expdata: { xor:
NumberInt(5) } } })!
!
print(db.t.findOne({_id:1}).expdata);!
$min/$max
var test = db.getSisterDB('test');!
test.t.drop();!
!
db.t.insert({ _id: 1, desc: "crafts", !
dateEntered: ISODate("2013-10-01T05:00:00Z"),!
dateExpired: ISODate("2013-10-01T16:38:16Z")!
});!
!
db.t.update({ _id: 1 }, {!
$min: { dateEntered: new Date("2013-09-25") }!
})!
!
print(db.t.findOne({_id:1}).dateEntered);!
$currentDate
var test = db.getSisterDB('test');!
test.t.drop();!
!
db.t.insert({ _id: 1, !
! status: "a", !
! lastModified: ISODate("2013-10-02T01:11:18.965Z") });!
!
db.t.update({ _id: 1 }, {!
! $currentDate: {!
! ! lastModified: true,!
! ! lastModifiedTS: { $type: "timestamp" }},!
! $set: { status: "D" }!
});!
!
printjson(db.t.findOne({_id:1}));!
$push enhancements
var test = db.getSisterDB('test');!
test.t.drop();!
!
db.t.insert({ "_id" : 1, "scores" : [50,60,70,100 ]});!
!
db.t.update({ _id: 1 }, !
! { $push: { scores: {!
! ! ! $each: [ 20, 30 ],!
! ! ! $position: 2!
! ! }!
! }!
});!
!
printjson(db.t.findOne({_id:1}));!
New Security Model
New Security Model
• Now with
• Roles
• Rights
• You can customize the roles and rights to your liking.
• Subscription Edition also includes
• LDAP
• X509 authentication
New Security Model - Create Role Ex
var admin = db.getSisterDB('admin');!
admin.createRole({!
role: "myClusterwideAdmin",!
privileges:!
[!
{ resource: { cluster: true }, !
! actions: [ "addShard" ] },!
{ resource: { db: "config", collection: "" }, !
! actions: [ "find", "update", "insert" ] },!
{ resource: { db: "users", collection: "usersCollection" }, !
! actions: [ "update" ] },!
{ resource: { db: "", collection: "" }, !
! actions: [ "find" ] }!
],!
roles:!
[!
{ role: "read", db: "admin" }!
],!
writeConcern: { w: "majority" , wtimeout: 5000 }!
})!
Ordered/Unordered Bulk
Operations
Ordered/Unordered Bulk Operations
var test = db.getSisterDB('test');!
test.t.drop();!
!
var bulk = db.t.initializeOrderedBulkOp();!
bulk.insert({a:1});!
bulk.find({a:1}).update({$set: {b:1}});!
bulk.find({a:2}).upsert().update({$set: {b:1}});!
bulk.find({a:1}).remove();!
var result = bulk.execute({w:1});!
printjson(result);!
Ordered/Unordered Bulk Operations
• New BulkAPI shared across drivers and shell
• Uses new write Commands underneath the covers
• Splits up documents into batches
• Write Commands is the future of writing for MongoDB
• w:0 semantics is no result details when using write
commands
Ordered/Unordered Bulk Operations
• Ordered
• Execute all operations in the order they where
entered and fail on first write error
• Guarantees order of execution
• Unordered
• Executes all operations out of order and potentially
in parallel.Does not stop on error.
• Does not Guarantee order of execution
Background index building on
secondaries
Background index building on secondaries
• Previously only available on primary
• Could cause secondaries to hang
• Was not practical in many situations
• Secondaries can now build indexes in background
• Can also restart partially build indexes on instance
termination and restart
parallelCollectionScan command
parallelCollectionScan command
• Split collection into multiple cursors
• Read in parallel from the collection
• No matching semantics (it’s for pure dumping
purposes only)
parallelCollectionScan command
var test = db.getSisterDB('test');!
test.t.drop();!
!
var bulk = db.t.initializeOrderedBulkOp();!
for(var i = 0; i < 100000; i++) {!
! bulk.insert({a:i});!
};!
!
var result = bulk.execute({w:1});!
result = test.runCommand({!
! ! parallelCollectionScan: 't'!
! ,! numCursors: 4!
});!
!
printjson(result);!
ThankYou
DriverTeam Lead,Node.js driver,MongoDB INC
Christian Kvalheim
#mongodb

More Related Content

PDF
NoSQL Injections in Node.js - The case of MongoDB
PPTX
Config BuildConfig
PDF
Security Challenges in Node.js
PDF
CommonJS: JavaScript Everywhere
PPT
SharePoint Administration with PowerShell
PPTX
Azure sql insert perf
PDF
OneRing @ OSCamp 2010
PDF
Tools for Solving Performance Issues
NoSQL Injections in Node.js - The case of MongoDB
Config BuildConfig
Security Challenges in Node.js
CommonJS: JavaScript Everywhere
SharePoint Administration with PowerShell
Azure sql insert perf
OneRing @ OSCamp 2010
Tools for Solving Performance Issues

What's hot (19)

PDF
TDC2016POA | Trilha Java - Introdução ao Byteman
PDF
Talk KVO with rac by Philippe Converset
PDF
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
PDF
Fun Teaching MongoDB New Tricks
PPTX
Power shell
PDF
Google App Engine Developer - Day3
PPTX
Unit testing pig
PDF
The Ring programming language version 1.5.3 book - Part 40 of 184
PDF
お題でGroovyプログラミング: Part A
PDF
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
PDF
Writing native bindings to node.js in C++
PDF
"Metrics: Where and How", Vsevolod Polyakov
KEY
Apache mod authまわりとか
PDF
Node.js testing
PDF
React for Beginners
PPTX
PDF
PyCon KR 2019 sprint - RustPython by example
PDF
Javascript call ObjC
KEY
New Design of OneRing
TDC2016POA | Trilha Java - Introdução ao Byteman
Talk KVO with rac by Philippe Converset
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Fun Teaching MongoDB New Tricks
Power shell
Google App Engine Developer - Day3
Unit testing pig
The Ring programming language version 1.5.3 book - Part 40 of 184
お題でGroovyプログラミング: Part A
Non-Relational Postgres / Bruce Momjian (EnterpriseDB)
Writing native bindings to node.js in C++
"Metrics: Where and How", Vsevolod Polyakov
Apache mod authまわりとか
Node.js testing
React for Beginners
PyCon KR 2019 sprint - RustPython by example
Javascript call ObjC
New Design of OneRing
Ad

Viewers also liked (17)

PDF
Node.js and ruby
PPTX
Slash n: Tech Talk Track 1 – Experimentation Platform - Ashok Banerjee
PDF
Slash n: Technical Session 2 - Messaging as a Platform - Shashwat Agarwal, V...
PDF
Slash n: Technical Session 6 - Keeping a commercial site secure – A case stud...
PPTX
Group #5 - Flipkart_final submission
PPT
Slash n: Tech Talk Track 1 – Art and Science of Cataloguing - Utkarsh
PPTX
Fungus on White Bread
PDF
Driving User Growth Through Online Marketing
PDF
Slash n: Technical Session 8 - Making Time - minute by minute - Janmejay Singh
KEY
Mongodb intro
PPTX
Slash n: Tech Talk Track 2 – Website Architecture-Mistakes & Learnings - Sidd...
PPT
Slash n: Technical Session 7 - Fraudsters are smart, Frank is smarter - Vivek...
PDF
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
KEY
Mongo db ecommerce
PPTX
Building Your First App with MongoDB
KEY
How Flipkart scales PHP
PPTX
Seminario Web MongoDB-Paradigma: Cree aplicaciones más escalables utilizando ...
Node.js and ruby
Slash n: Tech Talk Track 1 – Experimentation Platform - Ashok Banerjee
Slash n: Technical Session 2 - Messaging as a Platform - Shashwat Agarwal, V...
Slash n: Technical Session 6 - Keeping a commercial site secure – A case stud...
Group #5 - Flipkart_final submission
Slash n: Tech Talk Track 1 – Art and Science of Cataloguing - Utkarsh
Fungus on White Bread
Driving User Growth Through Online Marketing
Slash n: Technical Session 8 - Making Time - minute by minute - Janmejay Singh
Mongodb intro
Slash n: Tech Talk Track 2 – Website Architecture-Mistakes & Learnings - Sidd...
Slash n: Technical Session 7 - Fraudsters are smart, Frank is smarter - Vivek...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Mongo db ecommerce
Building Your First App with MongoDB
How Flipkart scales PHP
Seminario Web MongoDB-Paradigma: Cree aplicaciones más escalables utilizando ...
Ad

Similar to New in MongoDB 2.6 (20)

PDF
Whats new in mongoDB 2.4 at Copenhagen user group 2013-06-19
PPTX
Whats new in MongoDB 24
PDF
Quick overview on mongo db
PDF
full stack modul 5, mongodb,webpack,front-end,back-end
PPTX
How to leverage what's new in MongoDB 3.6
PPTX
MongoDB_ppt.pptx
PPTX
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
PPTX
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
PDF
MongoDB.pdf54teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeer
PDF
2016 feb-23 pyugre-py_mongo
PDF
Using MongoDB and Python
PDF
Latinoware
PPTX
MongoDB - An Introduction
PDF
Webinar: Was ist neu in MongoDB 2.4
PDF
Mongo db basics
PPTX
No SQL DB lecture showing structure and syntax
PPTX
MongoDB is a document database. It stores data in a type of JSON format calle...
PPT
Mongo db basics
PPTX
Introduction to MongoDB
KEY
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
Whats new in mongoDB 2.4 at Copenhagen user group 2013-06-19
Whats new in MongoDB 24
Quick overview on mongo db
full stack modul 5, mongodb,webpack,front-end,back-end
How to leverage what's new in MongoDB 3.6
MongoDB_ppt.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
MongoDB.pdf54teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeer
2016 feb-23 pyugre-py_mongo
Using MongoDB and Python
Latinoware
MongoDB - An Introduction
Webinar: Was ist neu in MongoDB 2.4
Mongo db basics
No SQL DB lecture showing structure and syntax
MongoDB is a document database. It stores data in a type of JSON format calle...
Mongo db basics
Introduction to MongoDB
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!

More from christkv (6)

PDF
From SQL to MongoDB
PDF
Lessons from 4 years of driver develoment
PPTX
Storage talk
PDF
Cdr stats-vo ip-analytics_solution_mongodb_meetup
KEY
Schema design
KEY
Node js mongodriver
From SQL to MongoDB
Lessons from 4 years of driver develoment
Storage talk
Cdr stats-vo ip-analytics_solution_mongodb_meetup
Schema design
Node js mongodriver

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Cloud computing and distributed systems.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
A Presentation on Artificial Intelligence
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Cloud computing and distributed systems.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
A Presentation on Artificial Intelligence
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding

New in MongoDB 2.6

  • 1. What’s new in 2.6 DriverTeam Lead,Node.js driver,MongoDB INC Christian Kvalheim #mongodb
  • 2. Me • Driver Team Lead • Node.js driver developer • @christkv • http://www.christiankvalheim.com
  • 3. Agenda • Aggregation Cursors • maxTimeMS • New or Enhanced update operations • New Security Model • Ordered/Unordered Bulk Operations • Background index building on secondaries • parallelCollectionScan command
  • 5. Aggregation Cursors • Aggregation framework can now return a cursor var test = db.getSisterDB('test');! test.t.drop();! ! for(var i = 0; i < 100; i++) {! db.t.insert({a:i});! }! ! var c = test.t.aggregate([{$match: {}}], {cursor: { batchSize:1 }});! ! while(c.hasNext()) {! print(c.next().a);! }!
  • 6. Aggregation Cursors • You can control the behavior of the aggregation cursor passing in the cursor option with the batchSize > db.runCommand({aggregate: "t", pipeline: [], cursor: {batchSize: 1}! ! , allowDiskUse: true})! {! ! "cursor" : {! ! ! "id" : NumberLong("39465949628"),! ! ! "ns" : "test.t",! ! ! "firstBatch" : [! ! ! ! {! ! ! ! ! "_id" : ObjectId("532808ea4be168cc8e9dd7dd"),! ! ! ! ! "a" : 0! ! ! ! }! ! ! ]! ! },! ! "ok" : 1! }!
  • 7. Aggregation Cursors • Cursor id is just a normal MongoDB cursor meaning it works like other cursors using the wire protocol call getMore.
  • 9. maxTimeMS • Ever wanted to set a specific query or command timeout ? • maxTimeMS is what you’ve been looking for. > db.t.find({"$where": "sleep(1000)"}).maxTimeMS(50)!
  • 10. New or Enhanced update operations
  • 11. New or Enhanced update operations • $mul • $bit • $min/$max • $currentDate • $push enhancements
  • 12. $mul var test = db.getSisterDB('test');! test.t.drop();! ! db.t.insert({ _id: 1, item: "ABC", price: 10.99 });! ! db.t.update({ _id: 1 },! { $mul: { price: 1.25 } });! ! print(db.t.findOne({_id:1}).price);!
  • 13. $bit • supports and/or/xor (xor is new) var test = db.getSisterDB('test');! test.t.drop();! ! db.t.insert({ _id: 1, expdata: NumberLong(1) });! ! db.t.update({ _id: 1 },! { $bit: { expdata: { xor: NumberInt(5) } } })! ! print(db.t.findOne({_id:1}).expdata);!
  • 14. $min/$max var test = db.getSisterDB('test');! test.t.drop();! ! db.t.insert({ _id: 1, desc: "crafts", ! dateEntered: ISODate("2013-10-01T05:00:00Z"),! dateExpired: ISODate("2013-10-01T16:38:16Z")! });! ! db.t.update({ _id: 1 }, {! $min: { dateEntered: new Date("2013-09-25") }! })! ! print(db.t.findOne({_id:1}).dateEntered);!
  • 15. $currentDate var test = db.getSisterDB('test');! test.t.drop();! ! db.t.insert({ _id: 1, ! ! status: "a", ! ! lastModified: ISODate("2013-10-02T01:11:18.965Z") });! ! db.t.update({ _id: 1 }, {! ! $currentDate: {! ! ! lastModified: true,! ! ! lastModifiedTS: { $type: "timestamp" }},! ! $set: { status: "D" }! });! ! printjson(db.t.findOne({_id:1}));!
  • 16. $push enhancements var test = db.getSisterDB('test');! test.t.drop();! ! db.t.insert({ "_id" : 1, "scores" : [50,60,70,100 ]});! ! db.t.update({ _id: 1 }, ! ! { $push: { scores: {! ! ! ! $each: [ 20, 30 ],! ! ! ! $position: 2! ! ! }! ! }! });! ! printjson(db.t.findOne({_id:1}));!
  • 18. New Security Model • Now with • Roles • Rights • You can customize the roles and rights to your liking. • Subscription Edition also includes • LDAP • X509 authentication
  • 19. New Security Model - Create Role Ex var admin = db.getSisterDB('admin');! admin.createRole({! role: "myClusterwideAdmin",! privileges:! [! { resource: { cluster: true }, ! ! actions: [ "addShard" ] },! { resource: { db: "config", collection: "" }, ! ! actions: [ "find", "update", "insert" ] },! { resource: { db: "users", collection: "usersCollection" }, ! ! actions: [ "update" ] },! { resource: { db: "", collection: "" }, ! ! actions: [ "find" ] }! ],! roles:! [! { role: "read", db: "admin" }! ],! writeConcern: { w: "majority" , wtimeout: 5000 }! })!
  • 21. Ordered/Unordered Bulk Operations var test = db.getSisterDB('test');! test.t.drop();! ! var bulk = db.t.initializeOrderedBulkOp();! bulk.insert({a:1});! bulk.find({a:1}).update({$set: {b:1}});! bulk.find({a:2}).upsert().update({$set: {b:1}});! bulk.find({a:1}).remove();! var result = bulk.execute({w:1});! printjson(result);!
  • 22. Ordered/Unordered Bulk Operations • New BulkAPI shared across drivers and shell • Uses new write Commands underneath the covers • Splits up documents into batches • Write Commands is the future of writing for MongoDB • w:0 semantics is no result details when using write commands
  • 23. Ordered/Unordered Bulk Operations • Ordered • Execute all operations in the order they where entered and fail on first write error • Guarantees order of execution • Unordered • Executes all operations out of order and potentially in parallel.Does not stop on error. • Does not Guarantee order of execution
  • 24. Background index building on secondaries
  • 25. Background index building on secondaries • Previously only available on primary • Could cause secondaries to hang • Was not practical in many situations • Secondaries can now build indexes in background • Can also restart partially build indexes on instance termination and restart
  • 27. parallelCollectionScan command • Split collection into multiple cursors • Read in parallel from the collection • No matching semantics (it’s for pure dumping purposes only)
  • 28. parallelCollectionScan command var test = db.getSisterDB('test');! test.t.drop();! ! var bulk = db.t.initializeOrderedBulkOp();! for(var i = 0; i < 100000; i++) {! ! bulk.insert({a:i});! };! ! var result = bulk.execute({w:1});! result = test.runCommand({! ! ! parallelCollectionScan: 't'! ! ,! numCursors: 4! });! ! printjson(result);!
  • 29. ThankYou DriverTeam Lead,Node.js driver,MongoDB INC Christian Kvalheim #mongodb