Sentry backend performance was optimized using an AI coding agent, specifically Claude with Opus 5.5, connected to Sentry MCP. The agent analyzed distributed traces to identify and resolve performance bottlenecks on critical paths.

The optimization process involved ranking spans by frequency and duration to identify expensive operations. The agent evaluated potential fixes by reviewing code and git history, then generated draft pull requests for review.

Key improvements included eliminating redundant database queries and optimizing SQL execution plans. For instance, refactoring a GroupHistory query reduced execution time from 935 ms to 0.4 ms on a cold cache.

Specific optimizations, such as reusing project objects, reduced SELECT queries by approximately 143 million per week. Another change involving bulk cache writes reduced latency for specific operations from 51 ms to 1.2 ms.

Database load was significantly reduced across regions. In the US region, disk reads for certain status update queries dropped to near zero, while API-related repository pagination queries saw a 69% reduction in average execution time.