Presented by Tom Schreiber, Senior Consulting Engineer, MongoDB
Experience level: Beginner
MongoDB supports a wide range of indexing options to enable fast querying of your data, but what are the right strategies for your application? In this talk we’ll cover how indexing works, the various indexing options, and cover use cases where each might be useful. We'll dive into common pitfalls using real-world examples to ensure that you're ready for scale. We'll show you the tools and techniques for diagnosing and tuning the performance of your MongoDB deployment. Whether you're running into problems or just want to optimize your performance, these skills will be useful.
38. {...} {...} {...} {...}{...} {...} {...}{...}
MMAPv1
Flat Files for Collections
{...} {...}{...} {...}{...} {...}{...}
B-Trees for Indexes
B-Trees for Collections
WiredTiger
Index (and Collection-) Data Structures
are Storage Engine specific
B-Tree Indexes
LSM-Tree Indexes
https://github.com/mongodb/mongo/tree/
v3.0/src/mongo/db/storage/mmap_v1
https://github.com/mongodb/mongo/tree/
v3.0/src/third_party/wiredtiger
Pluggable Storage Engine API
MongoDB Database Engine
39. {...} {...} {...} {...}{...} {...} {...} {...}
MMAPv1
Flat Files for Collections
{...} {...} {...} {...}{...} {...} {...}
B-Trees for Indexes
B-Trees for Collections
WiredTiger
. . .
Index (and Collection-) Data Structures
are Storage Engine specific
B-Tree Indexes
LSM-Tree Indexes
https://github.com/mongodb/mongo/tree/
v3.0/src/mongo/db/storage/mmap_v1
https://github.com/mongodb/mongo/tree/
v3.0/src/third_party/wiredtiger
Fractal-Tree
Indexes
TokuMXse
LSM-Tree
Indexes
RocksDB
Pluggable Storage Engine API
MongoDB Database Engine
40. Balancing Speed of Reads and WritesPerformance
Fast reads Fast writesBoth
Easy:
• Add indexes
Easy:
• No indexes
Hard:
• Smart schema design
(hire a consultant)
• LSM index structures
B-Tree Indexes LSM-Tree Indexes
44. tresult
The Query Optimizer
Chooses the most efficient query plan.
Information on query plans
and their execution statistics:
db.col.query.explain()
full collection scan
index on x
index on y
t0
Choose and Remenber
Terminate
db.col.query(...)
49. Explain Levels
queryPlanner
"Which plan will MongoDB choose to run my query?"
executionStats
"How is my query performing?"
allPlansExecution
"I want as much information as possible to diagnose a slow query."