Investigation
1
2
3

It is not cool when queries do not use indexes
1
2

notablescan
Regression tests will fail on
all CI environments due to
missing index exceptions
notablescan can
only be set on
the mongod
process

Integration and
acceptance tests
fail due to missing
indexes in test DB...
3
ENABLE
PROFILING
Set profiling level to 1
in order to log all
queries that run longer
than 100ms
If there is
no traffic,
queries without index
only need 2ms
4

explain()
We could use the
explain()
command to analyze
Queries
query
A TOOL THAT:

inspects
executed
queries for
missing
indexes

logs queries that did
not use an index

___is written
in node...
A TOOL THAT:

inspects
executed
queries for
missing
indexes

logs queries that did
not use an index

___is written
in node...
A TOOL THAT:

inspects
executed
queries for
missing
indexes

Logs queries that did
not use an index

is written
in node.js
Application
execute queries

MongoDB

collect profiling data (profiling level: 2)

system.profile

read profiling data

Mo...
Application
execute queries

MongoDB

collect profiling data (profiling level: 2)

system.profile

read profiling data

Mo...
Application
execute queries

MongoDB

collect profiling data (profiling level: 2)

system.profile

read profiling data

Mo...
Query
run explain on query
Explain
result

analyze
explain result
Index missing?
log query
and fields to
apply index
on

Y...
Query
run explain on query
Explain
result

analyze
explain result
Index missing?
log query
and fields to
apply index
on

Y...
Integrate the Inspector in your build pipeline…
SUMMARY:
Problem

approach

notablescan
profiling
explain()

Solution
SUMMARY:
Problem

approach

notablescan
profiling
explain()

Solution
SUMMARY:
Problem

approach

notablescan
profiling
explain()

Solution
https://github.com/meckert/mongoQueryInspector
detect
obsolete
indexes

Index
optimization

contributers
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Got index
Upcoming SlideShare
Loading in...5
×

Got index

170

Published on

Published in: Technology, Spiritual
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
170
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Got index

  1. 1. Investigation
  2. 2. 1
  3. 3. 2
  4. 4. 3 It is not cool when queries do not use indexes
  5. 5. 1
  6. 6. 2 notablescan
  7. 7. Regression tests will fail on all CI environments due to missing index exceptions
  8. 8. notablescan can only be set on the mongod process Integration and acceptance tests fail due to missing indexes in test DBs
  9. 9. 3 ENABLE PROFILING
  10. 10. Set profiling level to 1 in order to log all queries that run longer than 100ms
  11. 11. If there is no traffic, queries without index only need 2ms
  12. 12. 4 explain()
  13. 13. We could use the explain() command to analyze Queries
  14. 14. query
  15. 15. A TOOL THAT: inspects executed queries for missing indexes logs queries that did not use an index ___is written in node.js
  16. 16. A TOOL THAT: inspects executed queries for missing indexes logs queries that did not use an index ___is written in node.js
  17. 17. A TOOL THAT: inspects executed queries for missing indexes Logs queries that did not use an index is written in node.js
  18. 18. Application execute queries MongoDB collect profiling data (profiling level: 2) system.profile read profiling data Mongo Query Inspector
  19. 19. Application execute queries MongoDB collect profiling data (profiling level: 2) system.profile read profiling data Mongo Query Inspector
  20. 20. Application execute queries MongoDB collect profiling data (profiling level: 2) system.profile read profiling data Mongo Query Inspector
  21. 21. Query run explain on query Explain result analyze explain result Index missing? log query and fields to apply index on YES NO Keep calm and carry on!
  22. 22. Query run explain on query Explain result analyze explain result Index missing? log query and fields to apply index on YES NO keep calm and carry on!
  23. 23. Integrate the Inspector in your build pipeline…
  24. 24. SUMMARY: Problem approach notablescan profiling explain() Solution
  25. 25. SUMMARY: Problem approach notablescan profiling explain() Solution
  26. 26. SUMMARY: Problem approach notablescan profiling explain() Solution
  27. 27. https://github.com/meckert/mongoQueryInspector
  28. 28. detect obsolete indexes Index optimization contributers
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×