log mongodb slow query

8
Log MongoDB Slow Query

Upload: hadi-ariawan

Post on 31-Jul-2015

62 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: Log MongoDB slow query

Log MongoDB Slow Query

Page 2: 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●…

Page 3: Log MongoDB slow query

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.

Page 4: Log MongoDB slow query

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/

Page 5: Log MongoDB slow query

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

Page 6: Log MongoDB slow query

System.Profile● MMS (MongoDB Monitoring System) to help you with this

Page 7: Log MongoDB slow query

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?

Page 8: Log MongoDB slow query

Thank you!@hadiariawan