---
title: "Finding performance wins in our own traces with a coding agent"
description: "Pairing a coding agent with the Sentry MCP over Sentry's own production traces surfaced dozens of small backend fixes that together removed hundreds of millions of queries a week."
url: "https://swe.quest/articles/finding-performance-wins-in-our-own-traces-with-a-coding-agent-884170e809905d07"
canonical: "https://blog.sentry.io/performance-wins-traces-coding-agent/"
source: "Sentry"
published: "2026-11-03"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["performance","postgres","ai-coding","observability","python"]
---

# Finding performance wins in our own traces with a coding agent

A post on [Sentry](https://swe.quest/sources/sentry.md), published 2026-11-03, 6 min read, Case study. Original: [https://blog.sentry.io/performance-wins-traces-coding-agent/](https://blog.sentry.io/performance-wins-traces-coding-agent/)

## Summary

Pairing a coding agent with the Sentry MCP over Sentry's own production traces surfaced dozens of small backend fixes that together removed hundreds of millions of queries a week. Django SDK spans with SQL descriptions, query-source file/line attributes and user agents let the agent rank hot paths. Each SQL change was validated with EXPLAIN ANALYZE on a read-only Postgres mirror. Wins included splitting a GroupHistory ORDER BY/LIMIT query into per-status probes (935ms to 0.4ms), adding a missing pagination index, eager-loading related objects, batching cache writes with bulk\_set, and skipping a needless UPDATE running ~10k/s. The post ends with example prompts for hunting N+1 queries and unindexed queries in your own app.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- distributed tracing basics ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))
- SQL query plans ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- Django ORM

## Keywords

Sentry, Sentry MCP, Django, PostgreSQL, EXPLAIN ANALYZE, Claude, sentry-cli

## Related posts

- [Introducing Postgres Query Insights in ClickHouse Cloud](https://swe.quest/articles/introducing-postgres-query-insights-in-clickhouse-cloud-a9697a827409b984.md): ClickHouse · 2026-05-07 · Medium · 7 min read · PostgreSQL, Observability, Performance engineering, Analytics & OLAP
  Postgres Query Insights, now in preview for ClickHouse Cloud Managed Postgres, ranks every normalized query pattern by impact and aggregates per-execution counters (CPU, cache vs disk reads, temp spills, unlaunched parallel workers, WAL) to explain why a pattern is slow.
- [How Edgar Allan Poe found bugs in Turso](https://swe.quest/articles/how-edgar-allan-poe-found-bugs-in-turso-c2af43819364d44c.md): Turso · 2026-06-08 · Medium · 7 min read · Testing, AI agents, SQLite, LLMs, Databases
  Turso runs LLM coding agents (Claude Code with the Ralph Loop plugin) for days at a time to autonomously find SQL correctness bugs.
- [Operate with confidence: check production with your coding agent](https://swe.quest/articles/operate-with-confidence-check-production-with-your-coding-agent-2d12eed022759488.md): Supabase · 2026-10-20 · Medium · 4 min read · AI agents, Observability, PostgreSQL, Developer tools
  Supabase now ships Agent prompts that let a coding agent (Claude, Codex, Cursor) check a production project on a schedule for error spikes, security findings, slow queries and resource growth, reporting only new or worsening issues with the measured value, threshold and a next step.
- [Intelligent security at ClickHouse speed: How Cogent Security built an AI-native vulnerability management platform](https://swe.quest/articles/intelligent-security-at-clickhouse-speed-how-cogent-security-built-an-ai-native-1f3815ca47a60230.md): ClickHouse · 2026-03-24 · Medium · 9 min read · Analytics & OLAP, AI agents, Evaluation, Data pipelines, Performance engineering
  Cogent Security serves billions of vulnerability findings from per-tenant ClickHouse databases fed by a pipeline of entity resolution into a Knowledge Graph, dbt-built denormalized Iceberg tables, and the ClickHouse Spark Connector.
- [Building PlanetScale with Insights Agent](https://swe.quest/articles/building-planetscale-with-insights-agent-b70b35e12242702e.md): PlanetScale · 2026-11-19 · Medium · 5 min read · MySQL, Performance engineering, AI agents, Ruby, Databases
  PlanetScale ran its Insights Agent, which finds costly queries via Query Insights and opens fix PRs, against its own Rails API on MySQL.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
