Search code examples
mongodbreplicasetmongodb-oplog

Analyze Mongo oplog for "biggest" queries


Question: Is there a way to know the actual size of a sample document in collection (namely oplog)?

My oplog appears to be too small for the data. I have an idea which queries are likely the biggest contributor, but I'd like to gauge the impact of cutting the queries down before doing so.

Here is some context:

> rs.printReplicationInfo()
configured oplog size:   990MB
log length start to end: 280secs (0.08hrs)
oplog first event time:  Mon Jul 16 2018 09:18:16 GMT+0000 (GMT)
oplog last event time:   Mon Jul 16 2018 09:22:56 GMT+0000 (GMT)
now:                     Mon Jul 16 2018 09:22:56 GMT+0000 (GMT)

> db.getCollection('oplog.rs').stats()
count: 4374

PS: 250kb on average per document seems way too much in general, doesn't it?

Thank you in advance!


Solution

  • This SO answer basically covers how one can get size of the document.

    I cherrypicked a document based on my presumption, and found that its size is around 3Mb.

    Unfortunately it's only good enough if one has any clues on what to look for. Good enough to solve my issue and the question in topic.

    It would be great if it was possible to get the biggest documents from the collection, though.