Re: ForeignKey efficiency question

2010-01-07 Thread apramanik
Thanks! On Jan 7, 2:19 am, Daniel Roseman wrote: > On Jan 7, 5:07 am, apramanik wrote: > > > > > Oops not a join, but still a db hit :). > > > On Jan 6, 9:03 pm, apramanik wrote: > > > > Hey all, if I have a foreign key on a model (say Model B has a foreign > > > key to Model A) and I do someth

Re: ForeignKey efficiency question

2010-01-07 Thread Daniel Roseman
On Jan 7, 5:07 am, apramanik wrote: > Oops not a join, but still a db hit :). > > On Jan 6, 9:03 pm, apramanik wrote: > > > Hey all, if I have a foreign key on a model (say Model B has a foreign > > key to Model A) and I do something like this: > > > a = A.objects.get( pk = 1 ) > > b = B.objects.

Re: ForeignKey efficiency question

2010-01-06 Thread apramanik
Oops not a join, but still a db hit :). On Jan 6, 9:03 pm, apramanik wrote: > Hey all, if I have a foreign key on a model (say Model B has a foreign > key to Model A) and I do something like this: > > a = A.objects.get( pk = 1 ) > b = B.objects.get( pk = 1 ) > > if b.a == a : >     # Do something

ForeignKey efficiency question

2010-01-06 Thread apramanik
Hey all, if I have a foreign key on a model (say Model B has a foreign key to Model A) and I do something like this: a = A.objects.get( pk = 1 ) b = B.objects.get( pk = 1 ) if b.a == a : # Do something Is that inefficient, since its doing a join to pull b.a? Should I be comparing their ids?