liuhao1024
9e2f07e704
perf(dashboard): use GROUP BY for session stats instead of fetching 10k rows
...
Replaces the O(N) list_sessions_rich histogram in /api/sessions/stats
with a single GROUP BY query, reducing response time from ~575ms to
<1ms on large databases.
Original PR #48921 by @liuhao1024. Salvage fixes based on review
feedback from teknium1 and @wernerhp:
1. Preserve try/except guard — a DB error still degrades to empty
by_source instead of failing the whole stats response.
2. GROUP BY COALESCE(source, 'cli') — the original GROUP BY source
could emit duplicate 'cli' keys (NULL group + literal 'cli' group)
that the dict comprehension silently dropped.
3. Add exclude_children=True — list_sessions_rich excludes subagent
runs, delegates, and compression continuations by default; the
bare GROUP BY counted all rows, inflating source counts.
Aggregate shape (exclude_children/include_archived/limit params)
adapted from closed duplicate #61120 by @mijanx.
Closes #48914
Co-authored-by: mijanx <mijanx@users.noreply.github.com >
2026-07-28 19:07:28 +05:30
..
2026-07-25 18:06:32 -07:00
2026-07-22 12:10:58 -05:00
2026-07-28 19:06:59 +05:30
2026-07-23 05:45:17 +00:00
2026-07-28 17:52:21 +05:30
2026-07-26 03:38:23 -05:00
2026-07-26 16:52:25 +10:00
2026-07-28 17:52:21 +05:30
2026-07-07 18:33:28 +10:00
2026-07-27 19:19:01 +05:30
2026-07-22 20:55:51 -07:00
2026-07-28 18:08:24 +05:30
2026-07-28 19:07:28 +05:30
2026-07-17 06:53:38 -07:00
2026-07-24 07:53:12 -07:00
2026-07-05 13:42:46 -07:00
2026-07-01 03:16:13 -07:00
2026-07-24 13:00:53 +05:30
2026-07-27 22:28:08 -04:00
2026-07-25 22:46:35 -07:00
2026-07-28 19:06:59 +05:30
2026-07-27 22:28:08 -04:00
2026-07-22 03:20:45 -07:00
2026-07-26 20:59:26 -07:00
2026-07-24 16:00:34 -07:00
2026-07-05 13:42:46 -07:00
2026-07-28 04:24:50 -05:00
2026-07-28 04:12:48 -05:00
2026-07-26 16:01:32 -07:00
2026-07-03 14:27:34 +10:00
2026-07-06 03:28:30 -07:00
2026-07-01 16:21:39 +05:30
2026-07-22 04:40:07 -07:00
2026-07-23 07:24:46 -07:00
2026-06-24 04:16:54 +05:30
2026-07-22 04:39:28 -07:00
2026-07-25 07:17:52 -07:00
2026-07-05 00:44:15 -07:00
2026-07-23 11:44:43 -07:00
2026-07-14 03:58:54 +05:30
2026-06-21 12:09:16 -07:00
2026-07-15 00:10:31 -07:00
2026-07-22 03:20:25 -07:00
2026-07-06 04:58:07 -07:00
2026-07-22 04:39:17 -07:00
2026-06-28 15:38:39 -07:00
2026-07-22 10:35:04 -07:00
2026-07-20 05:39:09 -07:00
2026-07-24 17:10:39 -07:00
2026-07-18 00:34:54 -04:00
2026-07-05 11:44:53 +05:30
2026-07-25 22:47:07 -07:00
2026-07-27 17:27:38 -07:00
2026-07-25 21:44:43 -07:00
2026-07-28 19:07:28 +05:30
2026-07-16 12:48:48 -07:00
2026-07-17 20:55:24 +00:00
2026-07-18 19:18:03 +05:30
2026-06-30 20:11:01 +07:00
2026-06-25 23:49:11 -07:00
2026-07-26 19:30:32 -07:00
2026-07-18 18:40:59 -04:00
2026-06-18 22:11:35 +05:30
2026-07-07 21:17:34 +07:00
2026-06-23 21:33:08 -07:00
2026-06-18 16:26:34 +07:00
2026-07-05 19:35:30 -07:00
2026-07-26 16:06:50 -05:00
2026-06-28 03:58:01 -07:00
2026-06-18 14:14:41 +10:00
2026-06-26 20:10:20 +05:30
2026-06-25 23:49:11 -07:00
2026-07-24 09:49:00 -07:00
2026-07-24 09:49:00 -07:00
2026-07-24 09:49:00 -07:00
2026-07-24 21:20:52 -05:00
2026-07-21 12:15:46 +05:30
2026-07-05 14:01:03 -07:00
2026-07-27 22:28:08 -04:00
2026-06-28 22:52:59 -07:00
2026-07-22 03:19:32 -07:00
2026-07-01 03:17:48 -07:00
2026-07-22 16:51:01 -04:00
2026-07-26 19:29:07 -07:00
2026-06-30 15:30:06 -07:00
2026-07-27 22:28:08 -04:00
2026-07-16 19:48:47 -04:00
2026-07-07 15:15:37 -07:00
2026-07-07 11:57:01 +05:30
2026-07-25 07:09:22 -07:00
2026-07-22 07:56:47 -07:00
2026-07-26 02:58:20 -05:00
2026-07-12 05:07:52 -04:00
2026-07-22 21:14:44 -07:00
2026-07-18 04:15:13 -07:00
2026-07-25 21:44:43 -07:00
2026-07-25 21:44:43 -07:00
2026-06-24 04:16:54 +05:30
2026-07-22 04:42:50 -07:00
2026-07-14 21:25:44 -07:00
2026-07-18 01:11:03 -07:00
2026-07-23 21:06:47 -07:00
2026-07-23 16:21:03 -07:00
2026-07-21 12:43:27 -07:00
2026-06-28 02:35:01 -07:00
2026-07-28 01:48:08 -05:00
2026-07-28 04:06:32 -05:00
2026-07-26 14:14:03 -07:00
2026-06-18 05:41:23 -07:00
2026-07-15 04:55:46 -07:00
2026-07-16 15:23:32 -04:00
2026-07-16 14:43:14 +02:00
2026-07-24 11:45:57 -07:00
2026-06-25 23:27:44 +05:30
2026-07-08 08:05:45 -07:00
2026-07-05 00:41:34 -07:00
2026-07-24 23:06:05 -07:00