Hi, All,

I have a question about ForeignKey in Django. Say, I have a model like
this,

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class test(models.Model):
         no=models.CharField(_('No.'),max_length=6,.....)
         nat=models.ForeignKey(Code,verbose_name=_
('Nationality'),related_name='b_nat',
                                            limit_choices_to=
{'cat':'1','status':'Y'})

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Say, there are 3,000 records in postgreql database. When I try to list
all objects in one page, the sql queries will be pretty high, like
more than 3000 times queries in backend.

Then, I just installed debug-toolbar, and try to find the reason of
why so many sql queries executed in backend. Finally, I found that
each record will trigger another sql query if there is a ForeignKey
field.  Because of this reason, my django application is really slow
on showing large records in one page, is this a performance issue in
Django and Postgresql?

Does every body know this issue and know how to solve it? Your any
suggestion or solution will be highly appreciated!

Regards,

Zeal


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to