Skip to main content

max / makenotwork

816 B · 21 lines History Blame Raw
1 -- Performance indexes for hot query paths identified in Run 15 audit.
2
3 -- Suspension check (called on every authenticated write request)
4 CREATE INDEX IF NOT EXISTS idx_users_suspended
5 ON users(suspended_at) WHERE suspended_at IS NOT NULL;
6
7 -- Per-user rate limiting (called on every post/footnote creation)
8 CREATE INDEX IF NOT EXISTS idx_posts_author_created
9 ON posts(author_id, created_at);
10
11 CREATE INDEX IF NOT EXISTS idx_post_footnotes_author_created
12 ON post_footnotes(author_id, created_at);
13
14 -- Image upload rate limiting
15 CREATE INDEX IF NOT EXISTS idx_images_uploader_created
16 ON images(uploader_id, created_at);
17
18 -- Ban/mute type filtering (existing index lacks ban_type column)
19 CREATE INDEX IF NOT EXISTS idx_community_bans_type_lookup
20 ON community_bans(community_id, user_id, ban_type);
21