hilobok/doctrine-extensions-taggable — pull request #3 by rvanlaarhoven (2014-03-28 14:36:48+00:00)
Title: Reduce amount of queries

When listing some rows of a taggable entity, which should also contain its related tags, it creates way more queries then necessary.

It first queries all entity rows. Then, for each row, it queries the related Tagging rows. When the entity has tags, it queries the Tag rows related to the Tagging rows.

I think there should be a way to somehow join the Tagging & Tag tables to the taggable entity. The commit already reduces the part between Tagging & Tag, but I haven't been able to create a solution between the Entity & Tagging tables yet. The problem I encountered was the fact that there's no hard relation between the entity and the Tagging table, which makes it hard to do joins.

I was thinking about creating an abstract TaggableRepository, which has something like findWithTags() method. Then, the each taggable entity's repository could extend from this repository.

Any suggestions?