Perf: Redundant permission queries + missing message index #86
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom#86
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Category: Performance — found in code review 2026-07-07.
Problem
server/src/permissions.rs:158(effective_permissions) callscompute_base_permissions(which already runslist_member_roles) and then callslist_member_rolesagain at:173, plus fetches theeveryonerole every call. Every message send/list/reaction pays 2×list_member_roles+ aget_role("everyone").list_messagesorders byid DESC(ULID = chronological) but the only index isidx_messages_channel_created (channel_id, created_at)— it doesn't cover ordering byidor thethread_id IS NULLfilter, so SQLite filters then sorts.Fix
compute_base_permissionsreturn the role list soeffective_permissionsreuses it; cache theeveryonerole.(channel_id, thread_id, id)so the paginated scan is index-ordered.