Skip to content

Redundant index on AccessAttempt.username #1436

Description

@GougeGouge

I was doing some Index analysis on my Platform and noticed AccessAttempt has a redundant index on username as already covered by unique_together = ("username", "ip_address", "user_agent").

I know it's pretty much nothing and probably micro-optimization but if you want i can create a PR fix it.

Mainly consist on adding:

username = models.CharField(_("Username"), max_length=255, null=True)`

to the model AccessAttempt to overide username without db_index=True.

Migration generated by this fix

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("axes", "0010_accessattemptexpiration"),
    ]

    operations = [
        migrations.AlterField(
            model_name="accessattempt",
            name="username",
            field=models.CharField(max_length=255, null=True, verbose_name="Username"),
        ),
    ]

NB: I use PostgreSQL and don't have the knowledge on other Database behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions