[perms] Refactor graph updates to remove costly N+1 query#73694
Open
bshepherdson wants to merge 1 commit intomastermetabase/metabase:masterfrom
perms-slow-graph-update-fix-N-plus-1smetabase/metabase:perms-slow-graph-update-fix-N-plus-1sCopy head branch name to clipboard
Open
[perms] Refactor graph updates to remove costly N+1 query#73694bshepherdson wants to merge 1 commit intomastermetabase/metabase:masterfrom perms-slow-graph-update-fix-N-plus-1smetabase/metabase:perms-slow-graph-update-fix-N-plus-1sCopy head branch name to clipboard
bshepherdson wants to merge 1 commit intomastermetabase/metabase:masterfrom
perms-slow-graph-update-fix-N-plus-1smetabase/metabase:perms-slow-graph-update-fix-N-plus-1sCopy head branch name to clipboard
Conversation
Fixes UXW-3902. The original architecture for updating the permissions resulted in `O(schemas * groups * perm_types)` `SELECT` queries and similarly for `DELETE` and `INSERT` queries to update them. This made graph updates extremely slow, where "slow" means that we have observed them taking 30+ minutes. The new approach uses 3 or 4 queries no matter how many permissions are being updated.
Contributor
e2e tests failed on
|
| File | Test Name |
|---|---|
metrics-explorer.cy.spec.ts |
scenarios > metrics > explorer > Adding metrics and measures > should add metrics and measures from the entity picker |
model-actions.cy.spec.js |
Write actions on model detail page (postgres) > should respect impersonated permission |
source-replacement.cy.spec.ts |
scenarios > data-studio > source replacement > Native queries > replaces a table referenced in a native SQL question |
metrics-explorer.cy.spec.ts |
scenarios > metrics > explorer > Expression custom names > should preserve custom name when re-running with the same expression |
dashboard-questions.cy.spec.js |
Dashboard > Dashboard Questions > admin > notifies the user about dashboards and dashcard series that a question will be removed from |
metrics-explorer.cy.spec.ts |
scenarios > metrics > explorer > Drill through > should allow me to do brush style time range filtering |
dependency-unreferenced-list.cy.spec.ts |
scenarios > dependencies > unreferenced list > analysis > should not show referenced entities |
metrics-explorer.cy.spec.ts |
scenarios > metrics > explorer > metric math > should handle metrics with numeric names in expressions |
data-studio-bulk-table.cy.spec.ts |
bulk table operations > syncing multiple tables |
data-studio-bulk-table.cy.spec.ts |
bulk table operations > allows publishing and unpublishing multiple tables |
| and more... | and more... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes UXW-3902.
Description
The original architecture for updating the permissions resulted in
O(schemas * groups * perm_types)SELECTqueries and similarly forDELETEandINSERTqueries to update them. This made graph updatesextremely slow, where "slow" means that we have observed them taking 30+
minutes.
The new approach uses 3 or 4 queries no matter how many permissions are
being updated.
How to verify
Should be no behavioural changes, so check that permissions updates still work as before.
I'm preparing a perf test with the 180 groups touching 60k tables in 10k schemas that the
reporting user has, to make sure it fixes that.
Checklist
If adding new Loki tests: they pass stress testing