I have a query that performs something like this,
last_shipment_id = OrderDelivery.where(platform: 'business').desc(:shipment_id).limit(1).pluck(:shipment_id)[0]
It works great with only 1 ~ 5ms when I have correctly index with { platform: 1, shipment_id: -1 } without sharding environment in staging machine
However, our production is set up with 4 sharding mongo db, the result ends up in 1000 ~ 3000ms.
Does anyone know how this could happen or how might solve this case?
I've read about this slides https://www.slideshare.net/mongodb/how-queries-work-with-sharding
Well, it's said on slide 13, but still not sure it has mentioned how to solve the case though.