Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge type property index #855

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions pages/fundamentals/indexes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,41 @@ Creating an edge-type index will optimize the following type of queries:
MATCH ()-[r:EDGE_TYPE]->() RETURN r;
```

#### Analyze graph
<Callout type="info">

If you need to access nodes of found edges, you can use the `startNode(r)` and `endNode(r)` functions.
Currently, named parameters are not supported for edge-type indexes.
Darych marked this conversation as resolved.
Show resolved Hide resolved

</Callout>

### Edge-type property index

To optimize queries that fetch only the edges by specific edge types and properties, you need to create an edge-type property index.

<Callout type="warning">

Creating an edge-type property index requires the --storage-properties-on-edges flag to be set to true!

</Callout>

```cypher
CREATE EDGE INDEX ON :EDGE_TYPE(property_name);
```

Creating an edge-type property index will optimize the following type of queries:

```cypher
MATCH ()-[r:EDGE_TYPE {property_name: value}]->() RETURN r;
```

<Callout type="info">

If you need to access nodes of found edges, you can use the `startNode(r)` and `endNode(r)` functions.
Currently, named parameters are not supported for edge-type property indexes.
Darych marked this conversation as resolved.
Show resolved Hide resolved

</Callout>

### Analyze graph

When multiple label-property indexes exist, the database can sometimes select a
non-optimal index due to the data's distribution.
Expand Down Expand Up @@ -310,7 +344,7 @@ configuration](/configuration/configuration-settings#storage) flag to `true`.
### Analyze graph

The `ANALYZE GRAPH` will check and calculate certain properties of a graph so
that the database can choose a more optimal index or `MERGE` transaction.
that the database can choose a more optimal index or `MERGE` transaction.

Before the introduction of the `ANALYZE GRAPH` query, the database would choose
an index solely based on the number of indexed nodes. But if the number of nodes
Expand Down Expand Up @@ -418,14 +452,14 @@ It is also possible to specify multiple hints separated with comma. In that
case, the planner will apply the first hint that is applicable for a given
match.

An example of selecting an index with `USING INDEX`:
An example of selecting an index with `USING INDEX`:
```
USING INDEX :Person(name)
MATCH (n:Person {name: 'John', gender: 'male'})
RETURN n;
```

<Callout type="warning">
<Callout type="warning">

Overriding planner behavior with index hints should be used with caution, and
only by experienced developers and/or database administrators, as poor index
Expand Down