Got Index?

931 views

Published on

Do all your queries use proper indexes? Really? A real life experience: In this talk I will reveal what might happen to your system if your queries do not use indexes and how to avoid this situation. I will show you different "built-in" possibilities to prevent missing indexes, and why they did not work for us! To solve the indexing issues we encountered at our company, I created a tool called "Mongo Query Inspector", which will be the main focus in this talk.

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

No Downloads
Views
Total views
931
On SlideShare
0
From Embeds
0
Number of Embeds
247
Actions
Shares
0
Downloads
26
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

×