Label & property indexes·4 min
Anchors: where traversals begin
0 / 1
Index-free adjacency makes hops O(1). But a query like MATCH (p:Person {name:'Kevin Bacon'})... first has to find Kevin. Without help that's an O(N) scan over every node. So graph databases keep regular indexes for the entry point — the one place a graph database does use classic indexing.
The mental model to lock in: indexes find the start; adjacency does the walking. A label index maps Person → all person ids. A property index maps (Person, name, 'Kevin Bacon') → the id. Find the anchor with an index probe, then switch to pointer-chasing.
Two halves of one query
query: (p:Person {name:'Kevin Bacon'})-[:ACTED_IN]->(m)
└────────── index lookup ──────────┘ └─ pointer-chase ─┘
labelIndex['Person'] ∩ nameIndex['Kevin Bacon']
neighbors(bacon, ACTED_IN, OUT)