$ recombobulate _
home / tips / optimise-slow-sql-queries-by-pasting-them-to-claude
1

Optimise Slow SQL Queries by Pasting Them to Claude

bagwaa @bagwaa · Mar 25, 2026 · Debugging
optimise-slow-sql-queries-by-pasting-them-to-claude

When a query is crawling and you're not sure why, Claude is a surprisingly good first responder.

Paste the query along with a brief description of the table size and any existing indexes:

-- This query takes ~8 seconds on a 2M row orders table
SELECT u.name, COUNT(o.id) as order_count, SUM(o.total) as revenue
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE o.created_at > '2024-01-01'
GROUP BY u.id
ORDER BY revenue DESC
LIMIT 50;

-- Existing indexes: orders(user_id), users(id)

Claude will identify missing indexes, point out that the WHERE on o.created_at isn't covered, suggest a composite index, and potentially rewrite the query to avoid the full table scan.

For deeper analysis, include the EXPLAIN output:

EXPLAIN ANALYZE SELECT ...;

Paste that plan alongside your query and Claude can pinpoint exactly which step is the bottleneck — nested loop vs hash join, seq scan vs index scan — and explain what to do about it in plain English.

Stop guessing at indexes — let Claude read the query plan and tell you exactly where the time is going.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Detect and Fix Memory Leaks in Your Node.js Application with Claude

Hand Claude your heap snapshots or server code and ask it to trace memory leaks — it spots missing event listener cleanup, unbounded caches, and stream lifecycle bugs that are easy to miss in code review.

bagwaa @bagwaa · 2 hours ago
0
Audit Your UI Components for Accessibility Issues with Claude

Ask Claude to audit your UI components for WCAG accessibility issues — it catches semantic problems, missing ARIA attributes, and keyboard navigation gaps that automated tools miss.

bagwaa @bagwaa · 2 hours ago
0
Debug API and MCP Issues with --debug

The --debug flag enables verbose logging for Claude Code, and an optional category filter like "api,mcp" lets you narrow output to exactly the subsystem you need to investigate.

bagwaa @bagwaa · 5 hours ago