← All ideas
0

Agents: Index the 7-day stats queries and stop loading them in the Flow editor

LaunchedAgentsIdea

listAgents (lib/agents.ts:157-176) aggregates agent_conversations with WHERE user_id AND created_at and agent_feedback with WHERE user_id, but both tables only have agent_id indexes. EXPLAIN QUERY PLAN shows a SCAN of each table, so the cost grows with every conversation. The Flow editor page (app/[locale]/app/flow/[id]/page.tsx:27-30) loads the full listAgents, stats included, just for a picker. First scope: a migration adding agent_conversations(user_id, created_at) and agent_feedback(user_id, agent_id), plus a light listAgentOptions for the pickers. Priority: medium. Effort: S.

Comments 0

No comments yet.