I have a query that does something like this,
last_shipment_id = OrderDelivery.where(platform: 'business').desc(:shipment_id).limit(1).pluck(:shipment_id)[0]
It works fine from 1 ~ 5 ms when I index correctly using {platform: 1, shipment_id: -1} without a shell in an intermediate computer
However, our production is tuned with 4 shards of mongo db, the result ends in 1000-3000 m.
Does anyone know how this can happen or how to solve it?
I read about this slides https://www.slideshare.net/mongodb/how-queries-work-with-sharding
Well, he said on slide 13, but still not sure if he mentioned how to solve this issue.
ruby-on-rails mongodb mongoid
Bernie Chiu
source share