N+1 queries while creating the experiments collection.
Opened this issue · 4 comments
Thanks for the great package, Ben! I noticed N+1 queries:
Example: I created two experiments and two goals. If a user is visiting a page with an included a/b test the package fetches the experiment one, then separately the two goals. After that it fetches the second experiment and the two goals separately as well. Then, it is updating the visitors counter. So in the end 7 queries are performed.
The query problem is due to the nested foreach in the start()
method in the ABTesting class. The goals model should be eager loaded.
It would be great if you have a quick solution for the problem. Otherwise I will create a PR in the next weeks.
Hi Robin, thanks for your effort in making this package better. However, I can not confirm the N+1 problem by adding eager loading. In fact by adding eager loading, two additional queries will be executed. Can you confirm this behavior?
Should be fixed through 2.0.2 can somebody confirm?