Query Tuning Playbook

A repeatable performance method using PROFILE, schema assertions, and controlled rewrites.

0/4 done

Overview

Query Tuning Playbook

A repeatable performance method using PROFILE, schema assertions, and controlled rewrites.

Why it matters

Most teams tune Cypher by folklore. A disciplined playbook turns query tuning into measurable engineering work.

Going deeper

A disciplined loop turns tuning into measurable engineering:

  1. BaselinePROFILE the query, record db hits per operator.
  2. One change — add an index, constrain a relationship type/direction, or tighten a pattern. Never two at once.
  3. Re-profile — compare db hits, not wall-clock (which is polluted by cache state and network).
  4. Keep or revert — keep only changes that cut db hits and keep the query readable.

The highest-yield findings are almost always: a NodeByLabelScan that should be a NodeIndexSeek (missing index), an unbounded/untyped Expand(All), or an Eager operator forcing the whole result to materialize. If db hits don't move, you changed syntax, not the plan.

Analogy

Query tuning by folklore is adjusting a recipe by smell; the PROFILE playbook is a kitchen scale. You change one ingredient, weigh the result (db hits), keep it only if the number improved. Anecdote — 'it felt faster' — is exactly how teams ship changes that did nothing but warm the cache.

Worked example — prototype to production

A practical tuning loop is deterministic, not anecdotal.

  1. Capture a baseline PROFILE (db hits per operator).
  2. Apply one change only (index, pattern tightening, relationship-type constraint).
  3. Re-profile and compare db hits — not wall-clock.
  4. Keep only changes that improve both cost and readability.

If db hits don't drop, you changed syntax, not the execution plan.

Pitfalls — what breaks when this is weak

  • Tuning on wall-clock. Warm vs cold cache makes it lie. Fix: compare db hits from PROFILE.
  • Changing several things at once. You can't attribute the win. Fix: one change per measurement.
  • Adding memory before profiling. Hides the real bottleneck. Fix: profile first.

Make it stick

Use the prompts below to anchor query tuning playbook to a real graph you own.

  • Which production query have you never PROFILEd — your likely next big win?
  • Where does your team decide tuning on wall-clock instead of db hits?
  • What's your single highest-db-hit operator right now, and what's the indicated fix?

Reading in progress · 0 of 4 activities done