perf: Add composite index on dependencies(depends_on_id, type)
The hierarchical blocking query recursively joins on dependencies with a type filter. Without a composite index, SQLite must scan all dependencies for a given depends_on_id and filter by type afterward. With 10k+ issues and many dependencies per issue, this could cause noticeable slowdowns in ready work calculations. Changes: - Added idx_dependencies_depends_on_type composite index to schema - Added automatic migration for existing databases - Index creation is silent and requires no user intervention The recursive CTE now efficiently seeks (depends_on_id, type) pairs directly instead of post-filtering. Resolves: bd-59 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,7 @@ CREATE TABLE IF NOT EXISTS dependencies (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_dependencies_issue ON dependencies(issue_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_dependencies_depends_on ON dependencies(depends_on_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_dependencies_depends_on_type ON dependencies(depends_on_id, type);
|
||||
|
||||
-- Labels table
|
||||
CREATE TABLE IF NOT EXISTS labels (
|
||||
|
||||
Reference in New Issue
Block a user