Missing orderBy parameter causes 20x slowdown in traces.metrics endpoint
criticalThe traces.metrics tRPC endpoint takes 20+ seconds to respond (versus under 1 second for traces.all) when orderBy parameter is not passed to getTracesTableGeneric. This forces ClickHouse to use FINAL operator on ReplacingMergeTree table, triggering full merge of all parts at query time instead of using the optimized LIMIT 1 BY deduplication. Affects self-hosted v3.155.1 and likely other versions.
Pass orderBy: { column: "timestamp", order: "DESC" } parameter in the traces.metrics call within web/src/server/api/routers/traces.ts. This enables the fast LIMIT 1 BY id, project_id deduplication path instead of expensive FINAL operator. Verify fix by comparing traces.metrics response time to traces.all in network tab after applying 24-hour timestamp filter.