Skip to content

cleartokens management command could have some performance improvements #651

@jarussi-luizalabs

Description

@jarussi-luizalabs

I'm using the cleartokens command to clear the expired tokens from my MySQL database and try to improve performance. However, we got to a point where we have a lot of tokens in our database (~300 MM) because of a bug in another application.

The command no longer workers because the delete() method from Django tries to load the entire object list to the python memory. The task will make the machine CPU goes to 100% and won't be able to delete anything.

I think we should have some alternatives to clear the tokens. Maybe some kind of pagination so it would delete X tokens at a time or maybe using the _raw_delete() method from Django ORM.

Is that an acceptable resolution for the problem? I can try and work in a PR to address this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions