Skip to content

Conversation

@jrgemignani
Copy link
Contributor

NOTE: This PR was created with AI tools and a human.

When matching patterns like (u)-[e]->(v), join conditions previously rebuilt entire vertex/edge agtype values just to extract IDs:

age_id(_agtype_build_vertex(r.id, ...))::graphid

Added optimize_qual_expr_mutator() to replace these patterns with direct column access:

age_id(_agtype_build_vertex(id, ...)) -> graphid_to_agtype(id) age_start_id(_agtype_build_edge(...)) -> graphid_to_agtype(start) age_end_id(_agtype_build_edge(...)) -> graphid_to_agtype(end) age_properties(...) -> direct properties column

Join conditions now use efficient comparisons like (e.start_id = u.id) enabling PostgreSQL to leverage index scans on edge tables.

Added regression tests.
All regression tests passed.

modified: regress/expected/unified_vertex_table.out
modified: regress/sql/unified_vertex_table.sql
modified: src/backend/parser/cypher_clause.c

NOTE: This PR was created with AI tools and a human.

When matching patterns like (u)-[e]->(v), join conditions previously
rebuilt entire vertex/edge agtype values just to extract IDs:

age_id(_agtype_build_vertex(r.id, ...))::graphid

Added optimize_qual_expr_mutator() to replace these patterns with
direct column access:

age_id(_agtype_build_vertex(id, ...)) -> graphid_to_agtype(id)
age_start_id(_agtype_build_edge(...)) -> graphid_to_agtype(start)
age_end_id(_agtype_build_edge(...)) -> graphid_to_agtype(end)
age_properties(...) -> direct properties column

Join conditions now use efficient comparisons like (e.start_id = u.id)
enabling PostgreSQL to leverage index scans on edge tables.

Added regression tests.
All regression tests passed.

modified:   regress/expected/unified_vertex_table.out
modified:   regress/sql/unified_vertex_table.sql
modified:   src/backend/parser/cypher_clause.c
@github-actions github-actions bot added the override-stale To keep issues/PRs untouched from stale action label Dec 23, 2025
@jrgemignani jrgemignani merged commit 22ebcda into apache:Dev_Multiple_Labels Dec 23, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

override-stale To keep issues/PRs untouched from stale action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant