Currently, I am experimenting with an EAV+Single Table Inheritance approach in Doctrine 2.
I have a Base-Class that has many Values and I have multiple Sub-Classes of the Base-Class. The Sub-Classes are related.
In the following CodeExample all Entities are SubClasses of the BaseClass except for Value.
In this example the hydration takes 3200 ms:
$qb = $this->createQueryBuilder('p')
->select('p', 'rip', 'rs', 'c', 'pv', 'ripv', 'rsv', 'cv')
->leftJoin("p.revisionsInProject", "rip")
->leftJoin("rip.revisionState", "rs")
->leftJoin("rs.component", "c")
->leftJoin("p.values", "pv")
->leftJoin("c.values", "cv")
->leftJoin("rs.values", "rsv")
->leftJoin("rip.values", "ripv")
->where("p.id = '".$id."'");
$q = $qb->getQuery();
return $q->getSingleResult();
In this example the hydration only takes 302 ms. The only difference is that I removed the p.values
and the pv
from the query.
$qb = $this->createQueryBuilder('p')
->select('p', 'rip', 'rs', 'c', 'ripv', 'rsv', 'cv')
->leftJoin("p.revisionsInProject", "rip")
->leftJoin("rip.revisionState", "rs")
->leftJoin("rs.component", "c")
->leftJoin("c.values", "cv")
->leftJoin("rs.values", "rsv")
->leftJoin("rip.values", "ripv")
->where("p.id = '".$id."'");
$q = $qb->getQuery();
return $q->getSingleResult();
The Problem does not solved when I use other hydrations modes like ARRAY
or SCALAR
. They are a bit faster but still ridiculously long.
Can anybody explain why this is happening? The other values (c.values, rs.values, rip.values
) do not significantly change the performance.
The Code itself can viewed at Github