log mongodb slow query
TRANSCRIPT
Log MongoDB Slow Query
Pricebook.co.id and MongoDB
●Pricebook.co.id; A shopping search engine, price comparison website based in Indonesia, launched on December 2013
●Fast growing●Millions and millions of documents●More than 27GB data size●…
Collecting performance data (1)● Enable MongoDB profilingdb.setProfilingLevel(1);
Table of profiling level
-1 No change. Returns the current profile level.
0 Off. No profiling.
1 On. Only includes slow operations.
2 On. Includes all operations.
By default slow operations are those slower than 100 milliseconds.You can change to whatever number that suits your platform.
Collecting performance data (2)
Example : Getting the slow queries below 200 miliseconds
db.setProfilingLevel(1,200);
“When you enable profiling, you also set the profiling level. The profiler records data in the system.profile collection. MongoDB creates the system.profile collection in a database after you enable profiling for that database.”
Read the complete reference here :http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/
Collecting performance data (3)
system.profile; Here is one example document of how it looks.
- what command? count product_id on searchindex collection- how long? 110 ms
System.Profile● MMS (MongoDB Monitoring System) to help you with this
what’s next?
OK, now we know what queries are slow.. and then..
Solutions might be different from one application type and another.
- Index? - Denormalize? Change schema design?- Scale up? Upgrade machine specs?
Thank you!@hadiariawan