Optimize graph query by simplifying MATCH pattern

- Simplify MATCH clause to ()-[r]-()
- Remove node type constraints
- Improve query performance
This commit is contained in:
yangdx 2025-08-02 12:54:22 +08:00
parent a417f7c168
commit 2f0aa7ed12
1 changed files with 1 additions and 1 deletions

View File

@ -3289,7 +3289,7 @@ class PGGraphStorage(BaseGraphStorage):
query = f"""
SELECT * FROM cypher('{self.graph_name}', $$
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}')
RETURN DISTINCT r, startNode(r) AS source, endNode(r) AS target
$$) AS (edge agtype, source agtype, target agtype);