Sunday, February 27, 2011

Re: How to reduce DB queries?

Actually, select_related won't help You with m2m fields. As it's written in docs linked by s.apostolico, it only works with ForeignKeys...

As far as I know, there's no way to avoid the extra query using django's orm.

2011/2/27 galago <progreo@gmail.com>
In template in main loop I want to display all technologies assigned to the each site. Technologies are assigned by m2m relation. So I run subloop as You can see in code above. I want to reduce the number of queries executed by those subqueries. I want to know, if there is a better way to do this.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment