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')]
Django's ORM seems to create *two* indexes automatically:
CREATE INDEX "myapp_item_group_id" ON "myapp_item" ("group_id");
CREATE INDEX "myapp_item_group_id_like" ON "myapp_item" ("group_id"
varchar_pattern_ops);
Two!? Is this really necessary? My understanding is that one usually
wants an index on the *referenced* field, not the *referencing*
field. In my case the referenced field is indexed implicitly by the
db, since it is already a primary key. I am looking for ways to
improve insert performance on the referencing table, and my
unique_together constraint already implies all the index I need on
this table. Is there any reason why I shouldn't drop the indexes
django creates for me?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.