Query Analysis

Anvil provides two tools for understanding query execution: EXPLAIN shows the planned execution without running the query, and PROFILE executes the query and reports actual performance statistics.

EXPLAIN

Show the query execution plan without executing it.

EXPLAIN MATCH (n:Person) WHERE n.age > 25 RETURN n

-- Complex query plan
EXPLAIN MATCH (a:Person)-[:FRIEND]->(b:Person)-[:WORKS_AT]->(c:Company)
WHERE a.age > 25
RETURN a.name, c.name

PROFILE

Execute the query and show actual statistics (rows processed, time per operator).

PROFILE MATCH (n:Person)-[:FRIEND]->(m:Person)
RETURN n.name, m.name

Query Analytics

-- Most-called queries with latency percentiles
SHOW QUERY STATS LIMIT 10

Returns: query, count, avg_ms, p95_ms, p99_ms, min_ms, max_ms.

Event & Dependency Analysis

-- View recent events
SHOW EVENTS
SHOW EVENTS LIMIT 20
SHOW EVENTS WHERE type = 'QuerySlow'

-- Map trigger/function/sync dependencies
SHOW DEPENDENCIES
SHOW DEPENDENCIES FOR TRIGGER create_profile