On Thu, Jul 7, 2011 at 3:49 PM, DrBloodmoney <drbloodmo...@gmail.com> wrote:
> On Thu, Jul 7, 2011 at 12:04 AM, Venkatraman S <venka...@gmail.com> wrote: > > I am doing some bechmarking on the performance of both the versions of > the > > query: > > 1. > > > Item.objects.filter(created_by__employees__org__in=u.employees_set.all().values_list('org')) > > and > > 2. Items.objects.extra(where=['created_by_id in (select e.user_id from > > myapp_employees e, myapp_organization o where e.org_id = o.id and o.id = > > (select o2.id from myapp_organization o2, myapp_employees e2 where > e2.org_id > > = o2.id and e2.user_id=3 and e2.deleted=False)) ']) > > > > I am seeing #1 to be faster(when i view from DDT). Will update in the > next > > few days or probably early next week. > > > > -V > > Personally, I'd add a FK on the Item to the Employee, particularly if > they're in the same app (Actually I'd replace the FK to User with one > to Employee). I suspect that is a simplified models.py so I don't > actually know if there would be a requirement to FK to User. (I also > try to limit my code touching django.contrib.auth since using it is my > biggest pain point for django). > > Cant actually, as the Item can be created by both employees, and 'outsiders'. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.