gregfelice commented on PR #2468: URL: https://github.com/apache/age/pull/2468#issuecomment-5004003823
Traced the scan-plan question @MuhammadTahaNaveed raised, and I think it's a real blocker rather than a nitpick: `rel->label` is set to `NULL` whenever an edge pattern uses alternation (`cypher_gram.y`), and the transform layer's fallback for a `NULL` label resolves the edge to `AG_DEFAULT_LABEL_EDGE` (`_ag_label_edge`) — the inheritance-parent table every edge label table inherits from (`create_stmt->inhRelations` in `label_commands.c`). Compare that to the single-label path, which builds a `RangeVar` straight at the specific label's own table. So `MATCH ()-[:A|B]->()` on a graph with labels `A..E` resolves against `_ag_label_edge`, which Postgres expands via inheritance to **all five** child tables, and only then filters with `_extract_label_id(id) IN (id_A, id_B)`. Since that's a function-wrapped predicate, there's no constraint exclusion or partition pruning available to skip C/D/E. As written, `[:A|B]` costs O(all edge labels in the graph) instead of O(2) — this gets worse as label cardinality grows, and is a real regression path for graphs with many edge types, not just a style concern. I don't think this needs to block the PR forever, but I'd like to see it addressed (or explicitly scoped out with a follow-up issue + a benchmark showing the regression is acceptable) before merge. The fix direction I'd suggest is building an Append/Union over just the resolved labels' own RangeVars — reusing the same per-label lookup the single-label path already does — rather than falling through to the generic parent + post-filter. Also flagging that @jrgemignani's performance question from Jul 13 is still open and lines up with this same issue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
