Mark agtype_string_match_starts_with / _ends_with IMMUTABLE (contains already is)
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 88/100
調査の方向性
sql/agtype_string.sql から始め、agtype_string_match_starts_with と agtype_string_match_ends_with の volatility 宣言を agtype_string_match_contains と比較します。2 つの関数を IMMUTABLE としてマークし、その後、PostgreSQL が式インデックスの定義内でそれらの呼び出しを受け付けることを確認します。src/backend/parser/cypher_expr.c:1604-1628 の parser コンテキストから、この変更によって自動的なインデックス pushdown が追加されない理由が分かります。
索引モデルが issue の本文から書いたものです。
説明
sql/agtype_string.sql declares three agtype string-matching functions:
agtype_string_match_starts_with—STABLEagtype_string_match_ends_with—STABLEagtype_string_match_contains—IMMUTABLE
All three are pure functions over agtype values — same inputs, same output, every time, no
catalog lookups, no session state. There's no functional reason for contains to be
IMMUTABLE while starts_with/ends_with are STABLE; this looks like an oversight rather
than a deliberate distinction.
Concrete cost of the current state: PostgreSQL requires a function to be IMMUTABLE to be
used as an expression-index key (STABLE/VOLATILE functions are rejected at CREATE INDEX
time with "functions in index expression must be marked IMMUTABLE"). So today there is no way
— not even by hand-building an index — to accelerate a STARTS WITH or ENDS WITH predicate
via an expression index. CONTAINS doesn't have this problem only because it happens to
already be marked correctly.
What this fix does and doesn't do, to be upfront about the limit of the ask: marking these
two functions IMMUTABLE does not, by itself, make WHERE n.prop STARTS WITH 'x' or
ENDS WITH start using an index automatically. Read in source
(src/backend/parser/cypher_expr.c:1604-1628, AGE 1.7.0), Cypher's STARTS WITH/ENDS WITH
compile to a FuncExpr call of these functions, not to an operator — and AGE's automatic
property-index pushdown (match_clause_to_indexcol() and friends) matches on operators via
opclass, not on arbitrary function calls. No operator, no automatic pushdown, regardless of
volatility.
What the IMMUTABLE marking does unlock: a user can build their own expression index
directly on the function call —
CREATE INDEX ON <graph>."<Label>" (agtype_string_match_starts_with(properties, ...))
— and use it via a manual rewrite of the predicate, or as groundwork for a future operator +
opclass that would let AGE's own pushdown logic reach it. Today that manual path is not just
unoptimized, it's flatly unavailable because Postgres refuses the CREATE INDEX outright on a
STABLE function.
So: two honest, separate claims — (1) this is a one-line correctness fix (volatility category
should match reality), and (2) it is a prerequisite for indexable prefix/suffix matching, not
a fix for it by itself. #2417 shows the maintainers have recently merged planner-metadata-only
changes to agtype operators for exactly this kind of correctness reason; happy to open this
as a PR if a maintainer confirms there isn't a reason these were left STABLE that we're
missing.
- 主要言語
- C
- スター
- 4.9k
- フォーク
- 535
- 平均マージ
- 9日 18時間
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/age のほかの issue
-
Integer division by -1 on INT64_MIN raises a misclassified floating-point exception (22P01) instead of bigint out of range対応中かも @sean0407 が 5 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
backlog bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
EchoTools/nevr-runtime#653 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
InfiniTimeOrg/InfiniTime#2492 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
base-files: 82_config_generate: regenerate /etc/board.json if 0-bytes / truncated after power cutオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
openwrt/openwrt#25940 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信