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

Slow DB Query for deleting the previous magic links #120

Closed
Eliotboutet opened this issue Dec 17, 2024 · 1 comment · Fixed by #122
Closed

Slow DB Query for deleting the previous magic links #120

Eliotboutet opened this issue Dec 17, 2024 · 1 comment · Fixed by #122

Comments

@Eliotboutet
Copy link

Eliotboutet commented Dec 17, 2024

Hello, I'm facing an issue :
When you create a new magic link, there is a query in order to delete all expired magic links (static::deleteMagicLinkExpired();)

However, I experience some really bad performances on this query in production. Is it because I don't set any expiration date on the magic links ? I also noticed that there is no index present at the migrations level. There should be index optimization on the magic links table level.

Did anyone face this issue aswell ?
Thank you

@cesargb
Copy link
Owner

cesargb commented Dec 25, 2024

Hello!

The aim of this method is to keep the table clean, although it may not have been a good idea to allow a magiclink to be generated without expiration, as this may cause it to never get cleaned.

I have tested 400,000 records, obtaining a latency of 500-600ms to perform this action. By generating the indices for the available_at and max_visits columns this time improves to 10-20ms.

As a first step I think it is important to create these 2 indexes.

And a second measure is to not allow to generate magiclink without expiration date or at least that this parameter is configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants