perf(permissions): drop duplicate role query; index message list #100
No reviewers
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!100
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/86-perm-queries-index"
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?
Summary
Fixes #86 — two independent perf wins in the permission/message hot path.
1. Duplicate role query
effective_permissionscalledcompute_base_permissions(which already runslist_member_roles) and then ranlist_member_rolesa second time just to get role ids for channel-override matching. Every message send/list/reaction paid two identical role queries plus theeveryonefetch.compute_base_permissionsnow also returns the member role ids;effective_permissionsreuses them. One role query instead of two.2. Missing message index
The channel list query filters on
(channel_id, thread_id IS NULL)and paginates byid(ORDER BY id DESC,id < ?). The only prior index was(channel_id, created_at), covering neither — SQLite filtered then sorted. Migration011addsidx_messages_channel_thread_id (channel_id, thread_id, id).EXPLAIN QUERY PLANconfirms the paginated query now doesSEARCH messages USING INDEX idx_messages_channel_thread_idinstead of a scan+sort.Tests
member_role_channel_override_is_applied: a channel override targeting a non-everyonerole the user holds still denies correctly — exercises the reused role-id path.channel_override_can_deny_sending_messages(everyone path) still passes.Full server suite green (116 tests);
clippy -D warningsclean.Closes #86