Intermediary Models in admin
Hey guys !
I'm trying to implement a any to many relationship with Intermediary
Models.
I've been following https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#working-with-many-to-many-intermediary-models
And I have almost the same code except for names.
The problem : that's crazy slow.
My table Group has 100 rows
My table Person has like 100 0000 rows
So, If I go to a Person, there is no problem to see his groups.
But if from a group I want to see all the persons that's not possible.
(page load never end)
I had a look at the queries the admin generates. And I was a bit
surprised.
First it's selecting my group (eg:select * from group where is =1)
Second it's selecting all my Persons and join it to membership giving
my group id (eg:select person.* from person JOIN membership ON
membership.person = person.id WHERE group = id)
Third it's select all my memberships for my group (eg:SELECT * from
membership WHERE group = id)
Until here I guess it's fine.
Finally it is selecting all my persons (eg : select * from person) :s
And it is not doing only one time..... like 100 times
So I'm a bit lost, is it the normal behavior ? if yes, is there a
better way to do what i want to do ?
Thanks
V
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home