From 6efbb61afc3283e30b1dc8f02f432a3ad0271ac6 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 13 Oct 2026 08:49:37 +0530 Subject: [PATCH] Indexes on papers.share_token and mistake_tags.attempt_id Both are per-request lookups (shared-paper view, result tags, dashboard rollup) that full-scanned. Zero warnings, 25 tests green. --- src/db.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/db.rs b/src/db.rs index 1e9d032..b5d2e45 100644 --- a/src/db.rs +++ b/src/db.rs @@ -22,7 +22,9 @@ pub async fn init_db(pool: &SqlitePool) -> anyhow::Result<()> { CREATE INDEX IF NOT EXISTS idx_papers_user ON papers(user_id); CREATE INDEX IF NOT EXISTS idx_attempts_paper ON attempts(paper_id); CREATE INDEX IF NOT EXISTS idx_attempts_user ON attempts(user_id); - CREATE INDEX IF NOT EXISTS idx_answers_attempt ON answers(attempt_id);", + CREATE INDEX IF NOT EXISTS idx_answers_attempt ON answers(attempt_id); + CREATE INDEX IF NOT EXISTS idx_papers_token ON papers(share_token); + CREATE INDEX IF NOT EXISTS idx_mistakes_attempt ON mistake_tags(attempt_id);", ) .execute(pool) .await?;