-
Notifications
You must be signed in to change notification settings - Fork 30
♻️🚨 Improve DB query listing_projects
performance (🗃️)
#7475
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 DB query listing_projects
performance (🗃️)
#7475
Conversation
listing_projects
performancelisting_projects
performance (🗃️)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7475 +/- ##
==========================================
+ Coverage 87.40% 89.16% +1.76%
==========================================
Files 1737 1473 -264
Lines 67032 58116 -8916
Branches 1138 541 -597
==========================================
- Hits 58589 51820 -6769
+ Misses 8122 6146 -1976
+ Partials 321 150 -171
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
...stgres-database/src/simcore_postgres_database/migration/versions/aa2c85e8a66a_add_indexes.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_projects_repository_legacy.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_projects_repository_legacy.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_projects_repository_legacy.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice!
Thanks, how much faster does it get?
...stgres-database/src/simcore_postgres_database/migration/versions/aa2c85e8a66a_add_indexes.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_projects_repository_legacy.py
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/projects/_projects_repository_legacy.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, did you manage to test this on the production dataset to see if we actually get a boost in speed?
Tested in staging ... I expect 10x speedup |
based on my experiments in staging 10x speedup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work ! 🎉 thx!
|
listing_projects
performance (🗃️)listing_projects
performance (🗃️)
993864d
into
ITISFoundation:master
What do these changes do?
listing_projects
database query (🗃️)EXPLAIN ANALYZE
to analyze query performance. By adding indexes and refactoring the SQL query, many sequential scans were eliminated.What was improved?
WHERE
clause foruser_groups
inmy_access_rights_subquery
→ Previously, it aggregated allproject_to_groups
data. With this change, user access rights are now determined through a join, eliminating the need to compare strings within a JSON array..lateral()
toaccess_rights_subquery
→ This helps the database engine avoid pre-aggregating all data inproject_to_groups
, processing only the projects that were already filtered (which, with an offset + limit combination, is usually just around 10 projects).FILTER
with aWHERE
clause → TheFILTER
condition prevented index scans from being used.projects_tags
join → Tags are retrieved separately for each project later, making the join unnecessary at this stage.What can still be improved?
projects_to_products
table and integrate its data into theprojects
table.🚨 Double check user project permissions 🚨
Related issue/s
How to test
Dev-ops checklist