Re: Automatic indexes on foreign keys

2012-04-21 Thread Ramiro Morales
On Sun, Mar 25, 2012 at 9:30 AM, Aryeh Leib Taurog wrote: > > On Mar 23, 3:56 pm, Javier Guerra Giraldez wrote: > > On Fri, Mar 23, 2012 at 4:37 AM, Aryeh Leib Taurog > > wrote: > > > > > My understanding is that one usually > > > wants an index on the *referenced* field, not the *referencing* >

Re: Automatic indexes on foreign keys

2012-03-25 Thread Aryeh Leib Taurog
On Mar 23, 3:56 pm, Javier Guerra Giraldez wrote: > On Fri, Mar 23, 2012 at 4:37 AM, Aryeh Leib Taurog wrote: > > > My understanding is that one usually > > wants an index on the *referenced* field, not the *referencing* > > field. > > it's for the back-reference link.  so that you can do > group

Re: Automatic indexes on foreign keys

2012-03-23 Thread Javier Guerra Giraldez
On Fri, Mar 23, 2012 at 4:37 AM, Aryeh Leib Taurog wrote: > My understanding is that one usually > wants an index on the *referenced* field, not the *referencing* > field. it's for the back-reference link. so that you can do group.item_set.all() and get all the items that share a group. yes, th

Automatic indexes on foreign keys

2012-03-23 Thread Aryeh Leib Taurog
With the following models: class Group(models.Model): group_name = models.CharField(max_length=10, primary_key=True) class Item(models.Model): item_name = models.CharField(max_length=10) group = models.ForeignKey(Group) class Meta: unique_together = [('item_name','group')]