I have three tables:
Tag (entity) > tags_articles (pivot) < articles (entity)
Entity "article" has method "addTag(tag)"
If I need to add tags to article I do foreach loop:
foreach ($tags as $tag) {
$article->add($tag)
}
$this->em->flush()
Sometimes in that loop I need to add over 5000 tags. So all that script takes quite long, around 25s.
Is there any way to speed up that inserts to pivot table?
Thank you.