From 9e5a05f4736927ed11cef181666bad33e3b8244e Mon Sep 17 00:00:00 2001 From: Aidar Samerkhanov Date: Wed, 19 Jun 2024 21:09:19 +0300 Subject: [PATCH 1/5] Add section about edge type property index. --- pages/fundamentals/indexes.mdx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/pages/fundamentals/indexes.mdx b/pages/fundamentals/indexes.mdx index 7534323e9..50b5de40c 100644 --- a/pages/fundamentals/indexes.mdx +++ b/pages/fundamentals/indexes.mdx @@ -151,6 +151,26 @@ Creating an edge-type index will optimize the following type of queries: MATCH ()-[r:EDGE_TYPE]->() RETURN r; ``` +### 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. + + + +Creating an edge type property index requires the --storage-properties-on-edges flag to be set to true! + + + +```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; +``` + #### Analyze graph When multiple label-property indexes exist, the database can sometimes select a @@ -310,7 +330,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 @@ -418,14 +438,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; ``` - + Overriding planner behavior with index hints should be used with caution, and only by experienced developers and/or database administrators, as poor index From e349da438bb9dcc00a05b06e87c62ea7d7f37750 Mon Sep 17 00:00:00 2001 From: Aidar Samerkhanov Date: Mon, 24 Jun 2024 21:57:05 +0300 Subject: [PATCH 2/5] Add information about accessing nodes when edge type indices are used. --- pages/fundamentals/indexes.mdx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pages/fundamentals/indexes.mdx b/pages/fundamentals/indexes.mdx index 50b5de40c..974515b1f 100644 --- a/pages/fundamentals/indexes.mdx +++ b/pages/fundamentals/indexes.mdx @@ -151,13 +151,20 @@ Creating an edge-type index will optimize the following type of queries: MATCH ()-[r:EDGE_TYPE]->() RETURN r; ``` -### 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. +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. + + + +### 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. -Creating an edge type property index requires the --storage-properties-on-edges flag to be set to true! +Creating an edge-type property index requires the --storage-properties-on-edges flag to be set to true! @@ -165,12 +172,19 @@ Creating an edge type property index requires the --storage-properties-on-edges CREATE EDGE INDEX ON :EDGE_TYPE(property_name); ``` -Creating an edge type property index will optimize the following type of queries: +Creating an edge-type property index will optimize the following type of queries: ```cypher MATCH ()-[r:EDGE_TYPE {property_name: value}]->() RETURN r; ``` + + +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. + + + #### Analyze graph When multiple label-property indexes exist, the database can sometimes select a From 171b69ff80a53030f7493a68875c4cc151bcea28 Mon Sep 17 00:00:00 2001 From: Aidar Samerkhanov Date: Mon, 24 Jun 2024 22:01:46 +0300 Subject: [PATCH 3/5] Fix `Analyze graph` indentation --- pages/fundamentals/indexes.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/fundamentals/indexes.mdx b/pages/fundamentals/indexes.mdx index 974515b1f..98bfe52ef 100644 --- a/pages/fundamentals/indexes.mdx +++ b/pages/fundamentals/indexes.mdx @@ -185,7 +185,7 @@ Currently, named parameters are not supported for edge-type property indexes. -#### Analyze graph +### Analyze graph When multiple label-property indexes exist, the database can sometimes select a non-optimal index due to the data's distribution. From 31d1a3e758c4784be3e4cd1a0b85dbb8e80c91ae Mon Sep 17 00:00:00 2001 From: Aidar Samerkhanov Date: Tue, 25 Jun 2024 09:16:12 +0300 Subject: [PATCH 4/5] Address comments --- pages/fundamentals/indexes.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/fundamentals/indexes.mdx b/pages/fundamentals/indexes.mdx index 98bfe52ef..c7dc5c2ca 100644 --- a/pages/fundamentals/indexes.mdx +++ b/pages/fundamentals/indexes.mdx @@ -154,7 +154,7 @@ MATCH ()-[r:EDGE_TYPE]->() RETURN r; 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. +Named parameters are not supported for edge-type indexes. @@ -181,7 +181,7 @@ MATCH ()-[r:EDGE_TYPE {property_name: value}]->() RETURN r; 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. +Named parameters are not supported for edge-type property indexes. From e9560ae21dd22d1120f298f8b38cd0a36b722613 Mon Sep 17 00:00:00 2001 From: Aidar Samerkhanov Date: Tue, 25 Jun 2024 22:44:01 +0300 Subject: [PATCH 5/5] Beautify docs --- pages/fundamentals/indexes.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/fundamentals/indexes.mdx b/pages/fundamentals/indexes.mdx index c7dc5c2ca..56b0fb631 100644 --- a/pages/fundamentals/indexes.mdx +++ b/pages/fundamentals/indexes.mdx @@ -154,6 +154,7 @@ MATCH ()-[r:EDGE_TYPE]->() RETURN r; If you need to access nodes of found edges, you can use the `startNode(r)` and `endNode(r)` functions. + Named parameters are not supported for edge-type indexes. @@ -181,6 +182,7 @@ MATCH ()-[r:EDGE_TYPE {property_name: value}]->() RETURN r; If you need to access nodes of found edges, you can use the `startNode(r)` and `endNode(r)` functions. + Named parameters are not supported for edge-type property indexes.