perf(snapshot): optimize snapshot listing#202
Merged
XuPeng-SH merged 1 commit intoMay 21, 2026
Conversation
XuPeng-SH
approved these changes
May 21, 2026
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.
What type of PR is this?
Which issue(s) this PR fixes
Fixes matrixorigin/memoria-website#132
What this PR does / why we need it
Root cause
/v1/snapshotscalledSHOW SNAPSHOTSwithout a predicate. On a cluster with many users, MatrixOne returned every visible snapshot first, and Memoria filtered the current user's database in Rust. With 10K snapshots this made snapshot listing spend seconds inSHOW SNAPSHOTSeven when the current user only had 50 snapshots.Changes
SHOW SNAPSHOTS WHERE DATABASE_NAME = '<user db>'.SHOW ... WHERErewrite.mem_snapshots.extraJSON instead of adding a narrowmemory_countcolumn.extra.memory_countwhen creating snapshots.extra.memory_countfor old snapshot registrations on read, while still returning a concretememory_countin/v1/snapshots.Compatibility
mem_snapshots.extra JSONcolumn migration when accessed.extra.memory_countare read-through backfilled for returned snapshots only.extracolumn in the initialmem_snapshotsschema.Validation
SQLX_OFFLINE=true cargo check -p memoria-storage -p memoria-git -p memoria-mcp -p memoria-api/v1/snapshotsrequests succeeded.SHOW SNAPSHOTSrows per request dropped from 10004 to 50.SHOW SNAPSHOTSlatency improved from p50 1.67s / p95 4.35s / max 9.93s to p50 185ms / p95 376ms / max 421ms.