How do I set a breakpoint in a Cypher statement for further analysis

If you wish to set a ‘breakpoint’ in a Cypher statement so as to perform further analysis (i.e. see how many locks are taken, memory utilization) one can add a call to apoc.utils.sleep(XXX) which will result in the query sleeping… Read more →

Explore:  


Comparing relationship properties within a path

You want to compare relationship-properties of a path, either by a global value or parameter, or with each other within a path. Basic model: (:Person {person_id:’123′})-[:FRIEND {date:’1972-01-01′}]->(m:Person {person_id:’456′}) Make sure to have an constraint OR index on your nodes: Constraint… Read more →

Explore:  


Understanding the Query Plan Cache

When a Cypher statement is first submitted Neo4j will attempt to determine if the query is in the plan cache before planning it. By default Neo4j will keep 1000 query plans in cache based upon the conf/neo4j.conf parameter of dbms.query_cache_size.… Read more →

Explore:  


Alternatives to UNION queries

While UNIONs can be useful for certain cases, they can often be avoided completely with small changes to the query. In this article we’ll present various example cases where a UNION isn’t necessary, and a simple Cypher query will do.… Read more →

Explore:  


Access to the neo4j-shell in NEO4J CE 3.x

From Neo4j 3.0 access to neo4j-shell is no longer possible from the desktop-installers for Windows and OSX. To use neo4j-shell, you have to download the TAR/ZIP distribution from: http://neo4j.com/download/other-releases/ For importing files that contain semicolon separated cypher commands, you can… Read more →

Explore:  


Neo4j & JDBC: the Neo4j JDBC Driver vs. BI Connector

This page describes the connection between JDBC and Neo4j, and when users should use the BI Connector, vs. when they should use the Neo4j JDBC Driver. To begin with, let’s start that JDBC is a transport; that is, it is… Read more →

Explore:  


How do I display the nodes with the most properties

To display the nodes with the most properties defined, run the following Cypher: MATCH (n) RETURN labels(n), keys(n), size(keys(n)), count(*) ORDER BY size(keys(n)) DESC Representative output is similar to: labels(n) keys(n) size(keys(n)) count(*) [Movie] [TotalRevenue, year_of_release, name, id] 4 1… Read more →

Explore:  


How do I display all nodes with no defined labels

Although assigning a node one or more labels provides many benefits (i.e. performance gains from index usage, ability to group nodes into sets, etc), it is possible to create a node without any labels. The following Cypher can be used to… Read more →

Explore:  


Importing Data to Neo4j in the Cloud

Loading data in a Neo4j instance that is in the cloud is very similar to running Neo4j using any other method. However, there are a few small things to look out for and keep in mind when importing data to… Read more →

Explore:  


Cross Product Cypher queries will not perform well

Just like SQL, if you do not properly connect the parts of your query, it will result in a cross (cartesian) product, which is seldom what you want. Take the following example: MATCH (p:Person), (m:Movie) RETURN p, m; In Cypher,… Read more →

Explore:  


How to avoid costly traversals with join hints

When matching a pattern using Cypher, the number of possible paths to evaluate often correlates with query execution time. When there is a supernode in the path (a node with a high number of relationships whose type are included in… Read more →

Explore:  


All shortest paths between a set of nodes

Consider a number of arbitrary nodes, A,B,C,D,E,F,…​.. I wish to return all of the shortest paths between these nodes. The nodes may have many edges between them, but anticipate a maximum of 4. The graph is complex and non hierarchical… Read more →

Explore:  


A note on OPTIONAL MATCHes

An OPTIONAL MATCH matches patterns against your graph database, just like a MATCH does. The difference is that if no matches are found, OPTIONAL MATCH will use a null for missing parts of the pattern. OPTIONAL MATCH could be considered… Read more →

Explore:  


Performing pattern negation to multiple nodes

Some use cases require matching to nodes which aren’t connected to any of some other set of nodes. We’ll discuss both incorrect and correct approaches to this kind of query. For our examples we’ll use a recipe graph, where the… Read more →

Explore:  


Importing CSV Files: Neo4j Desktop and Sandbox

Loading various kinds of files into Neo4j requires different locations depending on the tool you are using. Import methods we will cover: 1. Neo4j Desktop 2. Neo4j Sandbox Neo4j Desktop Filepath for Neo4j Desktop will vary based on your operating… Read more →

Explore:  


Large Delete Transaction Best Practices in Neo4j

In order to achieve the best performance, and avoid negative effects on the rest of the system, consider these best practices when processing large deletes. Start by identifying which situation you are in: Deleting the entire graph database, so you… Read more →

Explore:  


Export a (sub)graph to Cypher script and import it again

Oftentimes you want to export a full (or partial) database to a file and import it again without copying the actual database files. If you want to do the latter, use neo4j-admin dump/load. Here are two ways on how to… Read more →

Explore:  


How do I export Cypher Favorites recorded in the browser

Cypher Favorites are common Cypher statements which one can save to the left panel of the Neo4j browser. A Favorite is created by entering the Cypher at the top prompt and then clicking the Favorite icon to the right as… Read more →

Explore:  


Understanding transaction and lock timeouts

One way to handle runaway queries is to impose a time limit that will terminate a query when exceeded. There are some subtleties here that need to be understood to ensure proper behavior and avoid confusion. Defining a transaction timeout… Read more →

Explore:  


Tuning Cypher queries by understanding cardinality

Cardinality issues are the most frequent culprit in slow or incorrect Cypher queries. Because of this, understanding cardinality, and using this understanding to manage cardinality issues, is a critical component in Cypher query tuning, and query correctness in general. A… Read more →

Explore:  


Explanation of error “Cannot merge node using null property value for”

When running a MERGE, which is a combination of MATCH and/or CREATE one may encounter an error of Cannot merge node using null property value for if the MERGE is performing a MATCH against a null property. For example, when… Read more →

Explore:  


Post-UNION processing

Cypher does not allow further processing of UNION or UNION ALL results, since RETURN is required in all queries of the union. Here are some workarounds. Post-UNION processing in Neo4j 4.0 With Neo4j 4.0, post-UNION processing is now possible via… Read more →

Explore:  


Understanding non-existent properties and working with nulls

In Neo4j, since there is no table schema or equivalent to restrict possible properties, non-existence and null are equivalent for node and relationship properties. That is, there really is no such thing as a property with a null value; null… Read more →

Explore:  


Fast counts using the count store

Neo4j maintains a transactional count store for holding count metadata for a number of things. The count store is used to inform the query planner so it can make educated choices on how to plan the query. Obtaining counts from… Read more →

Explore:  


Understanding Neo4j Query Plan Caching

This article is based on the behavior of Neo4j 2.3.2. Query plan caching is governed by three parameters, as defined in the conf/neo4j.properties file, which are detailed here. The three parameters which govern whether a Cypher statement is planned/replanned are:… Read more →

Explore: