7.4. Execution plan operators in detail

All operators are listed here, grouped by the similarity of their characteristics.

Certain operators are only used by a subset of the runtimes that Cypher can choose from. If that is the case, the example queries will be prefixed with an option to choose one of these runtimes.

7.4.1. All Nodes Scan

The AllNodesScan operator reads all nodes from the node store. The variable that will contain the nodes is seen in the arguments. Any query using this operator is likely to encounter performance problems on a non-trivial database.

Query. 

MATCH (n)
RETURN n

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+---------+----------------+------+---------+----------------+---------------------+
| Operator        | Details | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------+---------+----------------+------+---------+----------------+---------------------+
| +ProduceResults | n       |             35 |   35 |       0 |                | Fused in Pipeline 0 |
| |               +---------+----------------+------+---------+----------------+---------------------+
| +AllNodesScan   | n       |             35 |   35 |      36 |             64 | Fused in Pipeline 0 |
+-----------------+---------+----------------+------+---------+----------------+---------------------+

Total database accesses: 36, total allocated memory: 64

7.4.2. Directed Relationship By Id Seek

The DirectedRelationshipByIdSeek operator reads one or more relationships by id from the relationship store, and produces both the relationship and the nodes on either side.

Query. 

MATCH (n1)-[r]->()
WHERE id(r)= 0
RETURN r, n1

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-------------------------------+----------------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator                      | Details                                      | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-------------------------------+----------------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults               | r, n1                                        |              1 |    1 |       0 |                | Fused in Pipeline 0 |
| |                             +----------------------------------------------+----------------+------+---------+----------------+---------------------+
| +DirectedRelationshipByIdSeek | (n1)-[r]->(anon_17) WHERE id(r) = $autoint_0 |              1 |    1 |       1 |             64 | Fused in Pipeline 0 |
+-------------------------------+----------------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.3. Node By Id Seek

The NodeByIdSeek operator reads one or more nodes by id from the node store.

Query. 

MATCH (n)
WHERE id(n)= 0
RETURN n

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+----------------------------+----------------+------+---------+----------------+---------------------+
| Operator        | Details                    | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------+----------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults | n                          |              1 |    1 |       0 |                | Fused in Pipeline 0 |
| |               +----------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByIdSeek   | n WHERE id(n) = $autoint_0 |              1 |    1 |       1 |             64 | Fused in Pipeline 0 |
+-----------------+----------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.4. Node By Label Scan

The NodeByLabelScan operator fetches all nodes with a specific label from the node label index.

Query. 

MATCH (person:Person)
RETURN person

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+---------------+----------------+------+---------+----------------+---------------------+
| Operator         | Details       | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+------------------+---------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults  | person        |             14 |   14 |       0 |                | Fused in Pipeline 0 |
| |                +---------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan | person:Person |             14 |   14 |      15 |             64 | Fused in Pipeline 0 |
+------------------+---------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 15, total allocated memory: 64

7.4.5. Node Index Seek

The NodeIndexSeek operator finds nodes using an index seek. The node variable and the index used is shown in the arguments of the operator. If the index is a unique index, the operator is instead called NodeUniqueIndexSeek.

Query. 

MATCH (location:Location { name: 'Malmo' })
RETURN location

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+----------------------------------------------------+----------------+------+---------+----------------+-------------------+---------------------+
| Operator        | Details                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order             | Other               |
+-----------------+----------------------------------------------------+----------------+------+---------+----------------+-------------------+---------------------+
| +ProduceResults | location                                           |              1 |    1 |       0 |                | location.name ASC | Fused in Pipeline 0 |
| |               +----------------------------------------------------+----------------+------+---------+----------------+-------------------+---------------------+
| +NodeIndexSeek  | location:Location(name) WHERE name = $autostring_0 |              1 |    1 |       2 |             64 | location.name ASC | Fused in Pipeline 0 |
+-----------------+----------------------------------------------------+----------------+------+---------+----------------+-------------------+---------------------+

Total database accesses: 2, total allocated memory: 64

7.4.6. Node Unique Index Seek

The NodeUniqueIndexSeek operator finds nodes using an index seek within a unique index. The node variable and the index used is shown in the arguments of the operator. If the index is not unique, the operator is instead called NodeIndexSeek. If the index seek is used to solve a MERGE clause, it will also be marked with (Locking). This makes it clear that any nodes returned from the index will be locked in order to prevent concurrent conflicting updates.

Query. 

MATCH (t:Team { name: 'Malmo' })
RETURN t

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+----------------------+------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator             | Details                                        | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+----------------------+------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults      | t                                              |              1 |    0 |       0 |                | t.name ASC | Fused in Pipeline 0 |
| |                    +------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeUniqueIndexSeek | UNIQUE t:Team(name) WHERE name = $autostring_0 |              1 |    0 |       1 |             64 | t.name ASC | Fused in Pipeline 0 |
+----------------------+------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.7. Multi Node Index Seek

The MultiNodeIndexSeek operator finds nodes using multiple index seeks. It supports using multiple distinct indexes for different nodes in the query. The node variables and the indexes used are shown in the arguments of the operator.

The operator yields a cartesian product of all index seeks. For example, if the operator does two seeks and the first seek finds the nodes a1, a2 and the second b1, b2, b3, the MultiNodeIndexSeek will yield the rows (a1, b1), (a1, b2), (a1, b3), (a2, b1), (a2, b2), (a2, b3).

Query. 

CYPHER runtime=pipelined
MATCH (location:Location { name: 'Malmo' }),(person:Person { name: 'Bob' })
RETURN location, person

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+---------------------+----------------------------------------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-------------------+---------------+
| Operator            | Details                                                                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order             | Other         |
+---------------------+----------------------------------------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-------------------+---------------+
| +ProduceResults     | location, person                                                                                   |              1 |    1 |       0 |                |     0.124 | location.name ASC | In Pipeline 0 |
| |                   +----------------------------------------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-------------------+---------------+
| +MultiNodeIndexSeek | location:Location(name) WHERE name = $autostring_0, person:Person(name) WHERE name = $autostring_1 |              1 |    1 |       4 |             64 |     1.755 | location.name ASC | In Pipeline 0 |
+---------------------+----------------------------------------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-------------------+---------------+

Total database accesses: 4, total allocated memory: 64

7.4.8. Node Index Seek By Range

The NodeIndexSeekByRange operator finds nodes using an index seek where the value of the property matches a given prefix string. NodeIndexSeekByRange can be used for STARTS WITH and comparison operators such as <, >, <= and >=. If the index is a unique index, the operator is instead called NodeUniqueIndexSeekByRange.

Query. 

MATCH (l:Location)
WHERE l.name STARTS WITH 'Lon'
RETURN l

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+-------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator              | Details                                               | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+-----------------------+-------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults       | l                                                     |              2 |    1 |       0 |                | l.name ASC | Fused in Pipeline 0 |
| |                     +-------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeIndexSeekByRange | l:Location(name) WHERE name STARTS WITH $autostring_0 |              2 |    1 |       2 |             64 | l.name ASC | Fused in Pipeline 0 |
+-----------------------+-------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 2, total allocated memory: 64

7.4.9. Node Unique Index Seek By Range

The NodeUniqueIndexSeekByRange operator finds nodes using an index seek within a unique index, where the value of the property matches a given prefix string. NodeUniqueIndexSeekByRange is used by STARTS WITH and comparison operators such as <, >, <= and >=. If the index is not unique, the operator is instead called NodeIndexSeekByRange.

Query. 

MATCH (t:Team)
WHERE t.name STARTS WITH 'Ma'
RETURN t

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------------+----------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator                    | Details                                                  | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+-----------------------------+----------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults             | t                                                        |              2 |    0 |       0 |                | t.name ASC | Fused in Pipeline 0 |
| |                           +----------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeUniqueIndexSeekByRange | UNIQUE t:Team(name) WHERE name STARTS WITH $autostring_0 |              2 |    0 |       1 |             64 | t.name ASC | Fused in Pipeline 0 |
+-----------------------------+----------------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.10. Node Index Contains Scan

The NodeIndexContainsScan operator examines all values stored in an index, searching for entries containing a specific string; for example, in queries including CONTAINS. Although this is slower than an index seek (since all entries need to be examined), it is still faster than the indirection resulting from a label scan using NodeByLabelScan, and a property store filter.

Query. 

MATCH (l:Location)
WHERE l.name CONTAINS 'al'
RETURN l

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------------+----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator               | Details                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+------------------------+----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults        | l                                                  |              0 |    2 |       0 |                | l.name ASC | Fused in Pipeline 0 |
| |                      +----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeIndexContainsScan | l:Location(name) WHERE name CONTAINS $autostring_0 |              0 |    2 |       3 |             64 | l.name ASC | Fused in Pipeline 0 |
+------------------------+----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 3, total allocated memory: 64

7.4.11. Node Index Ends With Scan

The NodeIndexEndsWithScan operator examines all values stored in an index, searching for entries ending in a specific string; for example, in queries containing ENDS WITH. Although this is slower than an index seek (since all entries need to be examined), it is still faster than the indirection resulting from a label scan using NodeByLabelScan, and a property store filter.

Query. 

MATCH (l:Location)
WHERE l.name ENDS WITH 'al'
RETURN l

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------------+-----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator               | Details                                             | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+------------------------+-----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults        | l                                                   |              0 |    0 |       0 |                | l.name ASC | Fused in Pipeline 0 |
| |                      +-----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeIndexEndsWithScan | l:Location(name) WHERE name ENDS WITH $autostring_0 |              0 |    0 |       1 |             64 | l.name ASC | Fused in Pipeline 0 |
+------------------------+-----------------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.12. Node Index Scan

The NodeIndexScan operator examines all values stored in an index, returning all nodes with a particular label having a specified property.

Query. 

MATCH (l:Location)
WHERE EXISTS (l.name)
RETURN l

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+-------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator        | Details                             | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------+-------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults | l                                   |             10 |   10 |       0 |                | Fused in Pipeline 0 |
| |               +-------------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeIndexScan  | l:Location(name) WHERE exists(name) |             10 |   10 |      11 |             64 | Fused in Pipeline 0 |
+-----------------+-------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 11, total allocated memory: 64

7.4.13. Undirected Relationship By Id Seek

The UndirectedRelationshipByIdSeek operator reads one or more relationships by id from the relationship store. As the direction is unspecified, two rows are produced for each relationship as a result of alternating the combination of the start and end node.

Query. 

MATCH (n1)-[r]-()
WHERE id(r)= 1
RETURN r, n1

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+---------------------------------+---------------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator                        | Details                                     | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+---------------------------------+---------------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults                 | r, n1                                       |              1 |    2 |       0 |                | Fused in Pipeline 0 |
| |                               +---------------------------------------------+----------------+------+---------+----------------+---------------------+
| +UndirectedRelationshipByIdSeek | (n1)-[r]-(anon_16) WHERE id(r) = $autoint_0 |              1 |    2 |       1 |             64 | Fused in Pipeline 0 |
+---------------------------------+---------------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.14. Apply

All the different Apply operators (listed below) share the same basic functionality: they perform a nested loop by taking a single row from the left-hand side, and using the Argument operator on the right-hand side, execute the operator tree on the right-hand side. The versions of the Apply operators differ in how the results are managed. The Apply operator (i.e. the standard version) takes the row produced by the right-hand side — which at this point contains data from both the left-hand and right-hand sides — and yields it..

Query. 

MATCH (p:Person { name:'me' })
MATCH (q:Person { name: p.secondName })
RETURN p, q

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| Operator         | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order      | Other               |
+------------------+-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +ProduceResults  | p, q                                      |              1 |    0 |       0 |                |           | p.name ASC | Fused in Pipeline 1 |
| |                +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +Apply           |                                           |              1 |    0 |       0 |                |           | p.name ASC |                     |
| |\               +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| | +NodeIndexSeek | q:Person(name) WHERE name = p.secondName  |              1 |    0 |       0 |             72 |           |            | Fused in Pipeline 1 |
| |                +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +NodeIndexSeek   | p:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |             64 |     0.166 | p.name ASC | In Pipeline 0       |
+------------------+-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------------+

Total database accesses: 2, total allocated memory: 72

7.4.15. Semi Apply

The SemiApply operator tests for the presence of a pattern predicate, and is a variation of the Apply operator. If the right-hand side operator yields at least one row, the row from the left-hand side operator is yielded by the SemiApply operator. This makes SemiApply a filtering operator, used mostly for pattern predicates in queries.

Query. 

CYPHER runtime=slotted
MATCH (p:Person)
WHERE (p)-[:FRIENDS_WITH]->(:Person)
RETURN p.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+--------------------+---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator           | Details                               | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+--------------------+---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults    | `p.name`                              |             11 |    2 |       0 |               0 |                 0 |               0.0000 |
| |                  +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection        | cache[p.name] AS `p.name`             |             11 |    2 |       2 |               1 |                 0 |               1.0000 |
| |                  +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SemiApply         |                                       |             11 |    2 |       0 |               0 |                 0 |               0.0000 |
| |\                 +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +CacheProperties | cache[p.name]                         |              2 |    0 |       0 |               0 |                 0 |               0.0000 |
| | |                +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter          | anon_45:Person                        |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)     | (p)-[anon_27:FRIENDS_WITH]->(anon_45) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument        | p                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                  +---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan   | p:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+--------------------+---------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 52, total allocated memory: 0

7.4.16. Anti Semi Apply

The AntiSemiApply operator tests for the absence of a pattern, and is a variation of the Apply operator. If the right-hand side operator yields no rows, the row from the left-hand side operator is yielded by the AntiSemiApply operator. This makes AntiSemiApply a filtering operator, used for pattern predicates in queries.

Query. 

CYPHER runtime=slotted
MATCH (me:Person { name: "me" }),(other:Person)
WHERE NOT (me)-[:FRIENDS_WITH]->(other)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+--------------------+--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| Operator           | Details                                    | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order       |
+--------------------+--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +ProduceResults    | `other.name`                               |              4 |   13 |       0 |                |               0 |                 0 |               0.0000 | me.name ASC |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +Projection        | other.name AS `other.name`                 |              4 |   13 |      13 |                |               2 |                 0 |               1.0000 | me.name ASC |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +AntiSemiApply     |                                            |              4 |   13 |       0 |                |               0 |                 0 |               0.0000 | me.name ASC |
| |\                 +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| | +Expand(Into)    | (me)-[anon_62:FRIENDS_WITH]->(other)       |              0 |    0 |      55 |           9984 |              15 |                 0 |               1.0000 |             |
| | |                +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| | +Argument        | me, other                                  |             14 |   14 |       0 |                |               0 |                 0 |               0.0000 |             |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +CartesianProduct  |                                            |             14 |   14 |       0 |                |               0 |                 0 |               0.0000 | me.name ASC |
| |\                 +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| | +NodeByLabelScan | other:Person                               |             14 |   14 |      15 |                |               2 |                 0 |               1.0000 |             |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +NodeIndexSeek     | me:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |                |               0 |                 1 |               0.0000 | me.name ASC |
+--------------------+--------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+

Total database accesses: 85, total allocated memory: 9984

7.4.17. Anti

The Anti operator tests for the absence of a pattern. If there are incoming rows, the Anti operator will yield no rows. If there are no incoming rows, the Anti operator will yield a single row.

Query. 

CYPHER runtime=pipelined
MATCH (me:Person { name: "me" }),(other:Person)
WHERE NOT (me)-[:FRIENDS_WITH]->(other)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+--------------------+--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| Operator           | Details                                    | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order       | Other               |
+--------------------+--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| +ProduceResults    | `other.name`                               |              4 |   13 |       0 |                |     0.231 | me.name ASC | In Pipeline 4       |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| +Projection        | other.name AS `other.name`                 |              4 |   13 |      26 |                |     0.225 | me.name ASC | In Pipeline 4       |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| +Apply             |                                            |              4 |   13 |       0 |                |           | me.name ASC |                     |
| |\                 +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| | +Anti            |                                            |             14 |   13 |       0 |                |     0.055 |             | In Pipeline 4       |
| | |                +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| | +Limit           | 1                                          |             14 |    1 |       0 |                |           |             | Fused in Pipeline 3 |
| | |                +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| | +Expand(Into)    | (me)-[anon_62:FRIENDS_WITH]->(other)       |              0 |    1 |      55 |           2728 |           |             | Fused in Pipeline 3 |
| | |                +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| | +Argument        | me, other                                  |             14 |   14 |       0 |            400 |           |             | Fused in Pipeline 3 |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| +CartesianProduct  |                                            |             14 |   14 |       0 |            288 |     0.113 | me.name ASC | In Pipeline 2       |
| |\                 +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| | +NodeByLabelScan | other:Person                               |             14 |   14 |      15 |             80 |     0.067 |             | In Pipeline 1       |
| |                  +--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+
| +NodeIndexSeek     | me:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |             64 |     0.184 | me.name ASC | In Pipeline 0       |
+--------------------+--------------------------------------------+----------------+------+---------+----------------+-----------+-------------+---------------------+

Total database accesses: 98, total allocated memory: 2728

7.4.18. Let Semi Apply

The LetSemiApply operator tests for the presence of a pattern predicate, and is a variation of the Apply operator. When a query contains multiple pattern predicates separated with OR, LetSemiApply will be used to evaluate the first of these. It will record the result of evaluating the predicate but will leave any filtering to another operator. In the example, LetSemiApply will be used to check for the presence of the FRIENDS_WITH relationship from each person.

Query. 

MATCH (other:Person)
WHERE (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator           | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults    | `other.name`                              |             13 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection        | cache[other.name] AS `other.name`         |             13 |   14 |      14 |               1 |                 0 |               1.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SelectOrSemiApply | anon_27                                   |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\                 +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter          | anon_87:Location                          |             15 |    0 |      12 |               0 |                 0 |               0.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)     | (other)-[anon_73:WORKS_IN]->(anon_87)     |             15 |   12 |      26 |              12 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument        | other                                     |             14 |   12 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +LetSemiApply      |                                           |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\                 +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +CacheProperties | cache[other.name]                         |              2 |    0 |       0 |               0 |                 0 |               0.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter          | anon_53:Person                            |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)     | (other)-[anon_35:FRIENDS_WITH]->(anon_53) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument        | other                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan   | other:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 102, total allocated memory: 0

7.4.19. Let Anti Semi Apply

The LetAntiSemiApply operator tests for the absence of a pattern, and is a variation of the Apply operator. When a query contains multiple negated pattern predicates — i.e. predicates separated with OR, where at least one predicate contains NOT — LetAntiSemiApply will be used to evaluate the first of these. It will record the result of evaluating the predicate but will leave any filtering to another operator. In the example, LetAntiSemiApply will be used to check for the absence of the FRIENDS_WITH relationship from each person.

Query. 

MATCH (other:Person)
WHERE NOT ((other)-[:FRIENDS_WITH]->(:Person)) OR (other)-[:WORKS_IN]->(:Location)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator           | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults    | `other.name`                              |             11 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection        | other.name AS `other.name`                |             11 |   14 |      14 |               1 |                 0 |               1.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SelectOrSemiApply | anon_32                                   |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\                 +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter          | anon_93:Location                          |             15 |    0 |       2 |               0 |                 0 |               0.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)     | (other)-[anon_79:WORKS_IN]->(anon_93)     |             15 |    2 |       7 |               2 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument        | other                                     |             14 |    2 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +LetAntiSemiApply  |                                           |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\                 +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter          | anon_58:Person                            |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)     | (other)-[anon_40:FRIENDS_WITH]->(anon_58) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument        | other                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan   | other:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 73, total allocated memory: 0

7.4.20. Select Or Semi Apply

The SelectOrSemiApply operator tests for the presence of a pattern predicate and evaluates a predicate, and is a variation of the Apply operator. This operator allows for the mixing of normal predicates and pattern predicates that check for the presence of a pattern. First, the normal expression predicate is evaluated, and, only if it returns false, is the costly pattern predicate evaluated.

Query. 

MATCH (other:Person)
WHERE other.age > 25 OR (other)-[:FRIENDS_WITH]->(:Person)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator           | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults    | `other.name`                              |             11 |    2 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection        | cache[other.name] AS `other.name`         |             11 |    2 |       2 |               1 |                 0 |               1.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SelectOrSemiApply | other.age > $autoint_0                    |             14 |    2 |      14 |               0 |                 0 |               0.0000 |
| |\                 +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +CacheProperties | cache[other.name]                         |              2 |    0 |       0 |               0 |                 0 |               0.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter          | anon_71:Person                            |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)     | (other)-[anon_53:FRIENDS_WITH]->(anon_71) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument        | other                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                  +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan   | other:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+--------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 66, total allocated memory: 0

7.4.21. Select Or Anti Semi Apply

The SelectOrAntiSemiApply operator is used to evaluate OR between a predicate and a negative pattern predicate (i.e. a pattern predicate preceded with NOT), and is a variation of the Apply operator. If the predicate returns true, the pattern predicate is not tested. If the predicate returns false or null, SelectOrAntiSemiApply will instead test the pattern predicate.

Query. 

MATCH (other:Person)
WHERE other.age > 25 OR NOT (other)-[:FRIENDS_WITH]->(:Person)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator               | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults        | `other.name`                              |              4 |   12 |       0 |               0 |                 0 |               0.0000 |
| |                      +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection            | other.name AS `other.name`                |              4 |   12 |      12 |               1 |                 0 |               1.0000 |
| |                      +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SelectOrAntiSemiApply | other.age > $autoint_0                    |             14 |   12 |      14 |               0 |                 0 |               0.0000 |
| |\                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter              | anon_75:Person                            |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)         | (other)-[anon_57:FRIENDS_WITH]->(anon_75) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument            | other                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                      +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan       | other:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 76, total allocated memory: 0

7.4.22. Let Select Or Semi Apply

The LetSelectOrSemiApply operator is planned for pattern predicates that are combined with other predicates using OR. This is a variation of the Apply operator.

Query. 

MATCH (other:Person)
WHERE (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) OR other.age = 5
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator              | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults       | `other.name`                              |             13 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection           | cache[other.name] AS `other.name`         |             13 |   14 |      14 |               1 |                 0 |               1.0000 |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SelectOrSemiApply    | anon_27                                   |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter             | anon_87:Location                          |             15 |    0 |      12 |               0 |                 0 |               0.0000 |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)        | (other)-[anon_73:WORKS_IN]->(anon_87)     |             15 |   12 |      26 |              12 |                 0 |               1.0000 |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument           | other                                     |             14 |   12 |       0 |               0 |                 0 |               0.0000 |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +LetSelectOrSemiApply | other.age = $autoint_0                    |             14 |   14 |      14 |               0 |                 0 |               0.0000 |
| |\                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +CacheProperties    | cache[other.name]                         |              2 |    0 |       0 |               0 |                 0 |               0.0000 |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter             | anon_53:Person                            |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)        | (other)-[anon_35:FRIENDS_WITH]->(anon_53) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument           | other                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan      | other:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 116, total allocated memory: 0

7.4.23. Let Select Or Anti Semi Apply

The LetSelectOrAntiSemiApply operator is planned for negated pattern predicates — i.e. pattern predicates preceded with NOT — that are combined with other predicates using OR. This operator is a variation of the Apply operator.

Query. 

MATCH (other:Person)
WHERE NOT (other)-[:FRIENDS_WITH]->(:Person) OR (other)-[:WORKS_IN]->(:Location) OR other.age = 5
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+---------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator                  | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+---------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults           | `other.name`                              |             11 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                         +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection               | other.name AS `other.name`                |             11 |   14 |      14 |               1 |                 0 |               1.0000 |
| |                         +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SelectOrSemiApply        | anon_31                                   |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\                        +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter                 | anon_91:Location                          |             15 |    0 |       2 |               0 |                 0 |               0.0000 |
| | |                       +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)            | (other)-[anon_77:WORKS_IN]->(anon_91)     |             15 |    2 |       7 |               2 |                 0 |               1.0000 |
| | |                       +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument               | other                                     |             14 |    2 |       0 |               0 |                 0 |               0.0000 |
| |                         +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +LetSelectOrAntiSemiApply | other.age = $autoint_0                    |             14 |   14 |      14 |               0 |                 0 |               0.0000 |
| |\                        +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter                 | anon_57:Person                            |              2 |    0 |       2 |               1 |                 0 |               1.0000 |
| | |                       +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)            | (other)-[anon_39:FRIENDS_WITH]->(anon_57) |              2 |    2 |      33 |              15 |                 0 |               1.0000 |
| | |                       +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument               | other                                     |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                         +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan          | other:Person                              |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+---------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 87, total allocated memory: 0

7.4.24. Conditional Apply

The ConditionalApply operator checks whether a variable is not null, and if so, the right child operator will be executed. This operator is a variation of the Apply operator.

Query. 

MERGE (p:Person { name: 'Andy' })
ON MATCH SET p.exists = TRUE

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| Operator              | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order      |
+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +ProduceResults       |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +EmptyResult          |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +AntiConditionalApply |                                           |              1 |    1 |       0 |               0 |                 0 |               0.0000 |            |
| |\                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +MergeCreateNode    | p                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +ConditionalApply     |                                           |              1 |    1 |       0 |               0 |                 0 |               0.0000 |            |
| |\                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +SetProperty        | p.exists = true                           |              1 |    1 |       3 |               2 |                 0 |               1.0000 |            |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +Argument           | p                                         |              1 |    1 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +Optional             |                                           |              1 |    1 |       0 |               0 |                 0 |               0.0000 | p.name ASC |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +NodeIndexSeek        | p:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |               0 |                 1 |               0.0000 | p.name ASC |
+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+

Total database accesses: 5, total allocated memory: 416

7.4.25. Anti Conditional Apply

The AntiConditionalApply operator checks whether a variable is null, and if so, the right child operator will be executed. This operator is a variation of the Apply operator.

Query. 

MERGE (p:Person { name: 'Andy' })
ON CREATE SET p.exists = TRUE

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| Operator              | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order      |
+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +ProduceResults       |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +EmptyResult          |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +AntiConditionalApply |                                           |              1 |    1 |       0 |               0 |                 0 |               0.0000 |            |
| |\                    +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +SetProperty        | p.exists = true                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |                   +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +MergeCreateNode    | p                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +Optional             |                                           |              1 |    1 |       0 |               0 |                 0 |               0.0000 | p.name ASC |
| |                     +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +NodeIndexSeek        | p:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |               0 |                 1 |               0.0000 | p.name ASC |
+-----------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+

Total database accesses: 2, total allocated memory: 0

7.4.26. Roll Up Apply

The RollUpApply operator is used to execute an expression which takes as input a pattern, and returns a list with content from the matched pattern; for example, when using a pattern expression or pattern comprehension in a query. This operator is a variation of the Apply operator.

Query. 

CYPHER runtime=slotted
MATCH (p:Person)
RETURN p.name,[(p)-[:WORKS_IN]->(location)| location.name] AS cities

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+------------------+------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator         | Details                            | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+------------------+------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults  | `p.name`, cities                   |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                +------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection      | p.name AS `p.name`                 |             14 |   14 |      14 |               0 |                 0 |               0.0000 |
| |                +------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +RollUpApply     | cities, anon_32                    |             14 |   14 |       0 |               0 |                 0 |               0.0000 |
| |\               +------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Projection    | location.name AS anon_32           |              0 |   15 |      15 |               2 |                 0 |               1.0000 |
| | |              +------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)   | (p)-[anon_38:WORKS_IN]->(location) |              0 |   15 |      33 |              15 |                 0 |               1.0000 |
| | |              +------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument      | p                                  |              1 |   14 |       0 |               0 |                 0 |               0.0000 |
| |                +------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan | p:Person                           |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+------------------+------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 77, total allocated memory: 0

7.4.27. Argument

The Argument operator indicates the variable to be used as an argument to the right-hand side of an Apply operator.

Query. 

MATCH (s:Person { name: 'me' })
MERGE (s)-[:FRIENDS_WITH]->(s)

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+------------------------------+-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| Operator                     | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order      |
+------------------------------+-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +ProduceResults              |                                           |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +EmptyResult                 |                                           |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +Apply                       |                                           |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 | s.name ASC |
| |\                           +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +AntiConditionalApply      |                                           |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |\                         +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +MergeCreateRelationship | (s)-[anon_40:FRIENDS_WITH]->(s)           |              1 |    1 |       2 |                |               2 |                 0 |               1.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Argument                | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +AntiConditionalApply      |                                           |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |\                         +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Optional                | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Expand(Into)            | (s)-[anon_40:FRIENDS_WITH]->(s)           |              0 |    0 |       4 |            856 |               1 |                 0 |               1.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +LockNodes               | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Argument                | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +Optional                  | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +Expand(Into)              | (s)-[anon_40:FRIENDS_WITH]->(s)           |              0 |    0 |       4 |            856 |               2 |                 0 |               1.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +Argument                  | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +NodeIndexSeek               | s:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |                |               0 |                 1 |               0.0000 | s.name ASC |
+------------------------------+-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+

Total database accesses: 12, total allocated memory: 2920

7.4.28. Expand All

Given a start node, and depending on the pattern relationship, the Expand(All) operator will traverse incoming or outgoing relationships.

Query. 

MATCH (p:Person { name: 'me' })-[:FRIENDS_WITH]->(fof)
RETURN fof

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator        | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+-----------------+-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults | fof                                       |              0 |    1 |       0 |                | p.name ASC | Fused in Pipeline 0 |
| |               +-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +Expand(All)    | (p)-[anon_30:FRIENDS_WITH]->(fof)         |              0 |    1 |       3 |                | p.name ASC | Fused in Pipeline 0 |
| |               +-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeIndexSeek  | p:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |             64 | p.name ASC | Fused in Pipeline 0 |
+-----------------+-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 5, total allocated memory: 64

7.4.29. Expand Into

When both the start and end node have already been found, the Expand(Into) operator is used to find all relationships connecting the two nodes. As both the start and end node of the relationship are already in scope, the node with the smallest degree will be used. This can make a noticeable difference when dense nodes appear as end points.

Query. 

MATCH (p:Person { name: 'me' })-[:FRIENDS_WITH]->(fof)-->(p)
RETURN fof

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| Operator        | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Order      | Other               |
+-----------------+-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +ProduceResults | fof                                       |              0 |    0 |       0 |                | p.name ASC | Fused in Pipeline 0 |
| |               +-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +Filter         | not anon_30 = anon_53                     |              0 |    0 |       0 |                | p.name ASC | Fused in Pipeline 0 |
| |               +-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +Expand(Into)   | (p)-[anon_30:FRIENDS_WITH]->(fof)         |              0 |    0 |       0 |              0 | p.name ASC | Fused in Pipeline 0 |
| |               +-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +Expand(All)    | (p)<-[anon_53]-(fof)                      |              0 |    0 |       3 |                | p.name ASC | Fused in Pipeline 0 |
| |               +-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+
| +NodeIndexSeek  | p:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |             64 | p.name ASC | Fused in Pipeline 0 |
+-----------------+-------------------------------------------+----------------+------+---------+----------------+------------+---------------------+

Total database accesses: 5, total allocated memory: 64

7.4.30. Optional Expand All

The OptionalExpand(All) operator is analogous to Expand(All), apart from when no relationships match the direction, type and property predicates. In this situation, OptionalExpand(all) will return a single row with the relationship and end node set to null.

Query. 

MATCH (p:Person)
OPTIONAL MATCH (p)-[works_in:WORKS_IN]->(l)
WHERE works_in.duration > 180
RETURN p, l

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+----------------------+-------------------------------------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator             | Details                                                           | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+----------------------+-------------------------------------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults      | p, l                                                              |             14 |   15 |       0 |                | Fused in Pipeline 0 |
| |                    +-------------------------------------------------------------------+----------------+------+---------+----------------+---------------------+
| +OptionalExpand(All) | (p)-[works_in:WORKS_IN]->(l) WHERE works_in.duration > $autoint_0 |             14 |   15 |      48 |                | Fused in Pipeline 0 |
| |                    +-------------------------------------------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan     | p:Person                                                          |             14 |   14 |      15 |             64 | Fused in Pipeline 0 |
+----------------------+-------------------------------------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 63, total allocated memory: 64

7.4.31. Optional Expand Into

The OptionalExpand(Into) operator is analogous to Expand(Into), apart from when no matching relationships are found. In this situation, OptionalExpand(Into) will return a single row with the relationship and end node set to null. As both the start and end node of the relationship are already in scope, the node with the smallest degree will be used. This can make a noticeable difference when dense nodes appear as end points.

Query. 

MATCH (p:Person)-[works_in:WORKS_IN]->(l)
OPTIONAL MATCH (l)-->(p)
RETURN p

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+------------------------------+----------------+------+---------+----------------+---------------------+
| Operator              | Details                      | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------------+------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults       | p                            |             15 |   15 |       0 |                | Fused in Pipeline 0 |
| |                     +------------------------------+----------------+------+---------+----------------+---------------------+
| +OptionalExpand(Into) | (l)-[anon_61]->(p)           |             15 |   15 |     105 |           3208 | Fused in Pipeline 0 |
| |                     +------------------------------+----------------+------+---------+----------------+---------------------+
| +Expand(All)          | (p)-[works_in:WORKS_IN]->(l) |             15 |   15 |      33 |                | Fused in Pipeline 0 |
| |                     +------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan      | p:Person                     |             14 |   14 |      15 |             64 | Fused in Pipeline 0 |
+-----------------------+------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 153, total allocated memory: 3208

7.4.32. VarLength Expand All

Given a start node, the VarLengthExpand(All) operator will traverse variable-length relationships.

Query. 

MATCH (p:Person)-[:FRIENDS_WITH *1..2]-(q:Person)
RETURN p, q

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator              | Details                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------------+------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults       | p, q                               |              4 |    6 |       0 |                | Fused in Pipeline 0 |
| |                     +------------------------------------+----------------+------+---------+----------------+---------------------+
| +Filter               | q:Person                           |              4 |    6 |       6 |                | Fused in Pipeline 0 |
| |                     +------------------------------------+----------------+------+---------+----------------+---------------------+
| +VarLengthExpand(All) | (p)-[anon_17:FRIENDS_WITH*..2]-(q) |              4 |    6 |      47 |                | Fused in Pipeline 0 |
| |                     +------------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan      | p:Person                           |             14 |   14 |      15 |             64 | Fused in Pipeline 0 |
+-----------------------+------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 68, total allocated memory: 64

7.4.33. VarLength Expand Into

When both the start and end node have already been found, the VarLengthExpand(Into) operator is used to find all variable-length relationships connecting the two nodes.

Query. 

MATCH (p:Person)-[:FRIENDS_WITH *1..2]-(p:Person)
RETURN p

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------------+------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator               | Details                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+------------------------+------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults        | p                                  |              0 |    0 |       0 |                | Fused in Pipeline 0 |
| |                      +------------------------------------+----------------+------+---------+----------------+---------------------+
| +VarLengthExpand(Into) | (p)-[anon_17:FRIENDS_WITH*..2]-(p) |              0 |    0 |      47 |                | Fused in Pipeline 0 |
| |                      +------------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan       | p:Person                           |             14 |   14 |      15 |             64 | Fused in Pipeline 0 |
+------------------------+------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 62, total allocated memory: 64

7.4.34. VarLength Expand Pruning

Given a start node, the VarLengthExpand(Pruning) operator will traverse variable-length relationships much like the VarLengthExpand(All) operator. However, as an optimization, some paths will not be explored if they are guaranteed to produce an end node that has already been found (by means of a previous path traversal). This will only be used in cases where the individual paths are not of interest. This operator guarantees that all the end nodes produced will be unique.

Query. 

MATCH (p:Person)-[:FRIENDS_WITH *3..4]-(q:Person)
RETURN DISTINCT p, q

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+---------------------------+------------------------------+----------------+------+---------+----------------+-----------+---------------+
| Operator                  | Details                      | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Other         |
+---------------------------+------------------------------+----------------+------+---------+----------------+-----------+---------------+
| +ProduceResults           | p, q                         |              0 |    0 |       0 |                |     0.011 | In Pipeline 1 |
| |                         +------------------------------+----------------+------+---------+----------------+-----------+---------------+
| +Distinct                 | p, q                         |              0 |    0 |       0 |            176 |     0.842 | In Pipeline 1 |
| |                         +------------------------------+----------------+------+---------+----------------+-----------+---------------+
| +Filter                   | q:Person                     |              0 |    0 |       0 |                |     0.032 | In Pipeline 1 |
| |                         +------------------------------+----------------+------+---------+----------------+-----------+---------------+
| +VarLengthExpand(Pruning) | (p)-[:FRIENDS_WITH*3..4]-(q) |              0 |    0 |      32 |            896 |           | In Pipeline 1 |
| |                         +------------------------------+----------------+------+---------+----------------+-----------+---------------+
| +NodeByLabelScan          | p:Person                     |             14 |   14 |      15 |             64 |     0.088 | In Pipeline 0 |
+---------------------------+------------------------------+----------------+------+---------+----------------+-----------+---------------+

Total database accesses: 47, total allocated memory: 1072

7.4.35. Assert Same Node

The AssertSameNode operator is used to ensure that no unique constraints are violated. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. Owing to the existence of two unique constraints on :Team(name) and :Team(id), any node that would be found by the UniqueIndexSeek must be the very same node, or the constraints would be violated.

Query. 

MERGE (t:Team { name: 'Engineering', id: 42 })

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+---------------------------------+------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| Operator                        | Details                                        | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order      |
+---------------------------------+------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +ProduceResults                 |                                                |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                               +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +EmptyResult                    |                                                |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                               +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +AntiConditionalApply           |                                                |              1 |    1 |       0 |               0 |                 0 |               0.0000 |            |
| |\                              +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +MergeCreateNode              | t                                              |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                               +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +Optional                       |                                                |              1 |    1 |       0 |               0 |                 0 |               0.0000 | t.name ASC |
| |                               +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +AssertSameNode                 | t                                              |              0 |    1 |       0 |               0 |                 0 |               0.0000 | t.name ASC |
| |\                              +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +NodeUniqueIndexSeek(Locking) | UNIQUE t:Team(id) WHERE id = $autoint_1        |              1 |    1 |       1 |               0 |                 1 |               0.0000 | t.id ASC   |
| |                               +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +NodeUniqueIndexSeek(Locking)   | UNIQUE t:Team(name) WHERE name = $autostring_0 |              1 |    1 |       1 |               0 |                 1 |               0.0000 | t.name ASC |
+---------------------------------+------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+

Total database accesses: 2, total allocated memory: 0

7.4.36. Drop Result

The DropResult operator produces zero rows. It is applied when it can be deduced through static analysis that the result of an expression will be empty, such as when a predicate guaranteed to return false (e.g. 1 > 5) is used in a query.

Query. 

MATCH (p)
WHERE FALSE RETURN p

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+---------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+---------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults | p       |              0 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +---------+----------------+------+---------+-----------------+-------------------+----------------------+
| +DropResult     |         |              0 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +---------+----------------+------+---------+-----------------+-------------------+----------------------+
| +AllNodesScan   | p       |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
+-----------------+---------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 0, total allocated memory: 0

7.4.37. Empty Result

The EmptyResult operator eagerly loads all incoming data and discards it.

Query. 

CREATE (:Person)

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+-----------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details         | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+-----------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |                 |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +-----------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |                 |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +-----------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Create         | (anon_8:Person) |              1 |    1 |       1 |               0 |                 0 |               0.0000 |
+-----------------+-----------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 1, total allocated memory: 792

7.4.38. Produce Results

The ProduceResults operator prepares the result so that it is consumable by the user, such as transforming internal values to user values. It is present in every single query that returns data to the user, and has little bearing on performance optimisation.

Query. 

MATCH (n)
RETURN n

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+---------+----------------+------+---------+----------------+---------------------+
| Operator        | Details | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------+---------+----------------+------+---------+----------------+---------------------+
| +ProduceResults | n       |             35 |   35 |       0 |                | Fused in Pipeline 0 |
| |               +---------+----------------+------+---------+----------------+---------------------+
| +AllNodesScan   | n       |             35 |   35 |      36 |             64 | Fused in Pipeline 0 |
+-----------------+---------+----------------+------+---------+----------------+---------------------+

Total database accesses: 36, total allocated memory: 64

7.4.39. Load CSV

The LoadCSV operator loads data from a CSV source into the query. It is used whenever the LOAD CSV clause is used in a query.

Query. 

LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.3/csv/artists.csv' AS line
RETURN line

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+---------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+---------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults | line    |              1 |    4 |       0 |               0 |                 0 |               0.0000 |
| |               +---------+----------------+------+---------+-----------------+-------------------+----------------------+
| +LoadCSV        | line    |              1 |    4 |       0 |               0 |                 0 |               0.0000 |
+-----------------+---------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 0, total allocated memory: 0

7.4.40. Hash joins in general

Hash joins have two inputs: the build input and probe input. The query planner assigns these roles so that the smaller of the two inputs is the build input. The build input is pulled in eagerly, and is used to build a probe table. Once this is complete, the probe table is checked for each row coming from the probe input side.

In query plans, the build input is always the left operator, and the probe input the right operator.

There are four hash join operators:

7.4.41. Node Hash Join

The NodeHashJoin operator is a variation of the hash join. NodeHashJoin executes the hash join on node ids. As primitive types and arrays can be used, it can be done very efficiently.

Query. 

MATCH (bob:Person { name:'Bob' })-[:WORKS_IN]->(loc)<-[:WORKS_IN]-(matt:Person { name:'Mattis' })
RETURN loc.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| Operator         | Details                                      | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order         | Other               |
+------------------+----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| +ProduceResults  | `loc.name`                                   |             10 |    0 |       0 |                |     0.000 | matt.name ASC | In Pipeline 2       |
| |                +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| +Projection      | loc.name AS `loc.name`                       |             10 |    0 |       0 |                |     0.000 | matt.name ASC | In Pipeline 2       |
| |                +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| +Filter          | not anon_32 = anon_51                        |             10 |    0 |       0 |                |     0.000 | matt.name ASC | In Pipeline 2       |
| |                +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| +NodeHashJoin    | loc                                          |             10 |    0 |       0 |            472 |     0.024 | matt.name ASC | In Pipeline 2       |
| |\               +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| | +Expand(All)   | (matt)-[anon_51:WORKS_IN]->(loc)             |             19 |    0 |       0 |                |           | matt.name ASC | Fused in Pipeline 1 |
| | |              +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| | +NodeIndexSeek | matt:Person(name) WHERE name = $autostring_1 |              1 |    0 |       1 |             64 |           | matt.name ASC | Fused in Pipeline 1 |
| |                +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| +Expand(All)     | (bob)-[anon_32:WORKS_IN]->(loc)              |             19 |    1 |       3 |                |           | bob.name ASC  | Fused in Pipeline 0 |
| |                +----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+
| +NodeIndexSeek   | bob:Person(name) WHERE name = $autostring_0  |              1 |    1 |       2 |             64 |           | bob.name ASC  | Fused in Pipeline 0 |
+------------------+----------------------------------------------+----------------+------+---------+----------------+-----------+---------------+---------------------+

Total database accesses: 6, total allocated memory: 536

7.4.42. Value Hash Join

The ValueHashJoin operator is a variation of the hash join. This operator allows for arbitrary values to be used as the join key. It is most frequently used to solve predicates of the form: n.prop1 = m.prop2 (i.e. equality predicates between two property columns).

Query. 

MATCH (p:Person),(q:Person)
WHERE p.age = q.age
RETURN p,q

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+--------------------+---------------+----------------+------+---------+----------------+-----------+---------------+
| Operator           | Details       | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Other         |
+--------------------+---------------+----------------+------+---------+----------------+-----------+---------------+
| +ProduceResults    | p, q          |              0 |    0 |       0 |                |     0.011 | In Pipeline 2 |
| |                  +---------------+----------------+------+---------+----------------+-----------+---------------+
| +ValueHashJoin     | p.age = q.age |              0 |    0 |       0 |            408 |     0.180 | In Pipeline 2 |
| |\                 +---------------+----------------+------+---------+----------------+-----------+---------------+
| | +NodeByLabelScan | q:Person      |             14 |   14 |      15 |             64 |     0.069 | In Pipeline 1 |
| |                  +---------------+----------------+------+---------+----------------+-----------+---------------+
| +NodeByLabelScan   | p:Person      |             14 |   14 |      15 |             64 |     0.132 | In Pipeline 0 |
+--------------------+---------------+----------------+------+---------+----------------+-----------+---------------+

Total database accesses: 30, total allocated memory: 408

7.4.43. Node Left/Right Outer Hash Join

The NodeLeftOuterHashJoin and NodeRightOuterHashJoin operators are variations of the hash join. The query below can be planned with either a left or a right outer join. The decision depends on the cardinalities of the left-hand and right-hand sides; i.e. how many rows would be returned, respectively, for (a:Person) and (a)-→(b:Person). If (a:Person) returns fewer results than (a)-→(b:Person), a left outer join — indicated by NodeLeftOuterHashJoin — is planned. On the other hand, if (a:Person) returns more results than (a)-→(b:Person), a right outer join — indicated by NodeRightOuterHashJoin — is planned instead.

Query. 

MATCH (a:Person)
OPTIONAL MATCH (a)-->(b:Person)
USING JOIN ON a
RETURN a.name, b.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-------------------------+------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| Operator                | Details                                              | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-------------------------+------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +ProduceResults         | `a.name`, `b.name`                                   |             14 |   14 |       0 |                |               0 |                 0 |               0.0000 |
| |                       +------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Projection             | cache[a.name] AS `a.name`, cache[b.name] AS `b.name` |             14 |   14 |      12 |                |               0 |                 0 |               0.0000 |
| |                       +------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +NodeRightOuterHashJoin | a                                                    |             14 |   14 |       0 |           1112 |               0 |                 0 |               0.0000 |
| |\                      +------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| | +NodeByLabelScan      | a:Person                                             |             14 |   14 |      15 |                |               2 |                 0 |               1.0000 |
| |                       +------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +CacheProperties        | cache[a.name], cache[b.name]                         |              2 |    2 |       4 |                |               2 |                 0 |               1.0000 |
| |                       +------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Expand(All)            | (b)<-[anon_36]-(a)                                   |              2 |    2 |      33 |                |              15 |                 0 |               1.0000 |
| |                       +------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +NodeByLabelScan        | b:Person                                             |             14 |   14 |      15 |                |               2 |                 0 |               1.0000 |
+-------------------------+------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+

Total database accesses: 79, total allocated memory: 1112

7.4.44. Triadic Selection

The TriadicSelection operator is used to solve triangular queries, such as the very common 'find my friend-of-friends that are not already my friend'. It does so by putting all the friends into a set, and uses the set to check if the friend-of-friends are already connected to me. The example finds the names of all friends of my friends that are not already my friends.

Query. 

MATCH (me:Person)-[:FRIENDS_WITH]-()-[:FRIENDS_WITH]-(other)
WHERE NOT (me)-[:FRIENDS_WITH]-(other)
RETURN other.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-------------------+------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator          | Details                                  | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-------------------+------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults   | `other.name`                             |              0 |    2 |       0 |               0 |                 0 |               0.0000 |
| |                 +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection       | other.name AS `other.name`               |              0 |    2 |       2 |               2 |                 0 |               1.0000 |
| |                 +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +TriadicSelection | WHERE NOT (me)--(other)                  |              0 |    2 |       0 |               0 |                 0 |               0.0000 |
| |\                +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Filter         | not anon_18 = anon_37                    |              0 |    2 |       0 |               0 |                 0 |               0.0000 |
| | |               +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Expand(All)    | (anon_35)-[anon_37:FRIENDS_WITH]-(other) |              0 |    6 |      14 |               4 |                 0 |               1.0000 |
| | |               +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument       | me, anon_18, anon_35                     |              4 |    4 |       0 |               0 |                 0 |               0.0000 |
| |                 +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Expand(All)      | (me)-[anon_18:FRIENDS_WITH]-(anon_35)    |              4 |    4 |      33 |              15 |                 0 |               1.0000 |
| |                 +------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan  | me:Person                                |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+-------------------+------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 64, total allocated memory: 0

7.4.45. Cartesian Product

The CartesianProduct operator produces a cartesian product of the two inputs — each row coming from the left child operator will be combined with all the rows from the right child operator. CartesianProduct generally exhibits bad performance and ought to be avoided if possible.

Query. 

MATCH (p:Person),(t:Team)
RETURN p, t

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+--------------------+----------+----------------+------+---------+----------------+-----------+---------------+
| Operator           | Details  | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Other         |
+--------------------+----------+----------------+------+---------+----------------+-----------+---------------+
| +ProduceResults    | p, t     |            140 |  140 |       0 |                |     2.298 | In Pipeline 2 |
| |                  +----------+----------------+------+---------+----------------+-----------+---------------+
| +CartesianProduct  |          |            140 |  140 |       0 |            280 |     0.889 | In Pipeline 2 |
| |\                 +----------+----------------+------+---------+----------------+-----------+---------------+
| | +NodeByLabelScan | p:Person |             14 |   14 |      15 |             80 |     0.046 | In Pipeline 1 |
| |                  +----------+----------------+------+---------+----------------+-----------+---------------+
| +NodeByLabelScan   | t:Team   |             10 |   10 |      11 |             64 |     0.111 | In Pipeline 0 |
+--------------------+----------+----------------+------+---------+----------------+-----------+---------------+

Total database accesses: 26, total allocated memory: 280

7.4.46. Foreach

The Foreach operator executes a nested loop between the left child operator and the right child operator. In an analogous manner to the Apply operator, it takes a row from the left-hand side and, using the Argument operator, provides it to the operator tree on the right-hand side. Foreach will yield all the rows coming in from the left-hand side; all results from the right-hand side are pulled in and discarded.

Query. 

FOREACH (value IN [1,2,3]| CREATE (:Person { age: value }))

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details            | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |                    |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |                    |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Foreach        | value IN [1, 2, 3] |              1 |    1 |       0 |               0 |                 0 |               0.0000 |
| |\              +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Create       | (anon_36:Person)   |              1 |    3 |       9 |               0 |                 0 |               0.0000 |
| | |             +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument     | value              |              1 |    3 |       0 |               0 |                 0 |               0.0000 |
| |               +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyRow       |                    |              1 |    1 |       0 |               0 |                 0 |               0.0000 |
+-----------------+--------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 9, total allocated memory: 968

7.4.47. Eager

For isolation purposes, the Eager operator ensures that operations affecting subsequent operations are executed fully for the whole dataset before continuing execution. Information from the stores is fetched in a lazy manner; i.e. the pattern matching might not be fully exhausted before updates are applied. To guarantee reasonable semantics, the query planner will insert Eager operators into the query plan to prevent updates from influencing pattern matching; this scenario is exemplified by the query below, where the DELETE clause influences the MATCH clause. The Eager operator can cause high memory usage when importing data or migrating graph structures. In such cases, the operations should be split into simpler steps; e.g. importing nodes and relationships separately. Alternatively, the records to be updated can be returned, followed by an update statement.

Query. 

MATCH (a)-[r]-(b)
DELETE r,a,b
MERGE ()

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-------------------------+-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| Operator                | Details     | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-------------------------+-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +ProduceResults         |             |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +EmptyResult            |             |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Apply                  |             |              1 |  504 |       0 |                |               0 |                 0 |               0.0000 |
| |\                      +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| | +AntiConditionalApply |             |              1 |  504 |       0 |                |               0 |                 0 |               0.0000 |
| | |\                    +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| | | +MergeCreateNode    | anon_38     |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |
| | |                     +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| | +Optional             |             |             35 |  504 |       0 |                |               0 |                 0 |               0.0000 |
| | |                     +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| | +AllNodesScan         | anon_38     |             35 |  504 |     540 |                |               0 |                 0 |               0.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Eager                  |             |             36 |   36 |       0 |           7432 |               0 |                 0 |               0.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Delete                 | b           |             36 |   36 |       9 |                |               0 |                 0 |               0.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Delete                 | a           |             36 |   36 |      12 |                |               1 |                 0 |               1.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Delete                 | r           |             36 |   36 |      18 |                |              19 |                 0 |               1.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Eager                  |             |             36 |   36 |       0 |           7432 |               0 |                 0 |               0.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +Expand(All)            | (a)-[r]-(b) |             36 |   36 |      71 |                |              22 |                 0 |               1.0000 |
| |                       +-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+
| +AllNodesScan           | a           |             35 |   35 |      36 |                |               1 |                 0 |               1.0000 |
+-------------------------+-------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+

Total database accesses: 686, total allocated memory: 29544

7.4.48. Eager Aggregation

The EagerAggregation operator evaluates a grouping expression and uses the result to group rows into different groupings. For each of these groupings, EagerAggregation will then evaluate all aggregation functions and return the result. To do this, EagerAggregation, as the name implies, needs to pull in all data eagerly from its source and build up state, which leads to increased memory pressure in the system.

Query. 

MATCH (l:Location)<-[:WORKS_IN]-(p:Person)
RETURN l.name AS location, collect(p.name) AS people

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-------------------+------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| Operator          | Details                                              | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Other               |
+-------------------+------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| +ProduceResults   | location, people                                     |              4 |    6 |       0 |                |     0.208 | In Pipeline 1       |
| |                 +------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| +EagerAggregation | cache[l.name] AS location, collect(p.name) AS people |              4 |    6 |      30 |           2388 |     0.070 | Fused in Pipeline 0 |
| |                 +------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| +Filter           | p:Person                                             |             15 |   15 |      15 |                |           | Fused in Pipeline 0 |
| |                 +------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| +Expand(All)      | (l)<-[anon_19:WORKS_IN]-(p)                          |             15 |   15 |      26 |                |           | Fused in Pipeline 0 |
| |                 +------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| +CacheProperties  | cache[l.name]                                        |             10 |   10 |      20 |                |           | Fused in Pipeline 0 |
| |                 +------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+
| +NodeByLabelScan  | l:Location                                           |             10 |   10 |      11 |             64 |           | Fused in Pipeline 0 |
+-------------------+------------------------------------------------------+----------------+------+---------+----------------+-----------+---------------------+

Total database accesses: 102, total allocated memory: 2388

7.4.49. Ordered Aggregation

The OrderedAggregation operator is an optimization of the EagerAggregation operator that takes advantage of the ordering of the incoming rows. This operator uses lazy evaluation and has a lower memory pressure in the system than the EagerAggregation operator.

Query. 

MATCH (p:Person)
WHERE p.name STARTS WITH 'P'
RETURN p.name, count(*) AS count

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| Operator              | Details                                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order      | Other         |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +ProduceResults       | `p.name`, count                                                    |              0 |    2 |       0 |                |     0.120 | p.name ASC | In Pipeline 1 |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +OrderedAggregation   | cache[p.name] AS `p.name`, count(*) AS count                       |              0 |    2 |       0 |            200 |     0.160 | p.name ASC | In Pipeline 1 |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +NodeIndexSeekByRange | p:Person(name) WHERE name STARTS WITH $autostring_0, cache[p.name] |              0 |    2 |       3 |             64 |     1.014 | p.name ASC | In Pipeline 0 |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+

Total database accesses: 3, total allocated memory: 200

7.4.50. Node Count From Count Store

The NodeCountFromCountStore operator uses the count store to answer questions about node counts. This is much faster than the EagerAggregation operator which achieves the same result by actually counting. However, as the count store only stores a limited range of combinations, EagerAggregation will still be used for more complex queries. For example, we can get counts for all nodes, and nodes with a label, but not nodes with more than one label.

Query. 

MATCH (p:Person)
RETURN count(p) AS people

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+--------------------------+------------------------------+----------------+------+---------+----------------+---------------------+
| Operator                 | Details                      | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+--------------------------+------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults          | people                       |              1 |    1 |       0 |                | Fused in Pipeline 0 |
| |                        +------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeCountFromCountStore | count( (:Person) ) AS people |              1 |    1 |       1 |             64 | Fused in Pipeline 0 |
+--------------------------+------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.51. Relationship Count From Count Store

The RelationshipCountFromCountStore operator uses the count store to answer questions about relationship counts. This is much faster than the EagerAggregation operator which achieves the same result by actually counting. However, as the count store only stores a limited range of combinations, EagerAggregation will still be used for more complex queries. For example, we can get counts for all relationships, relationships with a type, relationships with a label on one end, but not relationships with labels on both end nodes.

Query. 

MATCH (p:Person)-[r:WORKS_IN]->()
RETURN count(r) AS jobs

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+----------------------------------+--------------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator                         | Details                                    | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+----------------------------------+--------------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults                  | jobs                                       |              1 |    1 |       0 |                | Fused in Pipeline 0 |
| |                                +--------------------------------------------+----------------+------+---------+----------------+---------------------+
| +RelationshipCountFromCountStore | count( (:Person)-[:WORKS_IN]->() ) AS jobs |              1 |    1 |       1 |             64 | Fused in Pipeline 0 |
+----------------------------------+--------------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 1, total allocated memory: 64

7.4.52. Distinct

The Distinct operator removes duplicate rows from the incoming stream of rows. To ensure only distinct elements are returned, Distinct will pull in data lazily from its source and build up state. This may lead to increased memory pressure in the system.

Query. 

MATCH (l:Location)<-[:WORKS_IN]-(p:Person)
RETURN DISTINCT l

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+-----------------------------+----------------+------+---------+----------------+---------------------+
| Operator         | Details                     | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+------------------+-----------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults  | l                           |             14 |    6 |       0 |                | Fused in Pipeline 0 |
| |                +-----------------------------+----------------+------+---------+----------------+---------------------+
| +Distinct        | l                           |             14 |    6 |       0 |            192 | Fused in Pipeline 0 |
| |                +-----------------------------+----------------+------+---------+----------------+---------------------+
| +Filter          | p:Person                    |             15 |   15 |      15 |                | Fused in Pipeline 0 |
| |                +-----------------------------+----------------+------+---------+----------------+---------------------+
| +Expand(All)     | (l)<-[anon_19:WORKS_IN]-(p) |             15 |   15 |      26 |                | Fused in Pipeline 0 |
| |                +-----------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan | l:Location                  |             10 |   10 |      11 |             64 | Fused in Pipeline 0 |
+------------------+-----------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 52, total allocated memory: 192

7.4.53. Ordered Distinct

The OrderedDistinct operator is an optimization of the Distinct operator that takes advantage of the ordering of the incoming rows. This operator has a lower memory pressure in the system than the Distinct operator.

Query. 

MATCH (p:Person)
WHERE p.name STARTS WITH 'P'
RETURN DISTINCT p.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| Operator              | Details                                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order      | Other         |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +ProduceResults       | `p.name`                                                           |              0 |    2 |       0 |                |     0.064 | p.name ASC | In Pipeline 0 |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +OrderedDistinct      | cache[p.name] AS `p.name`                                          |              0 |    2 |       0 |                |     0.702 | p.name ASC | In Pipeline 0 |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +NodeIndexSeekByRange | p:Person(name) WHERE name STARTS WITH $autostring_0, cache[p.name] |              0 |    2 |       3 |             64 |     0.228 | p.name ASC | In Pipeline 0 |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+

Total database accesses: 3, total allocated memory: 64

7.4.54. Filter

The Filter operator filters each row coming from the child operator, only passing through rows that evaluate the predicates to true.

Query. 

MATCH (p:Person)
WHERE p.name =~ '^a.*'
RETURN p

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+--------------------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator        | Details                                          | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+-----------------+--------------------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults | p                                                |             14 |    0 |       0 |                | Fused in Pipeline 0 |
| |               +--------------------------------------------------+----------------+------+---------+----------------+---------------------+
| +Filter         | cache[p.name] =~ $autostring_0                   |             14 |    0 |       0 |                | Fused in Pipeline 0 |
| |               +--------------------------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeIndexScan  | p:Person(name) WHERE exists(name), cache[p.name] |             14 |   14 |      15 |             64 | Fused in Pipeline 0 |
+-----------------+--------------------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 15, total allocated memory: 64

7.4.55. Limit

The Limit operator returns the first 'n' rows from the incoming input.

Query. 

MATCH (p:Person)
RETURN p
LIMIT 3

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+----------+----------------+------+---------+----------------+---------------------+
| Operator         | Details  | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+------------------+----------+----------------+------+---------+----------------+---------------------+
| +ProduceResults  | p        |              3 |    3 |       0 |                | Fused in Pipeline 0 |
| |                +----------+----------------+------+---------+----------------+---------------------+
| +Limit           | 3        |              3 |    3 |       0 |                | Fused in Pipeline 0 |
| |                +----------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan | p:Person |             14 |    4 |       5 |             64 | Fused in Pipeline 0 |
+------------------+----------+----------------+------+---------+----------------+---------------------+

Total database accesses: 5, total allocated memory: 64

7.4.56. Skip

The Skip operator skips 'n' rows from the incoming rows.

Query. 

MATCH (p:Person)
RETURN p
ORDER BY p.id
SKIP 1

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+----------------+----------------+------+---------+----------------+-----------+----------+---------------------+
| Operator         | Details        | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order    | Other               |
+------------------+----------------+----------------+------+---------+----------------+-----------+----------+---------------------+
| +ProduceResults  | p              |             14 |   13 |       0 |                |     0.308 | p.id ASC | In Pipeline 1       |
| |                +----------------+----------------+------+---------+----------------+-----------+----------+---------------------+
| +Skip            | $autoint_0     |             14 |   13 |       0 |                |     0.476 | p.id ASC | In Pipeline 1       |
| |                +----------------+----------------+------+---------+----------------+-----------+----------+---------------------+
| +Sort            | `p.id` ASC     |             14 |   14 |       0 |            344 |     0.138 | p.id ASC | In Pipeline 1       |
| |                +----------------+----------------+------+---------+----------------+-----------+----------+---------------------+
| +Projection      | p.id AS `p.id` |             14 |   14 |      28 |                |           |          | Fused in Pipeline 0 |
| |                +----------------+----------------+------+---------+----------------+-----------+----------+---------------------+
| +NodeByLabelScan | p:Person       |             14 |   14 |      15 |             64 |           |          | Fused in Pipeline 0 |
+------------------+----------------+----------------+------+---------+----------------+-----------+----------+---------------------+

Total database accesses: 43, total allocated memory: 344

7.4.57. Sort

The Sort operator sorts rows by a provided key. In order to sort the data, all data from the source operator needs to be pulled in eagerly and kept in the query state, which will lead to increased memory pressure in the system.

Query. 

MATCH (p:Person)
RETURN p
ORDER BY p.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+--------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| Operator         | Details            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order      | Other               |
+------------------+--------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +ProduceResults  | p                  |             14 |   14 |       0 |                |     0.292 | p.name ASC | In Pipeline 1       |
| |                +--------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +Sort            | `p.name` ASC       |             14 |   14 |       0 |           1136 |     0.212 | p.name ASC | In Pipeline 1       |
| |                +--------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +Projection      | p.name AS `p.name` |             14 |   14 |      28 |                |           |            | Fused in Pipeline 0 |
| |                +--------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +NodeByLabelScan | p:Person           |             14 |   14 |      15 |             64 |           |            | Fused in Pipeline 0 |
+------------------+--------------------+----------------+------+---------+----------------+-----------+------------+---------------------+

Total database accesses: 43, total allocated memory: 1136

7.4.58. Partial Sort

The PartialSort operator is an optimization of the Sort operator that takes advantage of the ordering of the incoming rows. This operator uses lazy evaluation and has a lower memory pressure in the system than the Sort operator. Partial sort is only applicable when sorting on multiple columns.

Query. 

MATCH (p:Person)
WHERE p.name STARTS WITH 'P'
RETURN p
ORDER BY p.name, p.age

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| Operator              | Details                                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order                 | Other               |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +ProduceResults       | p                                                                  |              0 |    2 |       0 |                |     0.164 | p.name ASC, p.age ASC | In Pipeline 1       |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +PartialSort          | `p.name` ASC, `p.age` ASC                                          |              0 |    2 |       0 |            600 |     0.499 | p.name ASC, p.age ASC | In Pipeline 1       |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +Projection           | cache[p.name] AS `p.name`, p.age AS `p.age`                        |              0 |    2 |       0 |                |           | p.name ASC            | Fused in Pipeline 0 |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +NodeIndexSeekByRange | p:Person(name) WHERE name STARTS WITH $autostring_0, cache[p.name] |              0 |    2 |       3 |             64 |           | p.name ASC            | Fused in Pipeline 0 |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+

Total database accesses: 3, total allocated memory: 600

7.4.59. Top

The Top operator returns the first 'n' rows sorted by a provided key. Instead of sorting the entire input, only the top 'n' rows are retained.

Query. 

MATCH (p:Person)
RETURN p
ORDER BY p.name
LIMIT 2

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+----------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| Operator         | Details              | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order      | Other               |
+------------------+----------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +ProduceResults  | p                    |              2 |    2 |       0 |                |     0.132 | p.name ASC | In Pipeline 1       |
| |                +----------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +Top             | `p.name` ASC LIMIT 2 |              2 |    2 |       0 |           1088 |     0.643 | p.name ASC | In Pipeline 1       |
| |                +----------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +Projection      | p.name AS `p.name`   |             14 |   14 |      28 |                |           |            | Fused in Pipeline 0 |
| |                +----------------------+----------------+------+---------+----------------+-----------+------------+---------------------+
| +NodeByLabelScan | p:Person             |             14 |   14 |      15 |             64 |           |            | Fused in Pipeline 0 |
+------------------+----------------------+----------------+------+---------+----------------+-----------+------------+---------------------+

Total database accesses: 43, total allocated memory: 1088

7.4.60. Partial Top

The PartialTop operator is an optimization of the Top operator that takes advantage of the ordering of the incoming rows. This operator uses lazy evaluation and has a lower memory pressure in the system than the Top operator. Partial top is only applicable when sorting on multiple columns.

Query. 

MATCH (p:Person)
WHERE p.name STARTS WITH 'P'
RETURN p
ORDER BY p.name, p.age
LIMIT 2

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| Operator              | Details                                                            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order                 | Other               |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +ProduceResults       | p                                                                  |              0 |    2 |       0 |                |     0.125 | p.name ASC, p.age ASC | In Pipeline 1       |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +PartialTop           | `p.name` ASC, `p.age` ASC LIMIT 2                                  |              0 |    2 |       0 |            344 |     0.542 | p.name ASC, p.age ASC | In Pipeline 1       |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +Projection           | cache[p.name] AS `p.name`, p.age AS `p.age`                        |              0 |    2 |       0 |                |           | p.name ASC            | Fused in Pipeline 0 |
| |                     +--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+
| +NodeIndexSeekByRange | p:Person(name) WHERE name STARTS WITH $autostring_0, cache[p.name] |              0 |    2 |       3 |             64 |           | p.name ASC            | Fused in Pipeline 0 |
+-----------------------+--------------------------------------------------------------------+----------------+------+---------+----------------+-----------+-----------------------+---------------------+

Total database accesses: 3, total allocated memory: 344

7.4.61. Union

The Union operator concatenates the results from the right child operator with the results from the left child operator.

Query. 

MATCH (p:Location)
RETURN p.name
UNION ALL MATCH (p:Country)
RETURN p.name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+--------------------+--------------------+----------------+------+---------+----------------+---------------------+
| Operator           | Details            | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+--------------------+--------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults    | `p.name`           |             20 |   11 |       0 |                | Fused in Pipeline 2 |
| |                  +--------------------+----------------+------+---------+----------------+---------------------+
| +Union             |                    |             20 |   11 |       0 |            760 | Fused in Pipeline 2 |
| |\                 +--------------------+----------------+------+---------+----------------+---------------------+
| | +Projection      | `p.name`           |             10 |    1 |       0 |                | Fused in Pipeline 1 |
| | |                +--------------------+----------------+------+---------+----------------+---------------------+
| | +Projection      | p.name AS `p.name` |             10 |    1 |       2 |                | Fused in Pipeline 1 |
| | |                +--------------------+----------------+------+---------+----------------+---------------------+
| | +NodeByLabelScan | p:Country          |             10 |    1 |       2 |             64 | Fused in Pipeline 1 |
| |                  +--------------------+----------------+------+---------+----------------+---------------------+
| +Projection        | `p.name`           |             10 |   10 |       0 |                | Fused in Pipeline 0 |
| |                  +--------------------+----------------+------+---------+----------------+---------------------+
| +Projection        | p.name AS `p.name` |             10 |   10 |      20 |                | Fused in Pipeline 0 |
| |                  +--------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan   | p:Location         |             10 |   10 |      11 |             64 | Fused in Pipeline 0 |
+--------------------+--------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 35, total allocated memory: 824

7.4.62. Unwind

The Unwind operator returns one row per item in a list.

Query. 

UNWIND range(1, 5) AS value
RETURN value

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+----------------------------------------+----------------+------+---------+---------------------+
| Operator        | Details                                | Estimated Rows | Rows | DB Hits | Other               |
+-----------------+----------------------------------------+----------------+------+---------+---------------------+
| +ProduceResults | value                                  |             10 |    5 |       0 | Fused in Pipeline 0 |
| |               +----------------------------------------+----------------+------+---------+---------------------+
| +Unwind         | range($autoint_0, $autoint_1) AS value |             10 |    5 |       0 | Fused in Pipeline 0 |
+-----------------+----------------------------------------+----------------+------+---------+---------------------+

Total database accesses: 0, total allocated memory: 64

7.4.63. Lock Nodes

The LockNodes operator locks the start and end node when creating a relationship.

Query. 

MATCH (s:Person { name: 'me' })
MERGE (s)-[:FRIENDS_WITH]->(s)

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+------------------------------+-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| Operator                     | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order      |
+------------------------------+-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +ProduceResults              |                                           |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +EmptyResult                 |                                           |              1 |    0 |       0 |                |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +Apply                       |                                           |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 | s.name ASC |
| |\                           +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +AntiConditionalApply      |                                           |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |\                         +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +MergeCreateRelationship | (s)-[anon_40:FRIENDS_WITH]->(s)           |              1 |    1 |       2 |                |               2 |                 0 |               1.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Argument                | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +AntiConditionalApply      |                                           |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |\                         +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Optional                | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Expand(Into)            | (s)-[anon_40:FRIENDS_WITH]->(s)           |              0 |    0 |       4 |            856 |               1 |                 0 |               1.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +LockNodes               | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | | +Argument                | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +Optional                  | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +Expand(Into)              | (s)-[anon_40:FRIENDS_WITH]->(s)           |              0 |    0 |       4 |            856 |               2 |                 0 |               1.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| | +Argument                  | s                                         |              1 |    1 |       0 |                |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+
| +NodeIndexSeek               | s:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |                |               0 |                 1 |               0.0000 | s.name ASC |
+------------------------------+-------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+------------+

Total database accesses: 12, total allocated memory: 2920

7.4.64. Optional

The Optional operator is used to solve some OPTIONAL MATCH queries. It will pull data from its source, simply passing it through if any data exists. However, if no data is returned by its source, Optional will yield a single row with all columns set to null.

Query. 

MATCH (p:Person { name:'me' })
OPTIONAL MATCH (q:Person { name: 'Lulu' })
RETURN p, q

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| Operator         | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order      | Other         |
+------------------+-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +ProduceResults  | p, q                                      |              1 |    1 |       0 |                |     0.138 | p.name ASC | In Pipeline 2 |
| |                +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +Apply           |                                           |              1 |    1 |       0 |                |     0.008 | p.name ASC |               |
| |\               +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| | +Optional      | p                                         |              1 |    1 |       0 |              0 |     0.334 | q.name ASC | In Pipeline 2 |
| | |              +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| | +NodeIndexSeek | q:Person(name) WHERE name = $autostring_1 |              1 |    0 |       1 |             72 |     0.092 | q.name ASC | In Pipeline 1 |
| |                +-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+
| +NodeIndexSeek   | p:Person(name) WHERE name = $autostring_0 |              1 |    1 |       2 |             64 |     2.898 | p.name ASC | In Pipeline 0 |
+------------------+-------------------------------------------+----------------+------+---------+----------------+-----------+------------+---------------+

Total database accesses: 3, total allocated memory: 72

7.4.65. Project Endpoints

The ProjectEndpoints operator projects the start and end node of a relationship.

Query. 

CREATE (n)-[p:KNOWS]->(m)
WITH p AS r
MATCH (u)-[r]->(v)
RETURN u, v

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+---------------------+------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator            | Details                      | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+---------------------+------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults     | u, v                         |             18 |    1 |       0 |               0 |                 0 |               0.0000 |
| |                   +------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Apply              |                              |             18 |    1 |       0 |               0 |                 0 |               0.0000 |
| |\                  +------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +ProjectEndpoints | (u)-[r*]->(v)                |             18 |    1 |       0 |               0 |                 0 |               0.0000 |
| | |                 +------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument         | r                            |              1 |    1 |       0 |               0 |                 0 |               0.0000 |
| |                   +------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Projection         | p AS r                       |              1 |    1 |       0 |               0 |                 0 |               0.0000 |
| |                   +------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Create             | (n), (m), (n)-[p:KNOWS]->(m) |              1 |    1 |       4 |               0 |                 0 |               0.0000 |
+---------------------+------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 4, total allocated memory: 2056

7.4.66. Projection

For each incoming row, the Projection operator evaluates a set of expressions and produces a row with the results of the expressions.

Query. 

RETURN 'hello' AS greeting

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+---------------------------+----------------+------+---------+---------------------+
| Operator        | Details                   | Estimated Rows | Rows | DB Hits | Other               |
+-----------------+---------------------------+----------------+------+---------+---------------------+
| +ProduceResults | greeting                  |              1 |    1 |       0 | Fused in Pipeline 0 |
| |               +---------------------------+----------------+------+---------+---------------------+
| +Projection     | $autostring_0 AS greeting |              1 |    1 |       0 | Fused in Pipeline 0 |
+-----------------+---------------------------+----------------+------+---------+---------------------+

Total database accesses: 0, total allocated memory: 64

7.4.67. Empty Row

The EmptyRow operator returns a single row with no columns.

Query. 

FOREACH (value IN [1,2,3]| CREATE (:Person { age: value }))

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details            | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |                    |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |                    |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Foreach        | value IN [1, 2, 3] |              1 |    1 |       0 |               0 |                 0 |               0.0000 |
| |\              +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Create       | (anon_36:Person)   |              1 |    3 |       9 |               0 |                 0 |               0.0000 |
| | |             +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| | +Argument     | value              |              1 |    3 |       0 |               0 |                 0 |               0.0000 |
| |               +--------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyRow       |                    |              1 |    1 |       0 |               0 |                 0 |               0.0000 |
+-----------------+--------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 9, total allocated memory: 968

7.4.68. Procedure Call

The ProcedureCall operator indicates an invocation to a procedure.

Query. 

CALL db.labels() YIELD label
RETURN *
ORDER BY label

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+-----------------+-----------------------------------+----------------+------+---------+----------------+-----------+-----------+---------------+
| Operator        | Details                           | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Time (ms) | Order     | Other         |
+-----------------+-----------------------------------+----------------+------+---------+----------------+-----------+-----------+---------------+
| +ProduceResults | label                             |          10000 |    4 |       0 |                |     0.160 | label ASC | In Pipeline 2 |
| |               +-----------------------------------+----------------+------+---------+----------------+-----------+-----------+---------------+
| +Sort           | label ASC                         |          10000 |    4 |       0 |            480 |     0.173 | label ASC | In Pipeline 2 |
| |               +-----------------------------------+----------------+------+---------+----------------+-----------+-----------+---------------+
| +ProcedureCall  | db.labels() :: (label :: STRING?) |          10000 |    4 |         |             56 |           |           | In Pipeline 1 |
+-----------------+-----------------------------------+----------------+------+---------+----------------+-----------+-----------+---------------+

Total database accesses: ?, total allocated memory: 480

7.4.69. Cache Properties

The CacheProperties operator reads nodes and relationship properties and caches them in the current row. Future accesses to these properties can avoid reading from the store which will speed up the query. In the plan below we will cache l.name before Expand(All) where there are fewer rows.

Query. 

MATCH (l:Location)<-[:WORKS_IN]-(p:Person)
RETURN l.name AS location, p.name AS name

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime PIPELINED

Runtime version 4.1

+------------------+-------------------------------------------+----------------+------+---------+----------------+---------------------+
| Operator         | Details                                   | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Other               |
+------------------+-------------------------------------------+----------------+------+---------+----------------+---------------------+
| +ProduceResults  | location, name                            |             15 |   15 |       0 |                | Fused in Pipeline 0 |
| |                +-------------------------------------------+----------------+------+---------+----------------+---------------------+
| +Projection      | cache[l.name] AS location, p.name AS name |             15 |   15 |      30 |                | Fused in Pipeline 0 |
| |                +-------------------------------------------+----------------+------+---------+----------------+---------------------+
| +Filter          | p:Person                                  |             15 |   15 |      15 |                | Fused in Pipeline 0 |
| |                +-------------------------------------------+----------------+------+---------+----------------+---------------------+
| +Expand(All)     | (l)<-[anon_19:WORKS_IN]-(p)               |             15 |   15 |      26 |                | Fused in Pipeline 0 |
| |                +-------------------------------------------+----------------+------+---------+----------------+---------------------+
| +CacheProperties | cache[l.name]                             |             10 |   10 |      20 |                | Fused in Pipeline 0 |
| |                +-------------------------------------------+----------------+------+---------+----------------+---------------------+
| +NodeByLabelScan | l:Location                                |             10 |   10 |      11 |             64 | Fused in Pipeline 0 |
+------------------+-------------------------------------------+----------------+------+---------+----------------+---------------------+

Total database accesses: 102, total allocated memory: 64

7.4.70. Create Nodes / Relationships

The Create operator is used to create nodes and relationships.

Query. 

CREATE (max:Person { name: 'Max' }),(chris:Person { name: 'Chris' })
CREATE (max)-[:FRIENDS_WITH]->(chris)

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+---------------------------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details                                                             | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+---------------------------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |                                                                     |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +---------------------------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |                                                                     |              1 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +---------------------------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Create         | (max:Person), (chris:Person), (max)-[anon_79:FRIENDS_WITH]->(chris) |              1 |    1 |       8 |               0 |                 0 |               0.0000 |
+-----------------+---------------------------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 8, total allocated memory: 3176

7.4.71. Delete

The Delete operator is used to delete a node or a relationship.

Query. 

MATCH (me:Person { name: 'me' })-[w:WORKS_IN { duration: 190 }]->(london:Location { name: 'London' })
DELETE w

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| Operator        | Details                                                                     | Estimated Rows | Rows | DB Hits | Memory (Bytes) | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order       |
+-----------------+-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +ProduceResults |                                                                             |              0 |    0 |       0 |                |               0 |                 0 |               0.0000 |             |
| |               +-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +EmptyResult    |                                                                             |              0 |    0 |       0 |                |               0 |                 0 |               0.0000 |             |
| |               +-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +Delete         | w                                                                           |              0 |    1 |       1 |                |               2 |                 0 |               1.0000 | me.name ASC |
| |               +-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +Eager          |                                                                             |              0 |    1 |       0 |           4352 |               0 |                 0 |               0.0000 | me.name ASC |
| |               +-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +Filter         | london:Location AND w.duration = $autoint_1 AND london.name = $autostring_2 |              0 |    1 |       3 |                |               3 |                 0 |               1.0000 | me.name ASC |
| |               +-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +Expand(All)    | (me)-[w:WORKS_IN]->(london)                                                 |              1 |    1 |       3 |                |               2 |                 0 |               1.0000 | me.name ASC |
| |               +-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+
| +NodeIndexSeek  | me:Person(name) WHERE name = $autostring_0                                  |              1 |    1 |       2 |                |               0 |                 1 |               0.0000 | me.name ASC |
+-----------------+-----------------------------------------------------------------------------+----------------+------+---------+----------------+-----------------+-------------------+----------------------+-------------+

Total database accesses: 9, total allocated memory: 4352

7.4.72. Detach Delete

The DetachDelete operator is used in all queries containing the DETACH DELETE clause, when deleting nodes and their relationships.

Query. 

MATCH (p:Person)
DETACH DELETE p

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+------------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator         | Details  | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+------------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults  |          |             14 |    0 |       0 |               0 |                 0 |               0.0000 |
| |                +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult     |          |             14 |    0 |       0 |               0 |                 0 |               0.0000 |
| |                +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +DetachDelete    | p        |             14 |   14 |       0 |              48 |                 0 |               1.0000 |
| |                +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +NodeByLabelScan | p:Person |             14 |   14 |      15 |               2 |                 0 |               1.0000 |
+------------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 15, total allocated memory: 11720

7.4.73. Merge Create Node

The MergeCreateNode operator is used when creating a node as a result of a MERGE clause failing to find the node.

Query. 

MERGE (:Person { name: 'Sally' })

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------------+------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| Operator              | Details                                        | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order           |
+-----------------------+------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| +ProduceResults       |                                                |              1 |    0 |       0 |               0 |                 0 |               0.0000 |                 |
| |                     +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| +EmptyResult          |                                                |              1 |    0 |       0 |               0 |                 0 |               0.0000 |                 |
| |                     +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| +AntiConditionalApply |                                                |              1 |    1 |       0 |               0 |                 0 |               0.0000 |                 |
| |\                    +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| | +MergeCreateNode    | anon_7                                         |              1 |    1 |       3 |               0 |                 0 |               0.0000 |                 |
| |                     +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| +Optional             |                                                |              1 |    1 |       0 |               0 |                 0 |               0.0000 | anon_7.name ASC |
| |                     +------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+
| +NodeIndexSeek        | anon_7:Person(name) WHERE name = $autostring_0 |              1 |    0 |       1 |               0 |                 1 |               0.0000 | anon_7.name ASC |
+-----------------------+------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+-----------------+

Total database accesses: 4, total allocated memory: 1352

7.4.74. Merge Create Relationship

The MergeCreateRelationship operator is used when creating a relationship as a result of a MERGE clause failing to find the relationship.

Query. 

MATCH (s:Person { name: 'Sally' })
MERGE (s)-[:FRIENDS_WITH]->(s)

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+------------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| Operator                     | Details                                   | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio | Order      |
+------------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +ProduceResults              |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +EmptyResult                 |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +Apply                       |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 | s.name ASC |
| |\                           +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +AntiConditionalApply      |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |\                         +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | | +MergeCreateRelationship | (s)-[anon_43:FRIENDS_WITH]->(s)           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | | +Argument                | s                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +AntiConditionalApply      |                                           |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |\                         +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | | +Optional                | s                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | | +Expand(Into)            | (s)-[anon_43:FRIENDS_WITH]->(s)           |              0 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | | +LockNodes               | s                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | | |                        +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | | +Argument                | s                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +Optional                  | s                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +Expand(Into)              | (s)-[anon_43:FRIENDS_WITH]->(s)           |              0 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| | |                          +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| | +Argument                  | s                                         |              1 |    0 |       0 |               0 |                 0 |               0.0000 |            |
| |                            +-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+
| +NodeIndexSeek               | s:Person(name) WHERE name = $autostring_0 |              1 |    0 |       1 |               0 |                 1 |               0.0000 | s.name ASC |
+------------------------------+-------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+------------+

Total database accesses: 1, total allocated memory: 0

7.4.75. Set Labels

The SetLabels operator is used when setting labels on a node.

Query. 

MATCH (n)
SET n:Person

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details  | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |          |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |          |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SetLabels      | n:Person |             35 |   35 |      35 |               2 |                 0 |               1.0000 |
| |               +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +AllNodesScan   | n        |             35 |   35 |      36 |               1 |                 0 |               1.0000 |
+-----------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 71, total allocated memory: 8960

7.4.76. Remove Labels

The RemoveLabels operator is used when deleting labels from a node.

Query. 

MATCH (n)
REMOVE n:Person

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details  | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |          |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |          |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +RemoveLabels   | n:Person |             35 |   35 |      35 |               2 |                 0 |               1.0000 |
| |               +----------+----------------+------+---------+-----------------+-------------------+----------------------+
| +AllNodesScan   | n        |             35 |   35 |      36 |               1 |                 0 |               1.0000 |
+-----------------+----------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 71, total allocated memory: 6144

7.4.77. Set Node Properties From Map

The SetNodePropertiesFromMap operator is used when setting properties from a map on a node.

Query. 

MATCH (n)
SET n = { weekday: 'Monday', meal: 'Lunch' }

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+---------------------------+---------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator                  | Details                                           | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+---------------------------+---------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults           |                                                   |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |                         +---------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult              |                                                   |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |                         +---------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SetNodePropertiesFromMap | n = {weekday: $autostring_0, meal: $autostring_1} |             35 |   35 |     141 |               4 |                 0 |               1.0000 |
| |                         +---------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +AllNodesScan             | n                                                 |             35 |   35 |      36 |               1 |                 0 |               1.0000 |
+---------------------------+---------------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 177, total allocated memory: 12000

7.4.78. Set Relationship Properties From Map

The SetRelationshipPropertiesFromMap operator is used when setting properties from a map on a relationship.

Query. 

MATCH (n)-[r]->(m)
SET r = { weight: 5, unit: 'kg' }

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------------------------+-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator                          | Details                                       | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------------------------+-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults                   |                                               |             18 |    0 |       0 |               0 |                 0 |               0.0000 |
| |                                 +-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult                      |                                               |             18 |    0 |       0 |               0 |                 0 |               0.0000 |
| |                                 +-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SetRelationshipPropertiesFromMap | r = {weight: $autoint_0, unit: $autostring_1} |             18 |   18 |      69 |               4 |                 0 |               1.0000 |
| |                                 +-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +Expand(All)                      | (m)<-[r]-(n)                                  |             18 |   18 |      71 |              22 |                 0 |               1.0000 |
| |                                 +-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +AllNodesScan                     | m                                             |             35 |   35 |      36 |               1 |                 0 |               1.0000 |
+-----------------------------------+-----------------------------------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 176, total allocated memory: 1704

7.4.79. Set Property

The SetProperty operator is used when setting a property on a node or relationship.

Query. 

MATCH (n)
SET n.checked = TRUE

Query Plan. 

Compiler CYPHER 4.1

Planner COST

Runtime SLOTTED

Runtime version 4.1

+-----------------+------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| Operator        | Details          | Estimated Rows | Rows | DB Hits | Page Cache Hits | Page Cache Misses | Page Cache Hit Ratio |
+-----------------+------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +ProduceResults |                  |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +EmptyResult    |                  |             35 |    0 |       0 |               0 |                 0 |               0.0000 |
| |               +------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +SetProperty    | n.checked = true |             35 |   35 |      38 |               2 |                 0 |               1.0000 |
| |               +------------------+----------------+------+---------+-----------------+-------------------+----------------------+
| +AllNodesScan   | n                |             35 |   35 |      36 |               1 |                 0 |               1.0000 |
+-----------------+------------------+----------------+------+---------+-----------------+-------------------+----------------------+

Total database accesses: 74, total allocated memory: 4464

7.4.80. Create Unique Constraint

The CreateUniqueConstraint operator creates a unique constraint on a property for all nodes having a certain label. The following query will create a unique constraint with the name uniqueness on the name property of nodes with the Country label.

Query. 

CREATE CONSTRAINT uniqueness
ON (c:Country) ASSERT c.name IS UNIQUE

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-------------------+----------------------------------------------------------------+
| Operator          | Details                                                        |
+-------------------+----------------------------------------------------------------+
| +CreateConstraint | CONSTRAINT uniqueness ON (c:Country) ASSERT (c.name) IS UNIQUE |
+-------------------+----------------------------------------------------------------+

Total database accesses: ?

7.4.81. Drop Unique Constraint

The DropUniqueConstraint operator removes a unique constraint from a property for all nodes having a certain label. The following query will drop a unique constraint on the name property of nodes with the Country label.

Query. 

DROP CONSTRAINT ON (c:Country) ASSERT c.name IS UNIQUE

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-----------------+-----------------------------------------------------+
| Operator        | Details                                             |
+-----------------+-----------------------------------------------------+
| +DropConstraint | CONSTRAINT ON (c:Country) ASSERT (c.name) IS UNIQUE |
+-----------------+-----------------------------------------------------+

Total database accesses: ?

7.4.82. Create Node Property Existence Constraint

The CreateNodePropertyExistenceConstraint operator creates an existence constraint with the name existence on a property for all nodes having a certain label. This will only appear in Enterprise Edition.

Query. 

CREATE CONSTRAINT existence
ON (p:Person) ASSERT EXISTS (p.name)

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-------------------+----------------------------------------------------------+
| Operator          | Details                                                  |
+-------------------+----------------------------------------------------------+
| +CreateConstraint | CONSTRAINT existence ON (p:Person) ASSERT exists(p.name) |
+-------------------+----------------------------------------------------------+

Total database accesses: ?

7.4.83. Drop Node Property Existence Constraint

The DropNodePropertyExistenceConstraint operator removes an existence constraint from a property for all nodes having a certain label. This will only appear in Enterprise Edition.

Query. 

DROP CONSTRAINT ON (p:Person) ASSERT EXISTS (p.name)

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-----------------+------------------------------------------------+
| Operator        | Details                                        |
+-----------------+------------------------------------------------+
| +DropConstraint | CONSTRAINT ON (p:Person) ASSERT exists(p.name) |
+-----------------+------------------------------------------------+

Total database accesses: ?

7.4.84. Create Node Key Constraint

The CreateNodeKeyConstraint operator creates a node key constraint with the name node_key which ensures that all nodes with a particular label have a set of defined properties whose combined value is unique, and where all properties in the set are present. This will only appear in Enterprise Edition.

Query. 

CREATE CONSTRAINT node_key
ON (e:Employee) ASSERT (e.firstname, e.surname) IS NODE KEY

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-------------------+---------------------------------------------------------------------------------+
| Operator          | Details                                                                         |
+-------------------+---------------------------------------------------------------------------------+
| +CreateConstraint | CONSTRAINT node_key ON (e:Employee) ASSERT (e.firstname, e.surname) IS NODE KEY |
+-------------------+---------------------------------------------------------------------------------+

Total database accesses: ?

7.4.85. Drop Node Key Constraint

The DropNodeKeyConstraint operator removes a node key constraint from a set of properties for all nodes having a certain label. This will only appear in Enterprise Edition.

Query. 

DROP CONSTRAINT ON (e:Employee) ASSERT (e.firstname, e.surname) IS NODE KEY

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-----------------+------------------------------------------------------------------------+
| Operator        | Details                                                                |
+-----------------+------------------------------------------------------------------------+
| +DropConstraint | CONSTRAINT ON (e:Employee) ASSERT (e.firstname, e.surname) IS NODE KEY |
+-----------------+------------------------------------------------------------------------+

Total database accesses: ?

7.4.86. Create Relationship Property Existence Constraint

The CreateRelationshipPropertyExistenceConstraint operator creates an existence constraint with the name existence on a property for all relationships of a certain type. This will only appear in Enterprise Edition.

Query. 

CREATE CONSTRAINT existence
ON ()-[l:LIKED]-() ASSERT EXISTS (l.when)

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-------------------+---------------------------------------------------------------+
| Operator          | Details                                                       |
+-------------------+---------------------------------------------------------------+
| +CreateConstraint | CONSTRAINT existence ON ()-[l:LIKED]-() ASSERT exists(l.when) |
+-------------------+---------------------------------------------------------------+

Total database accesses: ?

7.4.87. Drop Relationship Property Existence Constraint

The DropRelationshipPropertyExistenceConstraint operator removes an existence constraint from a property for all relationships of a certain type. This will only appear in Enterprise Edition.

Query. 

DROP CONSTRAINT ON ()-[l:LIKED]-() ASSERT EXISTS (l.when)

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-----------------+-----------------------------------------------------+
| Operator        | Details                                             |
+-----------------+-----------------------------------------------------+
| +DropConstraint | CONSTRAINT ON ()-[l:LIKED]-() ASSERT exists(l.when) |
+-----------------+-----------------------------------------------------+

Total database accesses: ?

7.4.88. Drop Constraint by name

The DropConstraint operator removes a constraint using the name of the constraint, no matter the type.

Query. 

DROP CONSTRAINT name

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+-----------------+-----------------+
| Operator        | Details         |
+-----------------+-----------------+
| +DropConstraint | CONSTRAINT name |
+-----------------+-----------------+

Total database accesses: ?

7.4.89. Create Index

The CreateIndex operator creates an index on a property for all nodes having a certain label. The following query will create an index with the name my_index on the name property of nodes with the Country label.

Query. 

CREATE INDEX my_index FOR (c:Country)
ON (c.name)

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+--------------+-----------------------------------------+
| Operator     | Details                                 |
+--------------+-----------------------------------------+
| +CreateIndex | INDEX my_index FOR (:Country) ON (name) |
+--------------+-----------------------------------------+

Total database accesses: ?

7.4.90. Drop Index

The DropIndex operator removes an index from a property for all nodes having a certain label. The following query will drop an index on the name property of nodes with the Country label.

Query. 

DROP INDEX ON :Country(name)

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+------------+--------------------------------+
| Operator   | Details                        |
+------------+--------------------------------+
| +DropIndex | INDEX FOR (:Country) ON (name) |
+------------+--------------------------------+

Total database accesses: ?

7.4.91. Drop Index by name

The DropIndex operator removes an index using the name of the index.

Query. 

DROP INDEX name

Query Plan. 

Compiler CYPHER 4.1

Planner ADMINISTRATION

Runtime SCHEMA

Runtime version 4.1

+------------+------------+
| Operator   | Details    |
+------------+------------+
| +DropIndex | INDEX name |
+------------+------------+

Total database accesses: ?