[SERVER-2991] Nice to have bson fields returned in determined order to making loading into data type / object faster. Created: 23/Apr/11  Updated: 06/Dec/22

Status: Open
Project: Core Server
Component/s: Querying
Affects Version/s: 1.8.1
Fix Version/s: features we're not sure of

Type: New Feature Priority: Minor - P4
Reporter: Tony Hannan Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-12599 When projection is present in a query... Closed
Related
related to SERVER-2592 The fields in a document are reordere... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

If the bson fields are in a known order then they can be mapped/loaded into the data type directly. Otherwise, you have to use a dictionary to map bson fields to object fields. Mongo could specify the order (eg. sorted) and the data type could be made to match that. Alternatively, a query with a projection (subset of fields to retrieve) can return documents with fields ordered the same as the projection.



 Comments   
Comment by Greg Weber [ 23/Apr/11 ]

Just to clarify, we have an "ORM" with a MongoDB backend: http://www.yesodweb.com/book/persistent. Many other ORMs will lazily access MongoDB fields from a hash so they don't care as much about ordering. In our case, we are immediately instantiating a data structure. So we need to match up all the mongo fields with the data structure fields. The fastest way is to have a guarantee on the ordering of the fields returned from the server. This could come from a guarantee that they won't change on update as part of addressing SERVER-2592. Technically we could rely on the state of 2592 now to maintain an alphabetical ordering, but that seems ugly and could change with a new version of mongodb. Another solution would be to get the fields back in the same order in which a projection is specified.

Generated at Thu Feb 08 03:01:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.