Company
Date Published
Author
Matt Holford
Word count
2850
Language
English
Hacker News points
None

Summary

The author of the text is a consulting engineer at PS who frequently receives questions from Neo4j customers about improving query performance on large graphs. They explain that achieving good performance depends on having an effective model for the data and efficiently designed queries. The article discusses the two main ways of querying a graph in Neo4j: through the Cypher query language and via a Java API. While a solid model and well-designed Cypher query are sufficient in most cases, the Java API provides more control and is useful when fine-grained control is needed. The author aims to show that writing a stored procedure is not an arcane process but rather a simple Java program. They provide a simplified example of building a stored procedure using the Neo4j Java API, which aggregates patterns in patient journeys after a certain condition. The article covers the design and implementation of the stored procedure, including the use of Java annotations to inject context objects, defining a custom data class for the result, and implementing methods to traverse the graph and aggregate results.