Commit 7fbf8e1
authored
perf(dotcom): add groupId indexes on group_user and group_file (tldraw#8612)
In order to speed up the `groupUsers` synced query, this PR adds indexes
on `groupId` for the `group_user` and `group_file` tables. The composite
primary keys on these tables start with `userId`/`fileId`, so filtering
by `groupId` alone falls back to full-table scans — visible in the Zero
Cache SQLite plans as `SCAN group_user USING INDEX group_user_pkey` and
`SCAN group_file USING INDEX group_file_pkey`. The new indexes let Zero
replicate them to the replica and use proper index searches.
### Change type
- [x] `improvement`
### Test plan
1. Run the migration against a dev database.
2. Open a user session that has group memberships and file associations.
3. Inspect the `groupUsers` query's `sqlitePlans` — the `group_user` and
`group_file` entries should show `SEARCH … USING INDEX` instead of `SCAN
… USING INDEX *_pkey`.
### Release notes
- Internal: add `groupId` indexes to `group_user` and `group_file` for
faster `groupUsers` sync queries.1 parent 3810d2a commit 7fbf8e1
1 file changed
Lines changed: 2 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments