When displaying 10 nodes in English without translations, with interface and content language english, on a site with german and french enabled, it looks like getTranslation() is calling out to addTranslation() 20 times. That creates new entities, which is slow. It's 20x, because it calls getTranslation() for de and fr.
There seem to be two problems:
- Why is entity->getTranslation() called for de and fr, when I'm never interested in displaying that? Looks like field_invoke_method_multiple() is responsible for calling them, because it seems to call those methods for all languages. I have a feeling that will possibly help here?
- The second problem is that creating new entities with entity_create() or the storage controller is very slow. Maybe that's also something that is already improved in the above issue, if not we should check if there's a faster way. Maybe we can make entity_create() and the default value process itself faster? Field objects could track if they already have default values, so that we could lazy-generate them when requested? Because doing it in advance creates a million field and field item objects, generates UUID's and so on.