3 ms·
Some things I didn't know: 1- While you can select only specific fields by using {fieldA: 1, fieldB: 1} as a 2nd parameter to find, you can also exclude fields
by latch 15y ago
Some things I didn't know:
1-
While you can select only specific fields by using {fieldA: 1, fieldB: 1} as a 2nd parameter to find, you can also exclude fields using -1. Interestingly though, you can't mix inclusion or exclusion (which makes sense if you think about it), except to exclude _id. So {name: 1, description: 1, _id: -1} is possible.
2-
Sending SIGUSR1 to the running mongod process will rotate the logs
3-
We got a 25% memory/storage reduction by shrinking our field names. YMMV. I knew how data was stored, but I didn't know what amount we would specifically save :P
4-
Count returns the value of found documents regardless of paging. This lets you pull documents + get total # very easily. If you pass true to count, you'll get the actual returned # of documents.
5-
Replica sets either have a priority of 0 or 1...future versions will introduce more flexibility
- iqster 15y agoWith respect to #3, is this happening because field names aren't getting compressed when stored as BSON objects? P.S. Your ebook and tutorial are great resources. Thanks for sharing!!
- jgmmo 15y agoNo, it's b/c of the document-oriented db system. All the field names are in every single one of the entries. Ex: If in every instance of 'Title' you had 't' instead. and every 'Post' you had 'p' instead --- it can add up to alot.
- latch 15y agoIt is a property of document dbs, though I'm pretty sure implementations could internalize field names. Imma guess 99% of all Mongo collections ever created are pretty damn structured. When creating a collection, you could specify {internalize: false} or something to disable this when you do lean heavily on the schemaless behavior, but otherwise I'd like to see MongoDB take care of this.
- rb2k_ 15y ago>3- We got a 25% memory/storage reduction by shrinking our field names. YMMV. I knew how data was stored, but I didn't know what amount we would specifically save :P I really wish they just had an internal lookup table to do that. I don't want to have to deal with keys like "c1, ba, la" in my application.
- latch 15y agoSome drivers/mappers support it. However, as much as MongoDB likes to lean on the drivers, this clearly belongs in the server.