prefer using hash in ActionManager::findOrCreateComponent
Closed this issue · 1 comments
shouze commented
Pain point
when the table grows a lot (million of lines), hash
is an indexed column while model
and identifier
are not 😢 .
The sadness resides in this picture:
Change proposal
The happiness resides in this picture ⚡️ 🦄 🎉
So, to implement that, I suggest to change ActionManager::findOrCreateComponent()
implementation to use the hash:
timeline-bundle/Driver/ORM/ActionManager.php
Lines 77 to 98 in e408d9d
public function findOrCreateComponent($model, $identifier = null, $flush = true)
{
$resolvedComponentData = $this->resolveModelAndIdentifier($model, $identifier);
$component = $this->getComponentRepository()
->createQueryBuilder('c')
->where('c.hash = :hash')
// Imply to add getHash method into https://github.com/stephpy/timeline/blob/d059ba3c2ffbefc2ec6d8ac68c7d6037b890b487/src/ResolveComponent/ValueObject/ResolveComponentModelIdentifier.php
->setParameter('hash', $resolvedComponentData->getHash())
->getQuery()
->getOneOrNullResult()
;
if ($component) {
$component->setData($resolvedComponentData->getData());
return $component;
}
return $this->createComponentFromResolvedComponentData($resolvedComponentData, $flush);
}
shouze commented
closed by stephpy/timeline#49 & #213