I have a single-instance mongodb with a collection with 3 fields: _id, block_id, payload.
- Payloads are always 4096 byte binaries
- _id is an ever-incremented unique integer
There is a secondary index on the collection:
{ "v" : 1, "key" : { "block_id" : 1, "_id" : -1 },
"ns" : "testdb.testdev", "name" : "_block_id_id" }
I'm doing many queries like:
query: { query: { block_id: 868413 }, orderby: { _id: -1 } } ntoreturn:1 nscanned:1 nreturned:1 reslen:4166 163ms
There's no other query during these. When I read sequentially by block_id, it's 10 times faster than when I query with random block_id. I have low cpu usage, low storage utilization. The collection is 2-3 times bigger than the memory size.
What might be the bottleneck here?