Optimize graph query by simplifying MATCH pattern
- Simplify MATCH clause to ()-[r]-() - Remove node type constraints - Improve query performance
This commit is contained in:
parent
a417f7c168
commit
2f0aa7ed12
1 changed files with 1 additions and 1 deletions
|
|
@ -3289,7 +3289,7 @@ class PGGraphStorage(BaseGraphStorage):
|
||||||
query = f"""
|
query = f"""
|
||||||
SELECT * FROM cypher('{self.graph_name}', $$
|
SELECT * FROM cypher('{self.graph_name}', $$
|
||||||
UNWIND {chunk_ids_str} AS chunk_id
|
UNWIND {chunk_ids_str} AS chunk_id
|
||||||
MATCH (a:base)-[r]-(b:base)
|
MATCH ()-[r]-()
|
||||||
WHERE r.source_id IS NOT NULL AND chunk_id IN split(r.source_id, '{GRAPH_FIELD_SEP}')
|
WHERE r.source_id IS NOT NULL AND chunk_id IN split(r.source_id, '{GRAPH_FIELD_SEP}')
|
||||||
RETURN DISTINCT r, startNode(r) AS source, endNode(r) AS target
|
RETURN DISTINCT r, startNode(r) AS source, endNode(r) AS target
|
||||||
$$) AS (edge agtype, source agtype, target agtype);
|
$$) AS (edge agtype, source agtype, target agtype);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue