Overview
PROFILE and EXPLAIN
PROFILE = the only honest comparison between two query rewrites.
Why it matters
Cypher gives you two introspection tools: EXPLAIN (the plan, no execution) and PROFILE (the plan + actual db hits per operator). Decisions get made on db hits, not on intuition.
Going deeper
The four operators that tell you almost everything when you read a PROFILE plan:
| Operator | Healthy signal | Smell |
|---|---|---|
NodeIndexSeek | The first thing you see; small db hits | Missing → you got a NodeByLabelScan instead |
NodeByLabelScan | Acceptable on tiny labels (< 10k) | Catastrophic on big labels; add an index |
Expand(All) | Bounded by relationship type + direction | Unbounded fan-out on dense node → mis-modelled |
Eager | Sometimes unavoidable on writes | Often hides a query that could be split in two; flips reads to materialise the whole result set |
A 10× query rewrite is almost always one of: switching a Scan to a Seek (add the right index), constraining a relationship type/direction, or splitting an Eager query into two cheaper ones.