Skip to content
AI Skill Index

Trace a performance problem to its cause

Separates the slow thing from the thing you noticed.

Author: Editorial
Sign in to save
Something is slow. Help me find out what, before I optimise the wrong thing.

Symptom: [WHAT IS SLOW, AND HOW SLOW]
What I have measured so far: [PROFILE OUTPUT, TIMINGS, OR "NOTHING YET"]
Stack: [LANGUAGE, FRAMEWORK, DATABASE]

Work through it:
1. What are the plausible causes, ranked by how often they turn out to be the answer in a system like this?
2. For each, the cheapest measurement that would confirm or eliminate it.
3. Which measurement should I take first — the one that eliminates the most possibilities.

If I have given you no measurements, say so and give me the first one to take. Do not suggest optimisations yet. An optimisation applied to the wrong layer is worse than none, because it adds complexity and moves nothing.

Highlighted parts are placeholders. Replace them before you send.

Worked example

The input is invented for this page. The output shows what the prompt asks for with that input.

Example input (invented)

Symptom: The orders list page in our admin takes 6 to 8 seconds to load. In spring it took under 1 second. The orders table has grown from about 40,000 rows to 310,000 since then.

What I have measured so far: The browser's network tab only. The HTML response takes 6.4 seconds to arrive, and the scripts and images after it add 0.3 seconds. Nothing on the server yet.

Stack: Python, Django, PostgreSQL.

Example output

Your one measurement already rules something out. Of about 6.7 seconds, 6.4 pass before the HTML arrives, so the browser, the scripts and the images are not the cause. The time goes on the server.

1. Plausible causes, most likely first

  1. A query that scans the whole orders table, because it filters or sorts on a column with no index. It fits the history: its cost grows with the table.
  2. The pagination count. A paginated list counts every matching row on each load, and that count slows as the table grows.
  3. A query per row. The page fetches each order's customer or items one at a time. Common in Django, but its cost follows the page size and not the table size, so it explains a slow page better than a page that got slower.
  4. Python, not the database. The view loads far more rows than it shows and trims them in memory.

2. The cheapest measurement for each

CauseMeasurement
Full scanRun the list query under EXPLAIN ANALYZE and look for a sequential scan on orders
CountTime the paginator's COUNT(*) query on its own
Query per rowCount the queries for one page load. Hundreds means this one
PythonSubtract the total query time from 6.4 seconds. The rest is Python

3. Take this one first. Log every query of one page load with its duration. Django keeps them in django.db.connection.queries when DEBUG is on, so do it on a copy of the production data. That one list sorts all four causes. One slow query points at 1 or 2, hundreds of fast ones at 3, and a small total at 4.

I have suggested no fix. An index added before that measurement would be a guess.

ShareXLinkedIn

3 of the 7 other prompts filed under Coding.

Coding tools and skills

3 of the 9 tools and 3 of the 7 skills filed under Coding, the same category as this prompt.

Tool

Continue

Open-source coding agent for VS Code, JetBrains and the CLI. Cursor acquired it, and the repository is read-only.

Open source
Tool

Cursor

An editor built around AI-assisted editing.

Freemium
Tool

Devin Desktop

A full IDE with a command center for running local and cloud coding agents. It used to be called Windsurf.

Freemium
Skill

Accessibility reviewer

Reviews a component against WCAG failures that automated tools miss.

Claude Code, Cursor, Any agent
Skill

Release notes writer

Writes release notes and a changelog from a commit range, leaving out the commits users never notice.

Claude Code, Any agent
Skill

Test writer

Writes tests that fail for the right reason and refuse to test the framework.

Claude Code, Cursor, Any agent

Coding guides

3 of the 6 guides filed under Coding, the same category as this prompt.

Cookies

We use only the cookies this site needs to work. Optional analytics helps us see which content is worth writing more of — nothing loads until you say yes.

Read the privacy policy