Files
multica/server/migrations/035_task_queue_issue_id_index.up.sql
Bohan Jiang 88982ad23f feat(issues): display token usage per issue in detail sidebar (#581)
* feat(issues): display token usage per issue in detail sidebar

Add a new "Token usage" section to the issue detail right sidebar that
shows aggregated input/output tokens, cache tokens, and run count across
all tasks for the issue. Backed by a new SQL query and API endpoint.

* fix(db): add index on agent_task_queue(issue_id) for usage queries

The GetIssueUsageSummary query joins agent_task_queue filtered by
issue_id across all statuses. The existing partial index (migration 022)
only covers queued/dispatched rows, so completed tasks require a
sequential scan. Add a general index to prevent performance degradation
as task volume grows.
2026-04-10 14:34:32 +08:00

6 lines
330 B
SQL

-- Add a general index on agent_task_queue(issue_id) to support aggregation
-- queries like GetIssueUsageSummary that scan across all task statuses.
-- (Migration 022 only covers queued/dispatched rows via a partial index.)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_agent_task_queue_issue_id
ON agent_task_queue (issue_id);