Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Practical Tips from 2 Years of Growing on MongoDB
Search
Juan Patten
January 24, 2013
Programming
380
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Practical Tips from 2 Years of Growing on MongoDB
The talk I gave at Mongo Boulder 2013
Juan Patten
January 24, 2013
Other Decks in Programming
See All in Programming
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
390
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
410
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
1
2k
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
550
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
730
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
180
Go 1.27 における memory allocation の高速化
andpad
0
340
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
150
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
230
初めての模倣学習とVLA
natsutan
0
290
VibeCodingからAgenticWorkflowへ
starfish719
0
910
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
5
1.8k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Scaling GitHub
holman
464
140k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
260
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Thoughts on Productivity
jonyablonski
76
5.3k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
480
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
500
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
180
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Transcript
Practical Tips from 2 Years of Growing on MongoDB Juan
Patten – Rafflecopter
I’m J.R. www.Rafflecopter.com @rafflecopter @runningskull
❤
What We Talkin’ Bout? • Practical lessons learned from 3
iterations of schema design • A few clever(?) tricks • Our approach to no-downtime schema migration
Mongo Is... “Web-scale for dummies!” “Schema-free, man. w00t!”
Mongo Is... “Web-scale for dummies!” “Schema-free, man. w00t!” structured data
== schema! You still have to think!
Users Raffles Entries Entrants Rafflecopter
Users Raffles Entries Entrants Rafflecopter
Schema #1 Raffle = { _id: <string> [ ... ]
entries: [ {...}, {...}, ... ] } • Tough to access • Padding Factor • Max Document Size LESSONS
Schema #2 • “Denormalize!” • Each entry in own document
• _id is UUID() • Indexes for each access pattern • Documents (almost) never grow • Cache results of expensive queries
Schema #2 – Lessons • Complex queries for simple things
• Indexes gigantic - killed performance • Old data “lingered” • _id unused
Schema #3 – Goals • Minimal indexes • One document
per entrant per raffle • _id derivable from known data • Old data should “expire” naturally
ObjectID’s – A (not so) Secret Weapon 24-byte string →
12-byte binary value new ObjectId() new ObjectId("47cc67093475061e3d95369d") or
B-TREES ObjectID’s – A (not so) Secret Weapon
_id = UUID() RAM ObjectID’s – A (not so) Secret
Weapon
_id = new ObjectId() RAM ObjectID’s – A (not so)
Secret Weapon
_id = new ObjectId() timestamp (seconds since epoch) “misc” ID
info (machine_id | pid | incr) not derivable later! ObjectID’s – A (not so) Secret Weapon
timestamp (raffle_date_created) “misc” ID info md5(entrant_id | raffle_id | salt)
_id = new ObjectId(X) X = “1234567890abcdefabcdef” ObjectID’s – A (not so) Secret Weapon
Schema #3 – Results ✓Minimal indexes (5 large → 2
small) ✓One document per entrant per raffle ✓_id derivable from known data ✓Old data should “expire” naturally • write lock % cut by 9x • page faults cut by 10x • open cursor size cut by 5x
Schema Takeaways • access patterns == indexes. design the schema
around them • save queries and index space by deriving ID’s from known data • denormalize in moderation
Painless Schema Migration { [ ... ] _legacy: [ ‘flag_a’,
‘flag_b’, ‘flag_c’ ] }
Thanks! @runningskull JuanPatten.com Need cheap, effective marketing? Try giveaways! www.Rafflecopter.com