Performance review of AI-written code
For engineers
Catching N+1 queries, hidden quadratic loops, memory growth and chatty I/O in AI code, and proving fixes by measuring
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
What is the clearest sign of an N+1 query problem in AI-written code?
Check yourself · 2 of 5
A function loops over n items and calls list.index on a list of n items inside the loop. What is its time complexity?
Check yourself · 3 of 5
An AI-written script calls an API once per item in a loop of 500 items, awaiting each call. What is the main cost?
Check yourself · 4 of 5
Which line is the most likely cause of unbounded memory growth in a long-running service?
Check yourself · 5 of 5
What should you do before asking an agent to optimise a slow endpoint?
Topics
- Spotting N+1 database queries5 min read · ORM loops that fire one query per row, and fixes with joins, eager loading and batching
- Hidden quadratic loops in generated code5 min read · Nested scans, lookups inside loops, repeated sorting and string building that work on test data and fail at scale
- Chatty network calls and missing batching5 min read · Sequential awaits, per-item API calls, missing pagination and no caching in AI-written integrations
- Memory leaks and unbounded growth5 min read · Unbounded caches, listeners never removed, whole files or tables loaded into memory, and missing streaming
- Profiling and benchmarking before optimising5 min read · Profilers, flame graphs, query plans and benchmarks so neither you nor the agent optimises by guesswork
Start here
- Use The Index, Luke: SQL indexing and tuning (opens in a new tab)BookFree
A free book on how indexes and query shape decide database speed.
- Using EXPLAIN (PostgreSQL documentation) (opens in a new tab)DocsFree
How to read a query plan, with estimated and actual costs.
- Flame Graphs (Brendan Gregg) (opens in a new tab)ArticleFree
The inventor explains how to read a flame graph to find where time goes.
Helps to know first
110 questions · last verified 2026-12