Score:0

Base fields vs Config fields?

eg flag

I have an entity and I am not sure what I should use. On the one hand, configuration fields are easier to use via the UI, why should I consider base fields?

By using base fields everything is stored in the same table, would there be any kind of performance improvement if I have many entities?

I can't find anywhere where it is explained why to opt for one or the other. Thank you very much

4uk4 avatar
cn flag
Yes, that's it. It's not only easier to configure fields in UI, it's also easier to deploy the changes. If you change a base field in a module you need to write an update hook.
Jaypan avatar
de flag
You should add that as an answer 4k4. But maybe word it as a pros and cons of each, for people to determine which better suits their needs and skills. Even though base fields are more of a hassle to maintain, for certain entity types I prefer to use them due to the architectural paradigm of it actually being a fundamental field to the entity, as well as the ensuing performance benefits. But the config fields are much easier to work with, and with entity caching removes the difference after initial load anyways.
Score:1
cn flag

Your question contains already the key points to consider. It's not only easier to configure fields in UI, it's also easier to deploy the changes. If you change a base field in a module you need to write an update hook.

On the other hand, if changes to the fields are unlikely and you expect a very high number of entities then use base fields like core for the alias entity.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.