[Artifacts] Build artifact gallery page at /artifacts

← All Specs

[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 stats
  • Solution

  • 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 TTL
  • Work Log

    • 2026-04-03: Started — identified performance bottlenecks causing /artifacts timeout

    File: ee3d1bac_artifacts_gallery_spec.md
    Modified: 2026-05-01 20:13
    Size: 1.0 KB