16.1. Starting point operators

These operators find parts of the graph from which to start.

All Nodes Scan

Reads all nodes from the node store. The variable that will contain the nodes is seen in the arguments. If your query is using this operator, you are very likely to see performance problems on any non-trivial database.

Query 

MATCH (n)
RETURN n

Query Plan 

+-----------------+----------------+------+---------+-----------+-------+
| Operator        | Estimated Rows | Rows | DB Hits | Variables | Other |
+-----------------+----------------+------+---------+-----------+-------+
| +ProduceResults |             35 |   35 |       0 | n         | n     |
| |               +----------------+------+---------+-----------+-------+
| +AllNodesScan   |             35 |   35 |      36 | n         |       |
+-----------------+----------------+------+---------+-----------+-------+

Total database accesses: 36

Directed Relationship By Id Seek

Reads one or more relationships by id from the relationship store. Produces both the relationship and the nodes on either side.

Query 

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

Query Plan 

+-----------------------------------+----------------+------+---------+-----------------+--------------------------------------------+
| Operator                          | Estimated Rows | Rows | DB Hits | Variables       | Other                                      |
+-----------------------------------+----------------+------+---------+-----------------+--------------------------------------------+
| +ProduceResults                   |              1 |    1 |       0 | n1, r           | r, n1                                      |
| |                                 +----------------+------+---------+-----------------+--------------------------------------------+
| +DirectedRelationshipByIdSeekPipe |              1 |    1 |       1 | anon[17], n1, r | EntityByIdRhs(SingleSeekArg({  AUTOINT0})) |
+-----------------------------------+----------------+------+---------+-----------------+--------------------------------------------+

Total database accesses: 1

Node by Id seek

Reads one or more nodes by id from the node store.

Query 

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

Query Plan 

+-----------------+----------------+------+---------+-----------+-------+
| Operator        | Estimated Rows | Rows | DB Hits | Variables | Other |
+-----------------+----------------+------+---------+-----------+-------+
| +ProduceResults |              1 |    1 |       0 | n         | n     |
| |               +----------------+------+---------+-----------+-------+
| +NodeByIdSeek   |              1 |    1 |       1 | n         |       |
+-----------------+----------------+------+---------+-----------+-------+

Total database accesses: 1

Node by label scan

Using the label index, fetches all nodes with a specific label on them from the node label index.

Query 

MATCH (person:Person)
RETURN person

Query Plan 

+------------------+----------------+------+---------+-----------+---------+
| Operator         | Estimated Rows | Rows | DB Hits | Variables | Other   |
+------------------+----------------+------+---------+-----------+---------+
| +ProduceResults  |             14 |   14 |       0 | person    | person  |
| |                +----------------+------+---------+-----------+---------+
| +NodeByLabelScan |             14 |   14 |      15 | person    | :Person |
+------------------+----------------+------+---------+-----------+---------+

Total database accesses: 15

Node index seek

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 called NodeUniqueIndexSeek instead.

Query 

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

Query Plan 

+-----------------+----------------+------+---------+-----------+-----------------+
| Operator        | Estimated Rows | Rows | DB Hits | Variables | Other           |
+-----------------+----------------+------+---------+-----------+-----------------+
| +ProduceResults |              1 |    1 |       0 | location  | location        |
| |               +----------------+------+---------+-----------+-----------------+
| +NodeIndexSeek  |              1 |    1 |       2 | location  | :Location(name) |
+-----------------+----------------+------+---------+-----------+-----------------+

Total database accesses: 2

Node index range seek

Finds nodes using an index seek where the value of the property matches a given prefix string. This operator can be used for STARTS WITH and comparators such as <, >, <= and >=

Query 

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

Query Plan 

+-----------------------+----------------+------+---------+-----------+---------------------------------------------+
| Operator              | Estimated Rows | Rows | DB Hits | Variables | Other                                       |
+-----------------------+----------------+------+---------+-----------+---------------------------------------------+
| +ProduceResults       |             26 |    1 |       0 | l         | l                                           |
| |                     +----------------+------+---------+-----------+---------------------------------------------+
| +NodeIndexSeekByRange |             26 |    1 |       2 | l         | :Location(name STARTS WITH {  AUTOSTRING0}) |
+-----------------------+----------------+------+---------+-----------+---------------------------------------------+

Total database accesses: 2

Node index contains scan

An index contains scan goes through all values stored in an index, and searches for entries containing a specific string. This is slower than an index seek, since all entries need to be examined, but still faster than the indirection needed by a label scan and then a property store filter.

Query 

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

Query Plan 

+------------------------+----------------+------+---------+-----------+----------------------------------+
| Operator               | Estimated Rows | Rows | DB Hits | Variables | Other                            |
+------------------------+----------------+------+---------+-----------+----------------------------------+
| +ProduceResults        |             10 |    2 |       0 | l         | l                                |
| |                      +----------------+------+---------+-----------+----------------------------------+
| +NodeIndexContainsScan |             10 |    2 |       3 | l         | :Location(name); {  AUTOSTRING0} |
+------------------------+----------------+------+---------+-----------+----------------------------------+

Total database accesses: 3

Node index scan

An index scan goes through all values stored in an index, and can be used to find all nodes with a particular label having a specified property (e.g. exists(n.prop)).

Query 

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

Query Plan 

+-----------------+----------------+------+---------+-----------+-----------------+
| Operator        | Estimated Rows | Rows | DB Hits | Variables | Other           |
+-----------------+----------------+------+---------+-----------+-----------------+
| +ProduceResults |             10 |   10 |       0 | l         | l               |
| |               +----------------+------+---------+-----------+-----------------+
| +NodeIndexScan  |             10 |   10 |      11 | l         | :Location(name) |
+-----------------+----------------+------+---------+-----------+-----------------+

Total database accesses: 11

Undirected Relationship By Id Seek

Reads one or more relationships by id from the relationship store. For each relationship, two rows are produced with start and end nodes arranged differently.

Query 

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

Query Plan 

+---------------------------------+----------------+------+---------+-----------------+-------+
| Operator                        | Estimated Rows | Rows | DB Hits | Variables       | Other |
+---------------------------------+----------------+------+---------+-----------------+-------+
| +ProduceResults                 |              1 |    2 |       0 | n1, r           | r, n1 |
| |                               +----------------+------+---------+-----------------+-------+
| +UndirectedRelationshipByIdSeek |              1 |    2 |       1 | anon[16], n1, r |       |
+---------------------------------+----------------+------+---------+-----------------+-------+

Total database accesses: 1