SlideShare ist ein Scribd-Unternehmen logo
1 von 113
Avoiding Query
Pitfalls
@nleite
2
Agenda Common Query
Pitfalls
How to think
about and how to
solve them
Tips and Tricks
for Query
Optimization
3
Howdy!
Disclaimer
Who's this guy?
Norberto Leite
Lead Engineer
@nleite
MongoDB
https://university.mongodb.com/
M201: MongoDB
Performance
6
https://usatthebiglead.files.wordpress.com/2012/10/dez-drop-10-1-12.gif?w=1000
What's the
story about
query
pitfalls?
7
The Power of Query Optimization
Query tuning results in:
● Improved performance
● Reduced resource utilization
This may lead to:
● Improved stability and predictability
● Smaller hardware footprint
Not uncommon to observe efficiency improvements $gte 99%
Acme Games Introduces:
ShortFite
Tales of a release pre-launch testing
Getting
Ready for
Launch!
MongoDB Certified
Developers and DBA Stakeholders
Become a MongoDB
Certified Developer /
DBA
11
Stakeholder
Concerns
● Game nearly
complete
● Team starts to do
capacity testing
12
Stakeholder
Concerns
● Game nearly
complete
● Team starts to do
capacity testing
Indexes support the efficient
execution of queries in MongoDB
13
Stakeholder
Concerns
● Game nearly
complete
● Team starts to do
capacity testing
Ace Sue
… …
Bob
Indexes support the efficient
execution of queries in MongoDB
Stakeholder #1 Concern
App being stress tested
Concerns over current performance
Stakeholder #1 Concern
Developers created index
db.games.createIndex({ gamerTag: 1 })
This query takes several seconds to execute:
db.games.find( { gamerTag: "Ace" } ).sort({score:-1})
Adding the index on score does not help!
db.games.createIndex({ score: -1 })
Stakeholder #1 Concern
Developers created index
db.games.createIndex({ gamerTag: 1 })
This query takes several seconds to execute:
db.games.find( { gamerTag: "Ace" } ).sort({score:-1})
Adding the index on score does not help!
db.games.createIndex({ score: -1 })
“Clearly MongoDB
is not webscale!”
Blocking Operations
18
Blocking Operation
Formally:
“An operation which must process all input before it can begin to produce any output.”
Opposite of the often desirable “fully pipelined” plan which can stream results back as soon as they
are found.
Commonly observed when a sort is added to a query
Sorting with blocking
Sorting with blocking
Sorting with blocking
Sorting with blocking
Sorting with blocking
Sorting with blocking
Sorting with blocking
Sorting with blocking
Indexes that support sorting
db.games.createIndex({ gamerTag: 1, score:-1})
Sorting without blocking
Sorting without blocking
Sorting without blocking
Sorting without blocking
32
Blocking
Stages
$sort
In aggregation and find
$group
$bucket
$count
$facet
Are there any other blocking
operations?
Aggregation Pipeline Stages?
34
Working with blocking stages
For sorting:
Add a supporting index
Worth the overhead in almost all circumstances
For other stages:
Do you need the blocking stage?
Offload to secondary member
Stakeholder #1 Concern
Performance of
db.games.find( { gamerTag: "Ace" } ).sort({score:-1})
“Clearly MongoDB is not webscale!”
Stakeholder #1 Concern
Performance of
db.games.find( { gamerTag: "Ace" } ).sort({score:-1})
db.games.createIndex({ gamerTag: 1, score:-1 })
Stakeholder #1 Concern
Performance of
db.games.find( { gamerTag: "Ace" } ).sort({score:-1})
db.games.createIndex({ gamerTag: 1, score:-1 })
"That’ll work great!”
Stakeholder #2 Concern
The $and version of a query
returns quickly:
db.games.find({
$and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
But the $or version is slow:
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Concern #2: Multiple queries same index
The $and version of a query
returns quickly:
db.games.find({
$and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
But the $or version is slow:
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
We just created an index with both
those fields… Can it be used?
$or
$and example
Query on games:
db.games.find({
$and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Matching games:
{ gamerTag: "Ace", score: 9500 }
Non-matching games:
{ gamerTag: "Ace", score: 500 },
{ gamerTag: "Bob", score: 9500 },
{ gamerTag: "Bob", score: 500 }
Groups of documents
score: {$gt: 9000}gamerTag: "Ace"
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Ace",
score: 500 }
{ gamerTag: "Bob",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
gamerTag: "Ace"
$and Venn Diagram (logical)
score: {$gt: 9000}
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Ace",
score: 500 }
{ gamerTag: "Bob",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
$and Venn Diagram (logical)
{ gamerTag: "Bob",
score: 500 }
gamerTag: "Ace"
{ gamerTag: "Ace",
score: 500 }
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
gamerTag: "Ace"
$and Venn Diagram (logical)
score: {$gt: 9000}
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
gamerTag: "Ace"
$and Venn Diagram (logical)
score: {$gt: 9000}
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
$and Venn Diagram (logical)
score: {$gt: 9000}gamerTag: "Ace"
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
$and Venn Diagram (logical)
score: {$gt: 9000}gamerTag: "Ace"
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
$and Venn Diagram (logical)
score: {$gt: 9000}gamerTag: "Ace"
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
Ace Bob
{gamerTag:1
, score:-1}
500 9500
500 9500
$and Index Visualization
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
Ace Bob
{gamerTag:1
, score:-1}
500 9500
500 9500
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000.0)"
]
}
$and Index Visualization
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
Ace Bob
500 9500
500 9500
{gamerTag:1
, score:-1}
$and Index Visualization
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000.0)"
]
}
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
Bob
500 9500
500 9500
Ace
{gamerTag:1
, score:-1}
$and Index Visualization
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000.0)"
]
}
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
$and Index Visualization
Bob
500
500 9500
Ace
9500
{gamerTag:1
, score:-1}
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000.0)"
]
}
db.games.find(
{ $and : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]})
$or example
Query on games:
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Matching games:
{ gamerTag: "Ace", score: 9500 },
{ gamerTag: "Ace", score: 500 },
{ gamerTag: "Bob", score: 9500 }
Non-matching games:
{ gamerTag: "Bob", score: 500 }
gamerTag: "Ace"
$or Venn Diagram (logical)
score: {$gt: 9000}
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Ace",
score: 500 }
{ gamerTag: "Bob",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or Venn Diagram (logical)
score: {$gt: 9000}
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Ace",
score: 500 }
{ gamerTag: "Bob",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
gamerTag: "Ace"
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or Venn Diagram (logical)
score: {$gt: 9000}
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Ace",
score: 500 }
{ gamerTag: "Bob",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
gamerTag: "Ace"
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}
$or Venn Diagram (logical)
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
{ gamerTag: "Ace",
score: 500 }
gamerTag: "Ace"
{ gamerTag: "Bob",
score: 9500 }
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}gamerTag: "Ace"
$or Venn Diagram (logical)
{ gamerTag: "Ace",
score: 9500 }
{ gamerTag: "Ace",
score: 500 }
{ gamerTag: "Bob",
score: 9500 }
{ gamerTag: "Bob",
score: 500 }
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}gamerTag: "Ace"
$or Venn Diagram (logical)
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}gamerTag: "Ace"
$or Venn Diagram (logical)
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}gamerTag: "Ace"
$or Venn Diagram (logical)
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}
$or Venn Diagram (logical)
gamerTag: "Ace"
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
score: {$gt: 9000}
$or Venn Diagram (logical)
gamerTag: "Ace"
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (single) Index visualization
Ace Bob
{gamerTag:1
, score:-1}
500 9500
500 9500
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Ace Bob
{gamerTag:1
, score:-1}
500 9500
500 9500
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
$or (single) Index visualization
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Ace Bob
500 9500
500 9500
{gamerTag:1
, score:-1}
$or (single) Index visualization
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Bob
500 9500
500 9500
{gamerTag:1
, score:-1}
Ace
$or (single) Index visualization
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Bob
500 9500
{gamerTag:1
, score:-1}
Ace
500 9500
$or (single) Index visualization
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
500
Bob
9500
$or (single) Index visualization
{gamerTag:1
, score:-1}
Ace
500 9500
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
500
Bob
9500
Actual (Hinted) Index Bounds:
"indexBounds" : {
"gamerTag" : [
"[MinKey, MaxKey]"
],
"score" : [
"[MaxKey, MinKey]"
]}
$or (single) Index visualization
{gamerTag:1
, score:-1}
Ace
500 9500
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Ace Bob
500 9500
500 9500
{gamerTag:1
, score:-1}
So is there anything we can do to
improve the performance of this query?
$or (single) Index visualization
Actual (Hinted) Index Bounds:
"indexBounds" : {
"gamerTag" : [
"[MinKey, MaxKey]"
],
"score" : [
"[MaxKey, MinKey]"
]}
Expected Index Bounds:
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]"
],
"score" : [
"[inf.0, 9000]"
]}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Recommendations
Use multiple indexes!
db.data.createIndex({gamerTag: 1})
db.data.createIndex({score: 1})
$or (multiple) Index visualization
Ace Bob
{gamerTag:1
, score:-1}
500 9500
500 9500
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob
{gamerTag:1}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob
{gamerTag:1}
500
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob
{gamerTag:1}
500 9500
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob
{gamerTag:1}
500 9500
{score:1}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob
{gamerTag:1}
500 9500
{score:1}
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]”
]
}
"indexBounds" : {
"score" : [
"(9000.0, inf.0]”
]
}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Ace Bob 500 9500
{score:1}{gamerTag:1}
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]”
]
}
"indexBounds" : {
"score" : [
"(9000.0, inf.0]”
]
}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Bob 500 9500
{score:1}
Ace
{gamerTag:1}
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]”
]
}
"indexBounds" : {
"score" : [
"(9000.0, inf.0]”
]
}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Bob 500 9500
{score:1}{gamerTag:1}
Ace
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]”
]
}
"indexBounds" : {
"score" : [
"(9000.0, inf.0]”
]
}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Bob 500 9500
{gamerTag:1}
Ace
{score:1}
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]”
]
}
"indexBounds" : {
"score" : [
"(9000.0, inf.0]”
]
}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
$or (multiple) Index visualization
Bob 500 9500
{gamerTag:1}
Ace
{score:1}
"indexBounds" : {
"gamerTag" : [
"["Ace", "Ace"]”
]
}
"indexBounds" : {
"score" : [
"(9000.0, inf.0]”
]
}
db.games.find({
$or : [
{ gamerTag: "Ace" },
{ score: {$gt: 9000} }
]
})
Recommendations
Use multiple indexes!
db.data.createIndex({gamerTag: 1})
db.data.createIndex({score: 1})
Recommendations
Use multiple indexes!
db.data.createIndex({gamerTag: 1})
db.data.createIndex({score: 1})
We already have the {gamerTag:1, score:-1}
index, do we need both of these new ones?
Recommendations
Use multiple indexes!
db.data.createIndex({gamerTag: 1})
db.data.createIndex({score: 1})
db.games.createIndex({ gamerTag: 1, score:-1 })
Stakeholder #2 Concern
db.games.find({
$or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]
})
Having the right index is critical
"Super!!”
93
Stakeholder #3 Concern
“Wait wait wait, we can’t even FIND the gamers!”
A basic search on gamerTag takes several seconds already:
db.games.find({gamerTag: /^Ace$/i})
“This query is SLOWER with the index than it is without it!”
Case Insensitive
Queries
Matching games:
{ gamerTag: "Ace", score: 9500 }
Non-matching games:
{ gamerTag: "ACE", score: 500 },
{ gamerTag: "aCe", score: 9500 },
{ gamerTag: "ace", score: 0 },
{ gamerTag: "Bob", score: 500 },
{ gamerTag: "acxyz", score: 9500 },
{ gamerTag: "Ace mdb", score: 9500 }
db.games.find({
gamerTag: /^Ace$/
})
//equivalent to
db.games.find({
gamerTag: “Ace”
})
Case Sensitive
Case Sensitive
ace aCe acxyz Ace
Ace
mdb
ACE Bob
"indexBounds" : {
"gamerTag" : [
"["Ace", "Acf")",
"[/^Ace$/, /^Ace$/]"
]}
Matching games:
{ gamerTag: "Ace", score: 9500 }
Non-matching games:
{ gamerTag: "ACE", score: 500 },
{ gamerTag: "aCe", score: 9500 },
{ gamerTag: "ace", score: 0 },
{ gamerTag: "Bob", score: 500 },
{ gamerTag: "acxyz", score: 9500 },
{ gamerTag: "Ace mdb", score: 9500 }
Matching games:
{ gamerTag: "Ace", score: 9500 },
{ gamerTag: "ACE", score: 500 },
{ gamerTag: "aCe", score: 9500 },
{ gamerTag: "ace", score: 0 }
Non-matching games:
{ gamerTag: "Bob", score: 500 },
{ gamerTag: "acxyz", score: 9500 },
{ gamerTag: "Ace mdb", score: 9500 }
Case Insensitive
db.games.find({
gamerTag: /^Ace$/i
})
//equivalent to
db.games.find({
gamerTag: {
$regex: “^Ace$”,
$options: “i”
}
})
//equivalent to
db.games.find({ gamerTag: “Ace”})
.collation({locale:’en’,strength:2})
Case Insensitive
db.games.find({
gamerTag: /^Ace$/i
})
//equivalent to
db.games.find({
gamerTag: {
$regex: “^Ace$”,
$options: “i”
}
})
//equivalent to
db.games.find({ gamerTag: “Ace”})
.collation({locale:’en’,
strength:2})
Would a $text search be the same as well?
Matching games:
{ gamerTag: "Ace", score: 9500 },
{ gamerTag: "ACE", score: 500 },
{ gamerTag: "aCe", score: 9500 },
{ gamerTag: "ace", score: 0 }
Non-matching games:
{ gamerTag: "Bob", score: 500 },
{ gamerTag: "acxyz", score: 9500 },
{ gamerTag: "Ace mdb", score: 9500 }
Case Insensitive
ace aCe acxyz Ace
Ace
mdb
ACE Bob
"indexBounds" : {
"gamerTag" : [
“["", {})",
"[/^Ace$/i, /^Ace$/i]"
]
}
Matching games:
{ gamerTag: "Ace", score: 9500 },
{ gamerTag: "ACE", score: 500 },
{ gamerTag: "aCe", score: 9500 },
{ gamerTag: "ace", score: 0 }
Non-matching games:
{ gamerTag: "Bob", score: 500 },
{ gamerTag: "acxyz", score: 9500 },
{ gamerTag: "Ace mdb", score: 9500 }
100
Recommendations
Case insensitive index!
Collations available since 3.4
101
Recommendations
Case insensitive index!
Collations available since 3.4
db.games.createIndex( { gamerTag: 1},
{ collation: { locale: 'en', strength: 2 } } )
Store a transformed (eg toLower()) copy of the string
102
https://docs.mongodb.com/manual/reference/collation/index.html
Collations
103
Stakeholder #3 Concern
db.games.find({gamerTag: “Ace”})
.collation({locale:'en', strength:2})
104
Stakeholder #3 Concern
db.games.find({gamerTag: “Ace”})
.collation({locale:'en', strength:2})
105
Stakeholder #3 Concern
db.games.find({gamerTag: “Ace”})
.collation({locale:'en', strength:2})
“Wow, MongoDB can do anything!!!!1!”
Summary
107
Work Smarter Not Harder
Understand the business logic
Index appropriately
Is it the right index to support the query?
Be aware of:
Blocking Stages
Usage of $or
Case sensitivity
Leverage the Performance Advisor
108
Work Smarter Not Harder
Understand the business logic
Index appropriately
Is it the right index to support the query?
Be aware of:
Blocking Stages
Usage of $or
Case sensitivity
Leverage the Performance Advisor
109
Countdown to ShortFite
Powered by an optimized MongoDB
environment, ShortFite is sure to be a hit!
110
The Power of Query Optimization
Query tuning results in:
● Improved performance
● Reduced resource utilization
This may lead to:
● Improved stability and predictability
● A smaller hardware footprint
Not uncommon to observe efficiency improvements $gte 99%
111
Become the HERO!
- Plenty of resources out there
- http://university.mongodb.com
- http://docs.mongodb.com
Norberto Leite
Lead Engineer
norberto@mongodb.com
@nleite
Avoid Query Pitfalls

Weitere ähnliche Inhalte

Was ist angesagt?

Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingGareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingYury Chemerkin
 
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]MongoDB
 
Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Toria Gibbs
 
WordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingWordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingJonny Allbut
 
How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)Toria Gibbs
 
Why there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transportWhy there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transportCarl-Ivar Ahlqvist
 
A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017Toria Gibbs
 
MySQLConf2009: Taking ActiveRecord to the Next Level
MySQLConf2009: Taking ActiveRecord to the Next LevelMySQLConf2009: Taking ActiveRecord to the Next Level
MySQLConf2009: Taking ActiveRecord to the Next LevelBlythe Dunham
 
New opportunities for connected data
New opportunities for connected dataNew opportunities for connected data
New opportunities for connected dataNeo4j
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Craig Francis
 
Reading the .explain() Output
Reading the .explain() OutputReading the .explain() Output
Reading the .explain() OutputMongoDB
 
CouchDB @ red dirt ruby conference
CouchDB @ red dirt ruby conferenceCouchDB @ red dirt ruby conference
CouchDB @ red dirt ruby conferenceleinweber
 
Heroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedHeroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedSimon Bagreev
 
A17 indexing and query optimization by paul pederson
A17 indexing and query optimization by paul pedersonA17 indexing and query optimization by paul pederson
A17 indexing and query optimization by paul pedersonInsight Technology, Inc.
 
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185Mahmoud Samir Fayed
 

Was ist angesagt? (19)

Ecuacionesfuncionales2 1
Ecuacionesfuncionales2 1Ecuacionesfuncionales2 1
Ecuacionesfuncionales2 1
 
Ecuacionesfuncionales1 1
Ecuacionesfuncionales1 1Ecuacionesfuncionales1 1
Ecuacionesfuncionales1 1
 
Potential Friend Finder
Potential Friend FinderPotential Friend Finder
Potential Friend Finder
 
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingGareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
 
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
 
Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017Introduction to Search Systems - ScaleConf Colombia 2017
Introduction to Search Systems - ScaleConf Colombia 2017
 
WordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingWordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme building
 
How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)
 
Why there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transportWhy there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transport
 
A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017
 
MySQLConf2009: Taking ActiveRecord to the Next Level
MySQLConf2009: Taking ActiveRecord to the Next LevelMySQLConf2009: Taking ActiveRecord to the Next Level
MySQLConf2009: Taking ActiveRecord to the Next Level
 
New tags in html5
New tags in html5New tags in html5
New tags in html5
 
New opportunities for connected data
New opportunities for connected dataNew opportunities for connected data
New opportunities for connected data
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()
 
Reading the .explain() Output
Reading the .explain() OutputReading the .explain() Output
Reading the .explain() Output
 
CouchDB @ red dirt ruby conference
CouchDB @ red dirt ruby conferenceCouchDB @ red dirt ruby conference
CouchDB @ red dirt ruby conference
 
Heroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedHeroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons Learned
 
A17 indexing and query optimization by paul pederson
A17 indexing and query optimization by paul pedersonA17 indexing and query optimization by paul pederson
A17 indexing and query optimization by paul pederson
 
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185
 

Ähnlich wie Avoid Query Pitfalls

Tips and Tricks for Avoiding Common Query Pitfalls Christian Kurze
Tips and Tricks for Avoiding Common Query Pitfalls Christian KurzeTips and Tricks for Avoiding Common Query Pitfalls Christian Kurze
Tips and Tricks for Avoiding Common Query Pitfalls Christian KurzeMongoDB
 
MongoDB World 2018: Tips and Tricks for Avoiding Common Query Pitfalls
MongoDB World 2018: Tips and Tricks for Avoiding Common Query PitfallsMongoDB World 2018: Tips and Tricks for Avoiding Common Query Pitfalls
MongoDB World 2018: Tips and Tricks for Avoiding Common Query PitfallsMongoDB
 
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBLisa Roth, PMP
 
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB
 
MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...
MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...
MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB
 
MongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Will Button
 
GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑Pokai Chang
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parserkamaelian
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to TinkerpopTakahiro Inoue
 
Alexander Mostovenko "Modern approach to localization in javascript with the ...
Alexander Mostovenko "Modern approach to localization in javascript with the ...Alexander Mostovenko "Modern approach to localization in javascript with the ...
Alexander Mostovenko "Modern approach to localization in javascript with the ...OdessaJS Conf
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation Amit Ghosh
 
Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013Tanya Cashorali
 

Ähnlich wie Avoid Query Pitfalls (20)

Tips and Tricks for Avoiding Common Query Pitfalls Christian Kurze
Tips and Tricks for Avoiding Common Query Pitfalls Christian KurzeTips and Tricks for Avoiding Common Query Pitfalls Christian Kurze
Tips and Tricks for Avoiding Common Query Pitfalls Christian Kurze
 
MongoDB World 2018: Tips and Tricks for Avoiding Common Query Pitfalls
MongoDB World 2018: Tips and Tricks for Avoiding Common Query PitfallsMongoDB World 2018: Tips and Tricks for Avoiding Common Query Pitfalls
MongoDB World 2018: Tips and Tricks for Avoiding Common Query Pitfalls
 
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
 
MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...
MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...
MongoDB .local Bengaluru 2019: Tips and Tricks++ for Querying and Indexing Mo...
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Houston 2019:Tips and Tricks++ for Querying and Indexing MongoDB
 
Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Mongo db mug_2012-02-07
Mongo db mug_2012-02-07
 
GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 
Mongo indexes
Mongo indexesMongo indexes
Mongo indexes
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to Tinkerpop
 
Mongo Baseball .NET
Mongo Baseball .NETMongo Baseball .NET
Mongo Baseball .NET
 
Alexander Mostovenko "Modern approach to localization in javascript with the ...
Alexander Mostovenko "Modern approach to localization in javascript with the ...Alexander Mostovenko "Modern approach to localization in javascript with the ...
Alexander Mostovenko "Modern approach to localization in javascript with the ...
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 
Sam zhang demo
Sam zhang demoSam zhang demo
Sam zhang demo
 
Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013Microsoft NERD Talk - R and Tableau - 2-4-2013
Microsoft NERD Talk - R and Tableau - 2-4-2013
 
Indexing
IndexingIndexing
Indexing
 

Mehr von Norberto Leite

Data Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel AvivData Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel AvivNorberto Leite
 
MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016Norberto Leite
 
Geospatial and MongoDB
Geospatial and MongoDBGeospatial and MongoDB
Geospatial and MongoDBNorberto Leite
 
MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger InternalsNorberto Leite
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewNorberto Leite
 
MongoDB: Agile Combustion Engine
MongoDB: Agile Combustion EngineMongoDB: Agile Combustion Engine
MongoDB: Agile Combustion EngineNorberto Leite
 
MongoDB Capacity Planning
MongoDB Capacity PlanningMongoDB Capacity Planning
MongoDB Capacity PlanningNorberto Leite
 
Strongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible SchemasStrongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible SchemasNorberto Leite
 
Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMNorberto Leite
 
Advanced applications with MongoDB
Advanced applications with MongoDBAdvanced applications with MongoDB
Advanced applications with MongoDBNorberto Leite
 

Mehr von Norberto Leite (20)

Data Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel AvivData Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel Aviv
 
MongoDB and Spark
MongoDB and SparkMongoDB and Spark
MongoDB and Spark
 
Mongo db 3.4 Overview
Mongo db 3.4 OverviewMongo db 3.4 Overview
Mongo db 3.4 Overview
 
MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016
 
Geospatial and MongoDB
Geospatial and MongoDBGeospatial and MongoDB
Geospatial and MongoDB
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger Internals
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature Preview
 
Mongodb Spring
Mongodb SpringMongodb Spring
Mongodb Spring
 
MongoDB on Azure
MongoDB on AzureMongoDB on Azure
MongoDB on Azure
 
MongoDB: Agile Combustion Engine
MongoDB: Agile Combustion EngineMongoDB: Agile Combustion Engine
MongoDB: Agile Combustion Engine
 
MongoDB Capacity Planning
MongoDB Capacity PlanningMongoDB Capacity Planning
MongoDB Capacity Planning
 
Spark and MongoDB
Spark and MongoDBSpark and MongoDB
Spark and MongoDB
 
Analyse Yourself
Analyse YourselfAnalyse Yourself
Analyse Yourself
 
Python and MongoDB
Python and MongoDB Python and MongoDB
Python and MongoDB
 
Strongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible SchemasStrongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible Schemas
 
Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEM
 
Advanced applications with MongoDB
Advanced applications with MongoDBAdvanced applications with MongoDB
Advanced applications with MongoDB
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
 

Kürzlich hochgeladen

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 

Kürzlich hochgeladen (20)

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 

Avoid Query Pitfalls

  • 2. 2 Agenda Common Query Pitfalls How to think about and how to solve them Tips and Tricks for Query Optimization
  • 3. 3 Howdy! Disclaimer Who's this guy? Norberto Leite Lead Engineer @nleite MongoDB
  • 7. 7 The Power of Query Optimization Query tuning results in: ● Improved performance ● Reduced resource utilization This may lead to: ● Improved stability and predictability ● Smaller hardware footprint Not uncommon to observe efficiency improvements $gte 99%
  • 8. Acme Games Introduces: ShortFite Tales of a release pre-launch testing
  • 10. Become a MongoDB Certified Developer / DBA
  • 11. 11 Stakeholder Concerns ● Game nearly complete ● Team starts to do capacity testing
  • 12. 12 Stakeholder Concerns ● Game nearly complete ● Team starts to do capacity testing Indexes support the efficient execution of queries in MongoDB
  • 13. 13 Stakeholder Concerns ● Game nearly complete ● Team starts to do capacity testing Ace Sue … … Bob Indexes support the efficient execution of queries in MongoDB
  • 14. Stakeholder #1 Concern App being stress tested Concerns over current performance
  • 15. Stakeholder #1 Concern Developers created index db.games.createIndex({ gamerTag: 1 }) This query takes several seconds to execute: db.games.find( { gamerTag: "Ace" } ).sort({score:-1}) Adding the index on score does not help! db.games.createIndex({ score: -1 })
  • 16. Stakeholder #1 Concern Developers created index db.games.createIndex({ gamerTag: 1 }) This query takes several seconds to execute: db.games.find( { gamerTag: "Ace" } ).sort({score:-1}) Adding the index on score does not help! db.games.createIndex({ score: -1 }) “Clearly MongoDB is not webscale!”
  • 18. 18 Blocking Operation Formally: “An operation which must process all input before it can begin to produce any output.” Opposite of the often desirable “fully pipelined” plan which can stream results back as soon as they are found. Commonly observed when a sort is added to a query
  • 27. Indexes that support sorting db.games.createIndex({ gamerTag: 1, score:-1})
  • 32. 32 Blocking Stages $sort In aggregation and find $group $bucket $count $facet Are there any other blocking operations?
  • 34. 34 Working with blocking stages For sorting: Add a supporting index Worth the overhead in almost all circumstances For other stages: Do you need the blocking stage? Offload to secondary member
  • 35. Stakeholder #1 Concern Performance of db.games.find( { gamerTag: "Ace" } ).sort({score:-1}) “Clearly MongoDB is not webscale!”
  • 36. Stakeholder #1 Concern Performance of db.games.find( { gamerTag: "Ace" } ).sort({score:-1}) db.games.createIndex({ gamerTag: 1, score:-1 })
  • 37. Stakeholder #1 Concern Performance of db.games.find( { gamerTag: "Ace" } ).sort({score:-1}) db.games.createIndex({ gamerTag: 1, score:-1 }) "That’ll work great!”
  • 38. Stakeholder #2 Concern The $and version of a query returns quickly: db.games.find({ $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] }) But the $or version is slow: db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 39. Concern #2: Multiple queries same index The $and version of a query returns quickly: db.games.find({ $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] }) But the $or version is slow: db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] }) We just created an index with both those fields… Can it be used?
  • 40. $or
  • 41. $and example Query on games: db.games.find({ $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] }) Matching games: { gamerTag: "Ace", score: 9500 } Non-matching games: { gamerTag: "Ace", score: 500 }, { gamerTag: "Bob", score: 9500 }, { gamerTag: "Bob", score: 500 }
  • 42. Groups of documents score: {$gt: 9000}gamerTag: "Ace" { gamerTag: "Ace", score: 9500 } { gamerTag: "Ace", score: 500 } { gamerTag: "Bob", score: 9500 } { gamerTag: "Bob", score: 500 }
  • 43. gamerTag: "Ace" $and Venn Diagram (logical) score: {$gt: 9000} { gamerTag: "Ace", score: 9500 } { gamerTag: "Ace", score: 500 } { gamerTag: "Bob", score: 9500 } { gamerTag: "Bob", score: 500 } db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 44. $and Venn Diagram (logical) { gamerTag: "Bob", score: 500 } gamerTag: "Ace" { gamerTag: "Ace", score: 500 } db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 45. gamerTag: "Ace" $and Venn Diagram (logical) score: {$gt: 9000} db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 46. gamerTag: "Ace" $and Venn Diagram (logical) score: {$gt: 9000} db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 47. $and Venn Diagram (logical) score: {$gt: 9000}gamerTag: "Ace" db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 48. $and Venn Diagram (logical) score: {$gt: 9000}gamerTag: "Ace" db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 49. $and Venn Diagram (logical) score: {$gt: 9000}gamerTag: "Ace" db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 50. Ace Bob {gamerTag:1 , score:-1} 500 9500 500 9500 $and Index Visualization db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 51. Ace Bob {gamerTag:1 , score:-1} 500 9500 500 9500 "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000.0)" ] } $and Index Visualization db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 52. Ace Bob 500 9500 500 9500 {gamerTag:1 , score:-1} $and Index Visualization "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000.0)" ] } db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 53. Bob 500 9500 500 9500 Ace {gamerTag:1 , score:-1} $and Index Visualization "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000.0)" ] } db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 54. $and Index Visualization Bob 500 500 9500 Ace 9500 {gamerTag:1 , score:-1} "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000.0)" ] } db.games.find( { $and : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ]})
  • 55. $or example Query on games: db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] }) Matching games: { gamerTag: "Ace", score: 9500 }, { gamerTag: "Ace", score: 500 }, { gamerTag: "Bob", score: 9500 } Non-matching games: { gamerTag: "Bob", score: 500 }
  • 56. gamerTag: "Ace" $or Venn Diagram (logical) score: {$gt: 9000} { gamerTag: "Ace", score: 9500 } { gamerTag: "Ace", score: 500 } { gamerTag: "Bob", score: 9500 } { gamerTag: "Bob", score: 500 } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 57. $or Venn Diagram (logical) score: {$gt: 9000} { gamerTag: "Ace", score: 9500 } { gamerTag: "Ace", score: 500 } { gamerTag: "Bob", score: 9500 } { gamerTag: "Bob", score: 500 } gamerTag: "Ace" db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 58. $or Venn Diagram (logical) score: {$gt: 9000} { gamerTag: "Ace", score: 9500 } { gamerTag: "Ace", score: 500 } { gamerTag: "Bob", score: 9500 } { gamerTag: "Bob", score: 500 } gamerTag: "Ace" db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 59. score: {$gt: 9000} $or Venn Diagram (logical) { gamerTag: "Ace", score: 9500 } { gamerTag: "Bob", score: 500 } { gamerTag: "Ace", score: 500 } gamerTag: "Ace" { gamerTag: "Bob", score: 9500 } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 60. score: {$gt: 9000}gamerTag: "Ace" $or Venn Diagram (logical) { gamerTag: "Ace", score: 9500 } { gamerTag: "Ace", score: 500 } { gamerTag: "Bob", score: 9500 } { gamerTag: "Bob", score: 500 } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 61. score: {$gt: 9000}gamerTag: "Ace" $or Venn Diagram (logical) db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 62. score: {$gt: 9000}gamerTag: "Ace" $or Venn Diagram (logical) db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 63. score: {$gt: 9000}gamerTag: "Ace" $or Venn Diagram (logical) db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 64. score: {$gt: 9000} $or Venn Diagram (logical) gamerTag: "Ace" db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 65. score: {$gt: 9000} $or Venn Diagram (logical) gamerTag: "Ace" db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 66. $or (single) Index visualization Ace Bob {gamerTag:1 , score:-1} 500 9500 500 9500 db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 67. Ace Bob {gamerTag:1 , score:-1} 500 9500 500 9500 Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} $or (single) Index visualization db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 68. Ace Bob 500 9500 500 9500 {gamerTag:1 , score:-1} $or (single) Index visualization Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 69. Bob 500 9500 500 9500 {gamerTag:1 , score:-1} Ace $or (single) Index visualization Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 70. Bob 500 9500 {gamerTag:1 , score:-1} Ace 500 9500 $or (single) Index visualization Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 71. 500 Bob 9500 $or (single) Index visualization {gamerTag:1 , score:-1} Ace 500 9500 Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 72. 500 Bob 9500 Actual (Hinted) Index Bounds: "indexBounds" : { "gamerTag" : [ "[MinKey, MaxKey]" ], "score" : [ "[MaxKey, MinKey]" ]} $or (single) Index visualization {gamerTag:1 , score:-1} Ace 500 9500 Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 73. Ace Bob 500 9500 500 9500 {gamerTag:1 , score:-1} So is there anything we can do to improve the performance of this query? $or (single) Index visualization Actual (Hinted) Index Bounds: "indexBounds" : { "gamerTag" : [ "[MinKey, MaxKey]" ], "score" : [ "[MaxKey, MinKey]" ]} Expected Index Bounds: "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]" ], "score" : [ "[inf.0, 9000]" ]} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 75. $or (multiple) Index visualization Ace Bob {gamerTag:1 , score:-1} 500 9500 500 9500 db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 76. $or (multiple) Index visualization db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 77. $or (multiple) Index visualization Ace db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 78. $or (multiple) Index visualization Ace Bob db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 79. $or (multiple) Index visualization Ace Bob {gamerTag:1} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 80. $or (multiple) Index visualization Ace Bob {gamerTag:1} 500 db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 81. $or (multiple) Index visualization Ace Bob {gamerTag:1} 500 9500 db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 82. $or (multiple) Index visualization Ace Bob {gamerTag:1} 500 9500 {score:1} db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 83. $or (multiple) Index visualization Ace Bob {gamerTag:1} 500 9500 {score:1} "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]” ] } "indexBounds" : { "score" : [ "(9000.0, inf.0]” ] } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 84. $or (multiple) Index visualization Ace Bob 500 9500 {score:1}{gamerTag:1} "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]” ] } "indexBounds" : { "score" : [ "(9000.0, inf.0]” ] } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 85. $or (multiple) Index visualization Bob 500 9500 {score:1} Ace {gamerTag:1} "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]” ] } "indexBounds" : { "score" : [ "(9000.0, inf.0]” ] } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 86. $or (multiple) Index visualization Bob 500 9500 {score:1}{gamerTag:1} Ace "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]” ] } "indexBounds" : { "score" : [ "(9000.0, inf.0]” ] } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 87. $or (multiple) Index visualization Bob 500 9500 {gamerTag:1} Ace {score:1} "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]” ] } "indexBounds" : { "score" : [ "(9000.0, inf.0]” ] } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 88. $or (multiple) Index visualization Bob 500 9500 {gamerTag:1} Ace {score:1} "indexBounds" : { "gamerTag" : [ "["Ace", "Ace"]” ] } "indexBounds" : { "score" : [ "(9000.0, inf.0]” ] } db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] })
  • 90. Recommendations Use multiple indexes! db.data.createIndex({gamerTag: 1}) db.data.createIndex({score: 1}) We already have the {gamerTag:1, score:-1} index, do we need both of these new ones?
  • 91. Recommendations Use multiple indexes! db.data.createIndex({gamerTag: 1}) db.data.createIndex({score: 1}) db.games.createIndex({ gamerTag: 1, score:-1 })
  • 92. Stakeholder #2 Concern db.games.find({ $or : [ { gamerTag: "Ace" }, { score: {$gt: 9000} } ] }) Having the right index is critical "Super!!”
  • 93. 93 Stakeholder #3 Concern “Wait wait wait, we can’t even FIND the gamers!” A basic search on gamerTag takes several seconds already: db.games.find({gamerTag: /^Ace$/i}) “This query is SLOWER with the index than it is without it!”
  • 95. Matching games: { gamerTag: "Ace", score: 9500 } Non-matching games: { gamerTag: "ACE", score: 500 }, { gamerTag: "aCe", score: 9500 }, { gamerTag: "ace", score: 0 }, { gamerTag: "Bob", score: 500 }, { gamerTag: "acxyz", score: 9500 }, { gamerTag: "Ace mdb", score: 9500 } db.games.find({ gamerTag: /^Ace$/ }) //equivalent to db.games.find({ gamerTag: “Ace” }) Case Sensitive
  • 96. Case Sensitive ace aCe acxyz Ace Ace mdb ACE Bob "indexBounds" : { "gamerTag" : [ "["Ace", "Acf")", "[/^Ace$/, /^Ace$/]" ]} Matching games: { gamerTag: "Ace", score: 9500 } Non-matching games: { gamerTag: "ACE", score: 500 }, { gamerTag: "aCe", score: 9500 }, { gamerTag: "ace", score: 0 }, { gamerTag: "Bob", score: 500 }, { gamerTag: "acxyz", score: 9500 }, { gamerTag: "Ace mdb", score: 9500 }
  • 97. Matching games: { gamerTag: "Ace", score: 9500 }, { gamerTag: "ACE", score: 500 }, { gamerTag: "aCe", score: 9500 }, { gamerTag: "ace", score: 0 } Non-matching games: { gamerTag: "Bob", score: 500 }, { gamerTag: "acxyz", score: 9500 }, { gamerTag: "Ace mdb", score: 9500 } Case Insensitive db.games.find({ gamerTag: /^Ace$/i }) //equivalent to db.games.find({ gamerTag: { $regex: “^Ace$”, $options: “i” } }) //equivalent to db.games.find({ gamerTag: “Ace”}) .collation({locale:’en’,strength:2})
  • 98. Case Insensitive db.games.find({ gamerTag: /^Ace$/i }) //equivalent to db.games.find({ gamerTag: { $regex: “^Ace$”, $options: “i” } }) //equivalent to db.games.find({ gamerTag: “Ace”}) .collation({locale:’en’, strength:2}) Would a $text search be the same as well? Matching games: { gamerTag: "Ace", score: 9500 }, { gamerTag: "ACE", score: 500 }, { gamerTag: "aCe", score: 9500 }, { gamerTag: "ace", score: 0 } Non-matching games: { gamerTag: "Bob", score: 500 }, { gamerTag: "acxyz", score: 9500 }, { gamerTag: "Ace mdb", score: 9500 }
  • 99. Case Insensitive ace aCe acxyz Ace Ace mdb ACE Bob "indexBounds" : { "gamerTag" : [ “["", {})", "[/^Ace$/i, /^Ace$/i]" ] } Matching games: { gamerTag: "Ace", score: 9500 }, { gamerTag: "ACE", score: 500 }, { gamerTag: "aCe", score: 9500 }, { gamerTag: "ace", score: 0 } Non-matching games: { gamerTag: "Bob", score: 500 }, { gamerTag: "acxyz", score: 9500 }, { gamerTag: "Ace mdb", score: 9500 }
  • 101. 101 Recommendations Case insensitive index! Collations available since 3.4 db.games.createIndex( { gamerTag: 1}, { collation: { locale: 'en', strength: 2 } } ) Store a transformed (eg toLower()) copy of the string
  • 103. 103 Stakeholder #3 Concern db.games.find({gamerTag: “Ace”}) .collation({locale:'en', strength:2})
  • 104. 104 Stakeholder #3 Concern db.games.find({gamerTag: “Ace”}) .collation({locale:'en', strength:2})
  • 105. 105 Stakeholder #3 Concern db.games.find({gamerTag: “Ace”}) .collation({locale:'en', strength:2}) “Wow, MongoDB can do anything!!!!1!”
  • 107. 107 Work Smarter Not Harder Understand the business logic Index appropriately Is it the right index to support the query? Be aware of: Blocking Stages Usage of $or Case sensitivity Leverage the Performance Advisor
  • 108. 108 Work Smarter Not Harder Understand the business logic Index appropriately Is it the right index to support the query? Be aware of: Blocking Stages Usage of $or Case sensitivity Leverage the Performance Advisor
  • 109. 109 Countdown to ShortFite Powered by an optimized MongoDB environment, ShortFite is sure to be a hit!
  • 110. 110 The Power of Query Optimization Query tuning results in: ● Improved performance ● Reduced resource utilization This may lead to: ● Improved stability and predictability ● A smaller hardware footprint Not uncommon to observe efficiency improvements $gte 99%
  • 111. 111 Become the HERO! - Plenty of resources out there - http://university.mongodb.com - http://docs.mongodb.com