1

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!

glock18
  • 670
  • 5
  • 11
  • Nothing here, https://docs.mongodb.com/manual/reference/method/db.getReplicationInfo/ ? – Hardik Shah Jul 16 '18 at 12:42
  • Hardik, it seems to give somewhat similar info to what `rs.printReplicationInfo()` gives. Found [here](https://stackoverflow.com/questions/22008822/mongo-get-size-of-single-document) an example, and cherrypicked a document for operation I was interested in. I think it answers the question, the document was around 3M... yikes! Them mongo array updates... – glock18 Jul 16 '18 at 13:00
  • OpLog doesn't include queries! Only DML operations what add, change or delete data are at the OpLog. To see size of queries, you need to enable profiling to the mongod.log with command `db.setProfilingLevel(0,-1)` – JJussi Jul 16 '18 at 14:15
  • JJussi, I was interested precisely in the size of documents of oplog (DML operations or whatever they are). They aren't queries per se as they are write operations, not read, likely used a wrong word, but I hope the idea is now clear. I need to know how much of space these operations take up in order to find which ones may be optimized (for example pushing to an 60k length array is really bad in this regard due to oplog's idempotency) – glock18 Jul 16 '18 at 14:56

1 Answers1

0

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.

glock18
  • 670
  • 5
  • 11