In every languages driver there should be an order preserving map/dict/etc.
If you don't use them then you don't care about order... and live with
the consequences. Up to you.
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
Also, be aware of the ~800 byte index key limit (which hopefully will go away).
http://www.mongodb.org/display/DOCS/Indexes#Indexes-KeysTooLargeToIndex
Wes
Or you could use the MongoDB BSON ordered containers in those
respective languages:
Python: http://api.mongodb.org/python/current/api/bson/son.html
(subclass of dict)
Ruby: Looks like the Ruby driver used to have an OrderedHash for Ruby
1.8 support, but maybe they took that out?
Java: http://api.mongodb.org/java/2.2/org/bson/BasicBSONObject.html
(uses LinkedHashMap)
I don't profess to be an expert on the database internals, but
consider the performance of the backing index implementation. In order
to do it your way, it would probably need to be a multikey index,
which is not nearly as efficient as one big key that can be directly
compared byte by byte. There wouldn't be any benefit
(performance-wise) in using a document index over using a multikey
index.
Maybe it could work (without too much performance sacrifice) with some
sort of normalization of the BSON before it goes into the index
key--sort the documents on their keys as they're fed into the index?
I'm happy with the way it is, but you could create a JIRA issue to see
if anyone else shares your concern.
Wes
Wes
--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
db.xxx.drop();db.xxx.insert({ id: {bar:2, foo:1}, name:"bob"});db.xxx.insert({ name:"bob", id: {bar:2, foo:1}});db.xxx.insert({ id: {foo:1, bar:2}, name:"bob"});db.xxx.find({ id: {bar:2, foo:1}, name:"bob"}); // only returns the first twoThe first two ARE equivalent, because field ordering is unimportant. As such, the following line executed before you did any insert()s would cause the second insert to fail (as well it should);
db.xxx.ensureIndex({id:1},{unique:1});However, the THIRD insert() where foo and bar are swapped in order, *should* be equivalent to both the two previous ones, but clearly it isn't. It is not returned from a find() and would be deemed unique by the index.
The Mongo docs have this to say;"MongoDB does not make guarantees regarding the order of fields in a BSON document. Drivers and MongoDB will reorder the fields of a documents upon insertion and following updates."
However, id is *also* considered a BsonDocument.