Commit f02eda0
authored
perf: VLE terminal-qual rewrite (#2420)
perf: VLE terminal-qual rewrite — emit endpoint equalities instead of SRF
qual functions.
Removes the per-row age_match_vle_terminal_edge and age_match_two_vle_edges
qual functions from VLE query plans. The cypher transformer now emits the
endpoint match as a plain graphid/int8 equality on new SRF output columns,
evaluated by the planner like any other join clause — no detoasting, no
per-row C function dispatch. Stages land as one commit:
S1 Inline start_vid/end_vid in VLE_path_container header
S2 Read VLE qual endpoints from header-only TOAST slice
S4 Emit start_id/end_id as scalar SRF output columns
(age_vle now RETURNS SETOF record with edges/start_id/end_id)
S5 Cypher transformer rewrites terminal-edge match quals as
integer equalities (drops age_match_vle_terminal_edge call)
S6 Cypher transformer emits graphid equality for two-VLE-edge
joins (drops age_match_two_vle_edges call)
Performance (SF3 LDBC SNB, 5 runs/3 warmup, vs clean master baseline_v2):
IC sum 198,958 → 109,322 ms −45.05 % (1.82× end-to-end speedup)
IC1 8,625 → 4,600 ms −46.67 %
IC3 21,239 → 9,784 ms −53.93 %
IC5 21,051 → 5,696 ms −72.94 %
IC6 15,916 → 4,447 ms −72.06 %
IC9 44,839 → 21,161 ms −52.81 %
IC10 13,104 → 2,432 ms −81.44 %
IC11 11,676 → 241 ms −97.93 % (48× speedup)
IC2/4/7/8/12: parity (within ±3.3 %; IC4 is −2.47 %, no regression)
IS sum: 1,009 → 1,004 ms −0.51 % (no VLE traffic)
IU sum: 77 → 71 ms −8.38 % (IU1 −16.09 %; incidental)
Memory: header-only TOAST slice for VLE qual evaluation avoids
detoasting full path containers on every row; reduces per-call
palloc/pfree churn in long DFS paths. No measured RSS change.
Dead-code removal:
- Bodies of age_match_vle_terminal_edge and age_match_two_vle_edges
are gone from age_vle.c (~225 lines). C entry points remain as
error-raising stubs solely so the upgrade-test snapshot loader
(which sources an older 1.7.0_initial SQL against the current
age.so) can resolve the symbols before the immediate ALTER
EXTENSION UPDATE drops them. No regress test references either
function.
- SQL CREATE FUNCTION declarations removed from fresh install
(sql/agtype_typecast.sql).
- DROP FUNCTION IF EXISTS for both qual functions added to the
upgrade script (age--1.7.0--y.y.y.sql).
API change: ag_catalog.age_vle(...) now RETURNS SETOF record with
output columns (edges agtype, start_id graphid, end_id graphid)
instead of RETURNS SETOF agtype. Both 7-arg and 8-arg overloads
are updated in fresh-install (sql/agtype_typecast.sql) and upgrade
(age--1.7.0--y.y.y.sql) paths. age_match_vle_terminal_edge and
age_match_two_vle_edges are dropped on upgrade and absent from
fresh installs. Internal AGE callers are unaffected; external SQL
that called any of these directly must adapt.
Hardening (in response to PR #2420 review feedback):
- cypher_clause.c: terminal-edge and two-VLE-edge join-qual
emission paths now bracket the existing Assert(vle_alias != NULL)
with a runtime ereport(ERROR, ...) so a missing alias produces a
clean error in production builds (where Asserts compile out)
instead of a NULL-deref crash inside makeString().
- age_vle.c: VLE_path_container struct comment now documents that
the layout is transient (consumed within the producing query and
never persisted), so the new start_vid/end_vid fields do not
require an AGT_FBINARY_TYPE_VLE_PATH version bump or backward-
compatible reader. The note also flags the constraint a future
change would need to honor if the container ever became
persistable.
Tested on PostgreSQL 18.3 (REL_18_STABLE): all 34 regression tests
pass (installcheck), warning-free build.
modified: age--1.7.0--y.y.y.sql
modified: regress/expected/cypher_match.out
modified: regress/expected/cypher_vle.out
modified: regress/expected/expr.out
modified: sql/agtype_typecast.sql
modified: src/backend/parser/cypher_clause.c
modified: src/backend/parser/cypher_transform_entity.c
modified: src/backend/utils/adt/age_vle.c
modified: src/include/parser/cypher_transform_entity.h1 parent 9960e9c commit f02eda0
9 files changed
Lines changed: 316 additions & 298 deletions
File tree
- regress/expected
- sql
- src
- backend
- parser
- utils/adt
- include/parser
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2784 | 2784 | | |
2785 | 2785 | | |
2786 | 2786 | | |
2787 | | - | |
2788 | 2787 | | |
| 2788 | + | |
2789 | 2789 | | |
2790 | 2790 | | |
2791 | 2791 | | |
2792 | | - | |
2793 | 2792 | | |
| 2793 | + | |
2794 | 2794 | | |
2795 | 2795 | | |
2796 | 2796 | | |
| |||
2812 | 2812 | | |
2813 | 2813 | | |
2814 | 2814 | | |
2815 | | - | |
2816 | 2815 | | |
| 2816 | + | |
2817 | 2817 | | |
2818 | 2818 | | |
2819 | 2819 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
76 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
87 | | - | |
88 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | 109 | | |
113 | 110 | | |
114 | 111 | | |
| |||
135 | 132 | | |
136 | 133 | | |
137 | 134 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | 135 | | |
147 | 136 | | |
148 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3982 | 3982 | | |
3983 | 3983 | | |
3984 | 3984 | | |
3985 | | - | |
3986 | | - | |
3987 | | - | |
3988 | | - | |
3989 | 3985 | | |
3990 | 3986 | | |
3991 | 3987 | | |
| |||
3998 | 3994 | | |
3999 | 3995 | | |
4000 | 3996 | | |
4001 | | - | |
4002 | | - | |
4003 | | - | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
4004 | 4007 | | |
4005 | 4008 | | |
4006 | 4009 | | |
4007 | | - | |
4008 | | - | |
| 4010 | + | |
| 4011 | + | |
| 4012 | + | |
| 4013 | + | |
4009 | 4014 | | |
4010 | 4015 | | |
4011 | | - | |
4012 | | - | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
4013 | 4019 | | |
4014 | | - | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
| 4027 | + | |
| 4028 | + | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
| 4038 | + | |
4015 | 4039 | | |
4016 | 4040 | | |
4017 | | - | |
4018 | | - | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
| 4044 | + | |
4019 | 4045 | | |
4020 | | - | |
4021 | | - | |
4022 | | - | |
| 4046 | + | |
| 4047 | + | |
4023 | 4048 | | |
4024 | 4049 | | |
4025 | 4050 | | |
4026 | | - | |
4027 | | - | |
4028 | | - | |
4029 | | - | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
4030 | 4061 | | |
4031 | 4062 | | |
4032 | 4063 | | |
4033 | 4064 | | |
4034 | 4065 | | |
4035 | | - | |
4036 | | - | |
4037 | | - | |
| 4066 | + | |
| 4067 | + | |
| 4068 | + | |
4038 | 4069 | | |
4039 | | - | |
| 4070 | + | |
| 4071 | + | |
| 4072 | + | |
| 4073 | + | |
| 4074 | + | |
| 4075 | + | |
| 4076 | + | |
| 4077 | + | |
| 4078 | + | |
| 4079 | + | |
| 4080 | + | |
| 4081 | + | |
4040 | 4082 | | |
4041 | | - | |
4042 | | - | |
| 4083 | + | |
| 4084 | + | |
| 4085 | + | |
| 4086 | + | |
4043 | 4087 | | |
4044 | | - | |
4045 | | - | |
| 4088 | + | |
| 4089 | + | |
| 4090 | + | |
| 4091 | + | |
4046 | 4092 | | |
4047 | | - | |
4048 | | - | |
| 4093 | + | |
| 4094 | + | |
| 4095 | + | |
4049 | 4096 | | |
4050 | | - | |
| 4097 | + | |
4051 | 4098 | | |
4052 | 4099 | | |
4053 | 4100 | | |
| |||
4898 | 4945 | | |
4899 | 4946 | | |
4900 | 4947 | | |
| 4948 | + | |
| 4949 | + | |
| 4950 | + | |
| 4951 | + | |
| 4952 | + | |
| 4953 | + | |
4901 | 4954 | | |
4902 | 4955 | | |
4903 | 4956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
0 commit comments