When creating a one to one table or a table with a compound key..
Django wants to create an index for the PK/alternate key and also
another index on the same column(s) because it's a FK. For example, if
I have:

class League(models.Model):
    name                    = models.CharField(max_length=50)

class Season(models.Model):
    name                    = models.CharField(max_length=50)

class LeagueSeason(models.Model):
    league                  = models.ForeignKey(League)
    season                  = models.ForeignKey(Season)

In LeagueSeason it will create the PK index on league + season (which
is correct), but then it will create an index on league and another on
season. The one on season should be created, but the one on league
should NOT be created since the PK index can be used. One to ones are
a simpler example and the 2nd index should never be created.

Better index on auth_user?
auth_user.username might as well have username and password in the
index since you usually query both and if you only query one, that's
ok, the index will still work. Since the typical use case for that is
login via username/pw, you never have to hit the table can just use
the index to pull the password. Saves an extra read to the database.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to