MuhammadTahaNaveed commented on PR #2458:
URL: https://github.com/apache/age/pull/2458#issuecomment-4875865687
@gregfelice
**GPT 5.5 xhigh review**:
Found one performance issue worth commenting on:
Performance note: `SET` now calls `ExecComputeStoredGenerated(...)` for
stored generated columns, but this path creates a fresh `ResultRelInfo` for
each updated entity at `src/backend/executor/cypher_set.c:607`.
`ExecComputeStoredGenerated(...)` lazily initializes `ri_GeneratedExprsU`;
PostgreSQL stores those expression states in the query context. Because AGE’s
`SET` path uses a new `ResultRelInfo` per row/update item, multi-row `SET` on
a label with stored generated columns will repeatedly rebuild generated-column
expression state and retain that memory until query end.
Relevant spots:
- `src/backend/executor/cypher_set.c:607` creates a new `ResultRelInfo`
- `src/backend/executor/cypher_set.c:143` / `:146` calls
`ExecComputeStoredGenerated(...)`
- `src/backend/executor/cypher_set.c:840` / `:841` closes
indexes/relation, but the generated expression state has already been allocated
in the executor query context
This should probably cache/reuse `ResultRelInfo` per label/relation for
the duration of `apply_update_list`, similar to the existing relation/index/RLS
caching pattern. That would let
`ri_GeneratedExprsU` initialize once per relation instead of once per
updated row.
**Secondary, lower-priority nit:**
Minor: `MERGE` now calls `clear_entity_slot(...)` before checking whether
the matched path will actually insert.
- `src/backend/executor/cypher_merge.c:1202`
- `src/backend/executor/cypher_merge.c:1529`
On a matched `MERGE` where `should_insert == false`, the code later skips
`insert_entity_tuple(...)`, so the new full-null-bitmap `memset` is avoidable
work. Usually tiny for AGE’s base
label tables, but it scales with extra user-added columns. Consider moving
the slot clear closer to the insert-only path if practical.
--
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]