Skip to content

Improve performance of tokenRequired middleware #127

@ThisIsMissEm

Description

@ThisIsMissEm

We may also be able to get a performance improvement for Hollo as a whole by limiting the amount of data we query back from the database on each request. The query in tokenRequired middleware to set c.get("token") returns back a tonne of data that's probably unnecessary

like, we probably only need to pull back the accountOwnerId, accountId and applicationId — then if we need the full records, we just query for the record for that id.

At the moment we pull back all this data on every request that has tokenRequired:

Image

the query plan for that query is complex:

Image

we could probably swap it out with a simpler query, but hit the database more often for some things:

Image

The simpler query doesn't include any of the relationships:

select "accessTokens"."code", "accessTokens"."application_id", "accessTokens"."account_owner_id", "accessTokens"."grant_type", "accessTokens"."scopes", "accessTokens"."created" from "access_tokens" where "accessTokens"."code" = '49yHfVlcAMcJpmmJo314NQ' limit 1;

Maybe we'd want to do a join between account_owner_id and the accounts table, idk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions