Michael Radziej wrote: > DavidA: > > > > DavidA wrote: > >> I have some models that look like this > >> > >> class Analyst(models.Model): > >> name = models.CharField(maxlength=20, unique=True) > >> > >> class Strategy(models.Model): > >> name = models.CharField(maxlength=20) > >> description = models.CharField(maxlength=80) > >> > >> class Inst(models.Model): > >> strategy = models.ForeignKey('Strategy', blank=True, null=True) > >> analyst1 = models.ForeignKey('Analyst', related_name='analyst1', > >> blank=True, null=True) > >> analyst2 = models.ForeignKey('Analyst', related_name='analyst2', > >> blank=True, null=True) > >> analyst3 = models.ForeignKey('Analyst', related_name='analyst3', > >> blank=True, null=True) > >> > >> class Position(models.Model): > >> date = models.DateField(db_index=True) > >> inst = models.ForeignKey(Inst) > >> quantity = fields.NumberField() > > [...] > > Neither table (Analyst or Strategy) is being cached - both expressions > > result > > in 20 separate select queries but its going back to the DB for the same > > ID many times. That still seems like a problem to me. > > select_related does not read in the tables that are related with > null=True, like in your case. I don't know the reason for it, > though. Would like to know, too ;-) > > Michael
Thanks, that explains it. I would guess that the reason they aren't joined in is because it uses inner joins and you'd drop rows. I wonder if you could just use an outer join for null FKs or if its more complicated than that. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---