Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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#73694
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

@bshepherdson
Copy link
Copy Markdown
Contributor

@bshepherdson bshepherdson commented May 5, 2026

closes #73249

Fixes UXW-3902.

Description

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.

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

  • Tests have been added/updated to cover changes in this PR
  • If adding new Loki tests: they pass stress testing

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.
Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@metabase-bot metabase-bot Bot added the .Team/QueryingPlatform Platform subteam for .Team/Querying. Please use in conjunction with .Team/Querying label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

e2e tests failed on 09b509993db7609c8c6ebfe7ffa7d1f346cbbd14-1

e2e test run

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...

@eliotmetabase eliotmetabase requested a review from johnswanson May 5, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.Team/QueryingPlatform Platform subteam for .Team/Querying. Please use in conjunction with .Team/Querying

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permissions Update Fails with Cluster Lock Error

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.