Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of tokenRequired middleware #127

Open
ThisIsMissEm opened this issue Feb 24, 2025 · 0 comments
Open

Improve performance of tokenRequired middleware #127

ThisIsMissEm opened this issue Feb 24, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@ThisIsMissEm
Copy link
Contributor

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.

@dahlia dahlia added the enhancement New feature or request label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants