-
-
Notifications
You must be signed in to change notification settings - Fork 965
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
chore: add index to improve DB cleanup job performance #3434
base: master
Are you sure you want to change the base?
chore: add index to improve DB cleanup job performance #3434
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3434 +/- ##
=======================================
Coverage 78.02% 78.02%
=======================================
Files 327 327
Lines 21402 21402
=======================================
Hits 16698 16698
Misses 3466 3466
Partials 1238 1238
|
Thank you david! This makes a lot of sense. I think it would be good to add this column to one of the existing indices (I think there are some already that cover |
Hey @aeneasr 👋 Thanks for the answer.
meaning that the |
The Kratos cleanup job does a query looking like
The query plan of the SELECT-subquery looks like this (on PostgreSQL):
which does a sequential scan on the table.
This PR adds the index
which results in this query plan:
Doing an Index Scan instead of the sequential one.
➡️ We created this index manually on our Kratos DB in order to optimize the Kratos cleanup process, which works very well for us.
💡 An alternative can be to create this index containing all columns:
then the query plan looks like:
Which does an Index Only Scan, no data loaded from the table itself.
For us, it was not worth it, but maybe that's more in the vein of something you'd like to skip to all Kratos customers :)
Let me know what you think of this PR!
Related issue(s)
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments