{
  "threadId": "thr_v67duphyr7",
  "maxSeq": 44004,
  "totalMs": 342,
  "diskReadBytes": 99958784,
  "majorPageFaults": 813,
  "profile": {
    "compactedEventCount": 1599,
    "contextWindowEventDataBytes": 148,
    "contextWindowEventRowCount": 1,
    "decodedEventCount": 1599,
    "eventDataBytes": 1693701,
    "eventRowCount": 1599,
    "pageKind": "latest",
    "projectedRowCount": 82,
    "responseJsonBytes": null,
    "responseRowCount": 82,
    "returnedSegmentCount": 20,
    "segmentLimit": 20,
    "selectionStrategy": "standard-window",
    "stageTimings": [
      {
        "stage": "event-query",
        "ms": 266
      },
      {
        "stage": "accepted-client-request-context-query",
        "ms": 8.3
      },
      {
        "stage": "event-json-decode",
        "ms": 42.2
      },
      {
        "stage": "summary-compaction",
        "ms": 0.6
      },
      {
        "stage": "context-window-query",
        "ms": 0.7
      },
      {
        "stage": "context-window-json-decode",
        "ms": 0.4
      },
      {
        "stage": "thread-view-projection",
        "ms": 21.8
      },
      {
        "stage": "pagination-segmentation",
        "ms": 0.2
      }
    ],
    "totalDurationMs": 340.2
  }
}

10 statement executions, 10 distinct statements. Top by disk bytes:
    64896 KiB    191 ms  x  1  select "created_at", CASE WHEN length("data") <= ? THEN "data" ELSE json_replace("data", CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]') END, "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and (json_extract("events"."data", '$.parentToolCallId') in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
    28356 KiB     45 ms  x  1  SELECT "events"."created_at" AS "createdAt", "events"."data" AS "data", "events"."id" AS "id", "events"."item_id" AS "itemId", "events"."item_kind" AS "itemKind", "events"."provider_thread_id" AS "providerThreadId", "events"."scope_kind" AS "scopeKind", "events"."sequence" AS "sequence", "events"."thread_id" AS "threadId", "events"."turn_id" AS "turnId", "events"."type" AS "type" FROM "events" INDEXED BY events_todo_snapshot_idx WHERE "events"."thread_id" = ? AND "events"."type" IN ('item/started', 'item/completed') AND "events"."item_kind" = 'toolCall' AND json_extract("events"."data", '$.item.tool') IN ( 'TodoWrite', 'TaskCreate', 'TaskUpdate', 'TaskList', 'TaskGet' ) ORDER BY "events"."sequence"
     2268 KiB      4 ms  x  1  select "thread_id" || ':user-seed:' || "sequence", "sequence" from "events" where ("events"."thread_id" = ? and "events"."type" = ? and ( COALESCE(json_extract("events"."data", '$.target.kind'), 'new-turn') IN ('thread-start', 'new-turn') OR ( json_extract("events"."data", '$.target.kind') IN ('auto', 'steer') AND json_extract("events"."data", '$.target.expectedTurnId') IS NULL ) ) and EXISTS ( SELECT 1 FROM json_each("events"."data", '$.input') AS input_part WHERE ( json_extract(input_part.value, '$.type') = 'text' AND COALESCE(json_extract(input_part.value, '$.text'), '') <> '' ) OR json_extract(input_part.value, '$.type') IN ('image', 'localImage', 'localFile') )) order by "events"."sequence" desc limit ?
     1628 KiB      4 ms  x  1  select "sequence" from "events" where ("events"."thread_id" = ? and "events"."type" not in (?, ?, ?, ?, ?, ?)) order by "events"."sequence" desc limit ? offset ?
      124 KiB      0 ms  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."sequence" in (select max("sequence") from "events" "latest_open_background_task_state" where ("latest_open_background_task_state"."thread_id" = ? and "latest_open_background_task_state"."item_kind" = ? and "latest_open_background_task_state"."type" in (?, ?) and "latest_open_background_task_state"."item_id" is not null) group by "latest_open_background_task_state"."item_id") and json_extract("events"."data", '$.item.status') = 'pending' and "events"."item_id" not in (select "item_id" from "events" "completed_background_task_state" where ("completed_background_task_state"."thread_id" = ? and "completed_background_task_state"."type" = ? and "completed_background_task_state"."item_id" is not null)))
      112 KiB      0 ms  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where "events".rowid IN ( SELECT latest_goal.rowid FROM "events" AS latest_goal INDEXED BY events_goal_thread_sequence_idx WHERE latest_goal.thread_id IN (?) AND latest_goal.type IN ('thread/goal/updated', 'thread/goal/cleared') AND latest_goal.sequence = ( SELECT MAX(candidate.sequence) FROM "events" AS candidate INDEXED BY events_goal_thread_sequence_idx WHERE candidate.thread_id = latest_goal.thread_id AND candidate.type IN ('thread/goal/updated', 'thread/goal/cleared') ) )
        0 KiB      2 ms  x  1  select "created_at", CASE WHEN length("data") <= ? THEN "data" ELSE json_replace("data", CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]') END, "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."sequence" >= ? and "events"."type" not in (?, ?, ?, ?, ?, ?)) order by "events"."sequence"
        0 KiB      1 ms  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."type" = ? and "events"."turn_id" in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and "events"."sequence" <= ?) order by "events"."sequence"
        0 KiB      0 ms  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."type" = ? and NOT EXISTS ( SELECT 1 FROM events AS nested_turn_started WHERE nested_turn_started.thread_id = "events"."thread_id" AND nested_turn_started.turn_id = "events"."turn_id" AND nested_turn_started.type = 'turn/started' AND COALESCE(json_extract(nested_turn_started.data, '$.parentToolCallId'), '') <> '' )) order by "events"."sequence" desc limit ?
        0 KiB      0 ms  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."type" = ? and NOT EXISTS ( SELECT 1 FROM events AS nested_turn_started WHERE nested_turn_started.thread_id = "events"."thread_id" AND nested_turn_started.turn_id = "events"."turn_id" AND nested_turn_started.type = 'turn/started' AND COALESCE(json_extract(nested_turn_started.data, '$.parentToolCallId'), '') <> '' ) and json_extract("events"."data", ?) IS NOT NULL) order by "events"."sequence" desc limit ?

Top by time:
    191 ms    64896 KiB  x  1  select "created_at", CASE WHEN length("data") <= ? THEN "data" ELSE json_replace("data", CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]') END, "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and (json_extract("events"."data", '$.parentToolCallId') in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
     45 ms    28356 KiB  x  1  SELECT "events"."created_at" AS "createdAt", "events"."data" AS "data", "events"."id" AS "id", "events"."item_id" AS "itemId", "events"."item_kind" AS "itemKind", "events"."provider_thread_id" AS "providerThreadId", "events"."scope_kind" AS "scopeKind", "events"."sequence" AS "sequence", "events"."thread_id" AS "threadId", "events"."turn_id" AS "turnId", "events"."type" AS "type" FROM "events" INDEXED BY events_todo_snapshot_idx WHERE "events"."thread_id" = ? AND "events"."type" IN ('item/started', 'item/completed') AND "events"."item_kind" = 'toolCall' AND json_extract("events"."data", '$.item.tool') IN ( 'TodoWrite', 'TaskCreate', 'TaskUpdate', 'TaskList', 'TaskGet' ) ORDER BY "events"."sequence"
      4 ms     1628 KiB  x  1  select "sequence" from "events" where ("events"."thread_id" = ? and "events"."type" not in (?, ?, ?, ?, ?, ?)) order by "events"."sequence" desc limit ? offset ?
      4 ms     2268 KiB  x  1  select "thread_id" || ':user-seed:' || "sequence", "sequence" from "events" where ("events"."thread_id" = ? and "events"."type" = ? and ( COALESCE(json_extract("events"."data", '$.target.kind'), 'new-turn') IN ('thread-start', 'new-turn') OR ( json_extract("events"."data", '$.target.kind') IN ('auto', 'steer') AND json_extract("events"."data", '$.target.expectedTurnId') IS NULL ) ) and EXISTS ( SELECT 1 FROM json_each("events"."data", '$.input') AS input_part WHERE ( json_extract(input_part.value, '$.type') = 'text' AND COALESCE(json_extract(input_part.value, '$.text'), '') <> '' ) OR json_extract(input_part.value, '$.type') IN ('image', 'localImage', 'localFile') )) order by "events"."sequence" desc limit ?
      2 ms        0 KiB  x  1  select "created_at", CASE WHEN length("data") <= ? THEN "data" ELSE json_replace("data", CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]', CASE WHEN json_type("events"."data", ?) = 'text' AND length(json_extract("events"."data", ?)) > ? THEN ? ELSE ? END, substr(json_extract("events"."data", ?), 1, ?) || char(10) || '…[' || printf('%,d', length(json_extract("events"."data", ?)) - ?) || ' more characters truncated]') END, "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."sequence" >= ? and "events"."type" not in (?, ?, ?, ?, ?, ?)) order by "events"."sequence"
      1 ms        0 KiB  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."type" = ? and "events"."turn_id" in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and "events"."sequence" <= ?) order by "events"."sequence"
      0 ms      112 KiB  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where "events".rowid IN ( SELECT latest_goal.rowid FROM "events" AS latest_goal INDEXED BY events_goal_thread_sequence_idx WHERE latest_goal.thread_id IN (?) AND latest_goal.type IN ('thread/goal/updated', 'thread/goal/cleared') AND latest_goal.sequence = ( SELECT MAX(candidate.sequence) FROM "events" AS candidate INDEXED BY events_goal_thread_sequence_idx WHERE candidate.thread_id = latest_goal.thread_id AND candidate.type IN ('thread/goal/updated', 'thread/goal/cleared') ) )
      0 ms      124 KiB  x  1  select "created_at", "data", "id", "item_id", "item_kind", "provider_thread_id", "scope_kind", "sequence", "thread_id", "turn_id", "type" from "events" where ("events"."thread_id" = ? and "events"."sequence" in (select max("sequence") from "events" "latest_open_background_task_state" where ("latest_open_background_task_state"."thread_id" = ? and "latest_open_background_task_state"."item_kind" = ? and "latest_open_background_task_state"."type" in (?, ?) and "latest_open_background_task_state"."item_id" is not null) group by "latest_open_background_task_state"."item_id") and json_extract("events"."data", '$.item.status') = 'pending' and "events"."item_id" not in (select "item_id" from "events" "completed_background_task_state" where ("completed_background_task_state"."thread_id" = ? and "completed_background_task_state"."type" = ? and "completed_background_task_state"."item_id" is not null)))
