You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enforce order in result.changes for batch insert? #3853
In result.changes, I may not get the same order (I may get 4, 1, 3, 2 and not 1, 2, 3, 4). Would it be possible to enforce the order of changes on the server?
That sounds difficult since those inserts can be routed to different shards and part of the performance benefit of batched inserts comes from the fact that they do not have to be serialized but can be processed in any order.
Do you have a specific use case in mind for which this matters?
Once the query comes back, I create instances of the model using what is in changes. Since it doesn't come back in the same order, I may return [doc2, doc3, doc1] which is not super friendly.
The current field generated_keys enforce an order if I'm not mistaken so maybe the server could use that? While it would be nice for thinky, no one complained so far (or no complains reached me ^_^) so I guess it's not that important.
It's a little harder because we generate the keys on the parsing node but the changes are calculated on the shards, so we'll have to re-order them once we get them back. But it should be perfectly doable since the primary key is preserved.
Activity
danielmewes commentedon Feb 28, 2015
That sounds difficult since those inserts can be routed to different shards and part of the performance benefit of batched inserts comes from the fact that they do not have to be serialized but can be processed in any order.
Do you have a specific use case in mind for which this matters?
neumino commentedon Feb 28, 2015
So with thinky I let people do batch inserts:
Once the query comes back, I create instances of the model using what is in
changes. Since it doesn't come back in the same order, I may return[doc2, doc3, doc1]which is not super friendly.The current field
generated_keysenforce an order if I'm not mistaken so maybe the server could use that? While it would be nice for thinky, no one complained so far (or no complains reached me ^_^) so I guess it's not that important.Also Slightly related to #3074.
danielmewes commentedon Mar 2, 2015
Oh sorry I thought you were talking about changefeeds.
Returning
changesin the same order as the input sounds reasonable.mlucy commentedon Mar 3, 2015
It's a little harder because we generate the keys on the parsing node but the changes are calculated on the shards, so we'll have to re-order them once we get them back. But it should be perfectly doable since the primary key is preserved.
danielmewes commentedon Dec 3, 2015
Marking as a duplicate of #5041