Table Inheritance: what is a leaf entity? #8854
-
Interesting question I've found on StackOverflow: What is a leaf entity in the inheritance hierarchy and what are examples of? From Doctrine's documentation:
I don't understand this part of the documentation. What is exactly preferable and what kind of performance issues can one expect if non-leaf entities are used? Let's say we've got these entites:
Can I have a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, it can, but there will be a performance hit you would not have if you were using a leaf entity: the cost in performance is the cost of hydrating the engine, from what I understand. When you instantiate an
If you are instead targeting a leaf class, the query + hydration would only happen when doing While there is a performance hit, it's probably pretty mild though, but only you can tell. |
Beta Was this translation helpful? Give feedback.
Yes, it can, but there will be a performance hit you would not have if you were using a leaf entity: the cost in performance is the cost of hydrating the engine, from what I understand. When you instantiate an
Automobile
, the ORM cannot create a proxy instance for the engine, so it will:AbstractEngine
with that dataIf you are instead targeting a leaf class, the query + hydration would only happen when doing
$automobile->engine()->name()
. In the first case, it happens when doingnew Automobile()
.While there is a performance hit, it's probably…