Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(experiments): add sortable Read column to slowest queries (#66982)

Juraj Majerike4a617746895
diff --git a/frontend/src/scenes/instance/QueryPerformance/QueryPerformance.tsx b/frontend/src/scenes/instance/QueryPerformance/QueryPerformance.tsx
index 350ef25b1b3d..0f5bf76340f9 100644
--- a/frontend/src/scenes/instance/QueryPerformance/QueryPerformance.tsx
+++ b/frontend/src/scenes/instance/QueryPerformance/QueryPerformance.tsx
@@ -44,6 +44,11 @@ const METRIC_TYPE_OPTIONS = [
{ value: 'retention', label: 'Retention' },
]
+// Group total = the read plus its precompute-build sub-queries (the user paid for all of them),
+// mirroring how the Duration column sums total_duration_ms over the group.
+const groupBytes = (item: SlowestQuery): number =>
+ item.read_bytes + item.sub_queries.reduce((sum, q) => sum + q.read_bytes, 0)
+
function QueryStats({
read_bytes,
read_rows,
@@ -192,6 +197,23 @@ export function QueryPerformance(): JSX.Element {
)
},
},
+ {
+ title: 'Read',
+ width: 130,
+ sorter: (a, b) => groupBytes(a) - groupBytes(b),
+ render: function Read(_, item): JSX.Element {
+ const total = groupBytes(item)
+ const hasSubQueries = item.sub_queries && item.sub_queries.length > 0
+ return (
+ <div className="font-mono">
+ <span>{humanizeBytes(total)}</span>
+ {hasSubQueries && (
+ <span className="text-muted text-xs"> · read {humanizeBytes(item.read_bytes)}</span>
+ )}
+ </div>
+ )
+ },
+ },
{
title: 'Organization',
render: function OrgCell(_, item) {