I need to show a list of users (around 400). No problem, the list loads in 1.5s, for which I could use {% cache %}
to speed it up.
Now, the problem arises whenever I want to display the title of an entry related to the user. The log shows 400 extra queries, so a query per user, if I do this:
{% for user in user %}
{{ user.relationFieldName.first() }}
{% endfor %}
This seems a bit faster, but not fast:
{% for user in user %}
{{ user.relationFieldName.find()[0] }}
{% endfor %}
Is there a way to get this information directly when querying for users? Or is there another way to speed this up?
Would eager loading these relations through a plugin help? And if so, what service/model/record would I have to extend to go about this?