Skip to content

N+1 Query issue on endpoints using APIKey permission class #274

@birddevelper

Description

@birddevelper

Describe the bug
N+1 problem occurs on calling endpoints that uses the api key as permission class.

To Reproduce
Steps to reproduce the behavior:

  1. Create a class inherited BaseHasAPIKey
  2. Set the permission_classes of a APIView to class created instep 1.
  3. Call the endpoint
  4. If you have profiling, or sentry enabled in project you can see the N+1 issue occurred.

Expected behavior
At most one select and one update query supposed to be executed.

Screenshots
Image

Server:

  • OS: Linux
  • Python Version: [e.g. 3.13]
  • Django Version: [e.g. 5.2.1]
  • DRF Version: 3.16.0
  • djangorestframework-api-key: 3.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions