Search code examples
javamongodbmorphiadatabase

In MongoDB: longer property names make bigger documents / use more memory?


I use Mongo with its Java driver and Morphia. I am mapping this class:

public class Transaction {

    @Id
    private ObjectId id;
    private String transactionUniqueIdentifier;

}

I see in the console that Mongo saves a transaction in a form like {transactionUniqueIdentifier: "xjeer"}

Does it mean I should use shorter property names ("uuid" instead of "transactionUniqueIdentifier") to get a smaller database? Or is there a setting in Mongo which would deal with that for me (create shorter names internally...).
Any pointer would be appreciated, thx.


Solution

  • With morphia, the document property names match the java field names by default. You can name them however you'd like to be serialized into mongodb using the @Property annotation and providing whatever name you'd like.