[Artifacts] Build artifact gallery page at /artifacts
Task ID: ee3d1bac-f034-4182-85ac-f9ad791da9ad
Priority: 85
Layer: Artifacts
Problem
The /artifacts gallery page exists but times out due to slow correlated subqueries on 43K+ artifacts. The page needs performance optimization to be usable.
Root Cause
Correlated subquery (SELECT COUNT(*) FROM artifact_links WHERE source_artifact_id = a.id OR target_artifact_id = a.id) runs per-row
Missing indexes on artifact_links table for source/target lookups
json_each() entity exploration query scans full table
Multiple separate COUNT queries for statsSolution
Add indexes on artifact_links(source_artifact_id) and artifact_links(target_artifact_id)
Replace correlated subquery with LEFT JOIN aggregate
Add index on artifacts(artifact_type) for type filtering
Cache stats queries separately with longer TTLWork Log
- 2026-04-03: Started — identified performance bottlenecks causing /artifacts timeout