Repository navigation
fix(query): several graphs answer from the graphs they name, at lane speed; typed literals and string filters keep their terms - #2214
Conversation
`<`, `<=`, `>` and `>=` read a string as a value of a temporal type to order it against a typed date, time or dateTime. The evaluator applied that to any string-backed literal, so `"2026-01-01"@en` and `"2026-01-01"^^ex:T` ordered against `"2026-02-01"^^xsd:date` and passed, though a tagged or custom-typed literal is a term of its own type. Pushed into the scan, the same filter kept them on novelty and dropped them on the index, which seeks only the date slice. Only a plain string (a simple literal or `xsd:string`) is read as a temporal now, in the evaluator and in the scan's object bounds alike; both still order through `temporal::cmp_with_lexical`.
A range against a typed temporal (`FILTER(?o < "2026-02-01"^^xsd:date)`) seeks the temporal slice of the predicate on the index, but `<` also orders a plain `xsd:string` row against it by reading the string as a date, so a stored "2026-01-01" passed the filter on novelty and was never read on the index. The scan now seeks the `xsd:string` slice beside the temporal one, without the temporal key range, which does not order string ids. An `=` never equates the two and keeps the single temporal seek.
The evaluator compared a stored `@fulltext` value as a plain string on the
index, where it stays late-materialized, and as `f:fullText` on novelty, so
`FILTER(?o = "Hello World" || false)` matched it on one lane and not the
other. It now carries `f:fullText` on both. A JSON value reached the
evaluator as a plain string on both lanes, so `FILTER(?j = '{"a":1}')`
matched it when evaluated and not when pushed into the scan; it is an
`rdf:JSON` literal now, and a BIND of it keeps that datatype instead of
becoming an `xsd:string`.
Both are text to the string builtins, which on novelty refused an
`@fulltext` value (CONTAINS, STRSTARTS, REGEX; SUBSTR failed the query).
The builtins now take their arguments through one accept-set,
`reads_as_text` (a simple literal, `xsd:string`, a language tag,
`@fulltext` and `rdf:JSON`), where `string_arg`, STRBEFORE/STRAFTER and
CONCAT each kept a copy; CONCAT's had drifted and refused an explicit
`xsd:string`.
A typed date or dateTime bound against plain, tagged and custom-typed strings; `=` and `<` on `@fulltext` and JSON values; seven string builtins on `@fulltext` and three on JSON, plus BIND keeping `rdf:JSON`; and the integer `=` seek over two-row leaflets, with a double `7.0` in the index and in novelty over an all-integer index.
On novelty a builtin that refuses its argument fails the whole query, which panicked the test at the first such row and hid the rest.
A counting lane projects no column, yet the merge recorded a run per emitted row to gather from. With an empty projection it now counts the rows it emits and returns batches that are a row count alone. The randomized test checks the count against a full merge of the same members over leaflets cut differently.
…mpare as themselves Only a plain string is read as a temporal by `<` and `>`, in both directions; an @fulltext or JSON value is excluded by `=` and `<` against a string while the string functions read it as text.
Lane C on T's fixture: in every scope, state and surface the answer is the hand-written one with fast paths on and off, and the cache's route is the one design §5 gives it. The union site takes a default graph of several graphs and of none, the one-graph site takes one graph, and novelty or a read below the index declines the union with its reason.
Under the release profile (fat LTO, one codegen unit) the generic bound check stayed a call per bound, and a numeric range scan cost ~2% more instructions than before the term-aware check. Forced inline, it is back below where it started (release A/B against a9336a9).
…e move Where two inputs' heads are the same row, the first emits it and the second steps past its copy, instead of taking a turn of its own to drop it as a repeat. Release, instructions retired per input row, no output column: two identical members 117 -> 100, half overlap 59 -> 50.
…l graphs `?s <p> ?o GROUP BY ?o` with `COUNT(?s)`, top k, fell back to the general plan over a default graph of several graphs. It now reads the predicate's POST range through the merged cursor across the members: each fact once, in object order, so a group's run is the distinct subjects holding that object in some member, which is what the general plan's dedup on `(?s, ?o)` counts. List rows and arena-typed objects decline, with their reason, at the lane's own site, `group_by_object_count_topk_union`. IRI groups are emitted decoded, since no graph view decodes an encoded subject downstream of a union. The bound-object count reads its dedup identity from one function, `union_count_key` (today the subject: the general plan's union dedup keys on the emitted row, which is `?s` alone). Its merge checks each source's key order as it reads and declines only where a list puts a key out of order. A single member's list rows now go through the merge instead of declining.
A range with a plain-string bound over temporal rows (`FILTER(?at < "2026-06-01T00:00:00Z")` over `xsd:dateTime`) parsed the bound string again for every row it compared. `temporal::cmp_with_lexical` is now built on `temporal::lexical_as_kind_of`, the one reading of a lexical as a temporal kind, and `ObjectBounds::prepare` gives the scan and the flake lanes a `PreparedBounds` that keeps that reading per temporal kind, so the bound is parsed on the kind's first row. It answers exactly as the bounds do (pinned by a unit test), and the comparison is still the one `cmp_with_lexical` makes.
A merge over several graphs reads every member's branch for one order. A member with none declines the lane; the fallback is stamped as fallback:no_branch, after the shared reasons.
…its code A direct insert of a literal whose datatype is in a namespace the ledger has never registered stores it under the code the write gives that namespace, never under the EMPTY-namespace full-IRI form a query builds for an unseen datatype. A lookup by the literal finds it before and after an index build, after a reindex at the same t, and after a reload. A DELETE of a literal no fact can carry retracts nothing and registers no namespace. The JSON-LD insert covers an http and a urn datatype; SPARQL INSERT DATA covers `<bad:datatype>`, an absolute IRI SPARQL accepts and a JSON-LD @type refuses as an unexpanded compact IRI. File-backed, without background indexing, with explicit builds. The commit walk checks the stored form directly: no committed flake has an EMPTY-namespace datatype.
…nothing The closing edge's pair count cost about 1% of a one-graph triangle over the membership test it replaced. A miss now costs the one binary search the test cost, and a hit steps outward over the rare repeats. The bound-bound edge no longer builds a candidate list either: it only multiplies the assignment by the rows it holds, so the join recurses that many times.
Building `cmp_with_lexical` on `lexical_as_kind_of` boxed the parsed lexical on every call, which the FILTER evaluator makes once per row: `FILTER(?at < "2026-06-01T00:00:00Z" || false)` over `xsd:dateTime` cost 6.7% more instructions (release). `cmp_with_lexical` parses onto the stack again, as before; `lexical_as_kind_of` stays for the scan's parse-once bounds, and a test pins that the two order every value against a lexical alike.
`COUNT(?s)` over `?s <p> 1.5`, or over a big integer, fell back to the general plan on one graph as on several: only a bare integer or double was sliced into the (o_type, o_key) seeks the counts read. One function now slices every bare number, `untyped_numeric_slices`: an integer slice where the value is an exact `i64`, a float slice where an `f64` holds it exactly (as `numeric_cmp` compares), and the NumBig arena's handles for it, decimal aliases and, past `i64`, the integer. Integers and doubles slice as before. Both counts read it. Over several graphs each member translates the value into its own arena, and the count still dedups on the subject, so a handle is never compared across members. A typed decimal stays out: the count detector takes no datatype-constrained object.
…p path Charging the tracker in the count iterators' refills cost the count plan about 1.1% more instructions per query, tracking off or on. The refill is inlined into next_group, and the charge kept the tracker live across it, so every group paid for one more callee-saved register (a push and a pop per call, two instructions a row on a one-row-per-subject star). The refills of the five fast_path_common iterators and the count plans' subject-object iterator are now #[inline(never)], and charge_leaflet inlines only the enabled check, with the charge itself #[cold]. The chain fold's seek cursor keeps its refill inline: out of line it measured slower there. On an EC2 c7i.8xlarge, fat-LTO release builds, 1M subjects, rayon on one thread, instructions per query against main: count plan -1.9%, MINUS -4.1%, EXISTS -4.1%, OPTIONAL -0.9%, chain fold, whole-graph aggregate, geo and the property path's id lane flat (within 0.6%), tracking off and on alike.
…e it flips it Its two tests turn the process-global kill switch on and off without the write side of support::FAST_PATH_SWITCH, so under cargo test a routing test in grp_query that holds the read side could run inside the window and see fallback:kill_switch (exists_semijoin_cache_over_one_graph_and_a_union failed so once in seven runs). They hold the write side now, as the binary's other togglers do.
Brings in main through 4adc62e. Four files conflicted: - graph.rs: main streams a GRAPH block's inner subplan instead of buffering it. The branch's scope crossing (ScopeCrossing, whose enter and leave are fallible) and its fallible graph-IRI extraction now live in main's streaming path: the crossing is built when the subplan opens and kept in InnerStream, and next_streamed propagates a decode failure instead of dropping the row. - cyclic_bgp.rs: main decodes every binding the cyclic join emits under eager materialization, and its cascade probes plan for an eager caller (LaneOutput::DecodesForEager). That flag now lives in the branch's Emit, set in open_reads for the one-graph and the union reads alike, with the emit view built from the first member read whenever the lane decodes. - fast_path_common.rs, count_plan_exec.rs: predicate_unsafe_for_cross_predicate_o_key_join takes main's replay_to and this branch's tracker.
Brings in main through f42ea37, with #2374, which moves the one-graph bound-object probe from OPST to POST, hands its matches over a run of subjects at a time and builds rows from them on demand. join.rs and optional.rs conflicted: - The one-graph flush, the walk and the row builder (next_object_probe_step) are main's. - The union object probe keeps its member walk, which hands over each match's list position for the union's fact identity, as for_each_object_probe_match_by_fact. Its matches, one per fact of the union, now land in main's per-object subject lists, so the union and the one graph share main's row building and charging. It probes ref objects; a left row on a string object, which main's lane now keys too, goes to the per-row scan, which reads the union. - optional.rs takes main's call of the POST walk.
Main's bound-object lane now keys string terms as well as refs. Over a union it probes refs only and leaves a row on a string object to the per-row scan: this pins that answer, before and after indexing, with fast paths on and off. Sending the string keys to the union's ref walk answers nothing on the indexed fast-path run.
The batched probes read the index through LeafScan::load_leaflet: the subject probe and the subject star, the bound-object walk (POST, #2374's design) and the union's by-fact walk, the semijoin's index walk and scan_matches. They charged their matched rows, but not the leaflets they read, where the scan's cursor charges each one. load_leaflet now takes the query's tracker and charges one index touch per leaflet (charge_leaflet: an inlined enabled check, the charge itself out of line), so a probe that loads a leaflet is charged by construction. it_fast_path_fuel gains a batched subject probe and a bound-object probe: with the charge removed, the 3-row leaflets cost what the left scan's leaflets alone add (a gap of about 1, against 1.5 wanted).
|
Evidence for the description, moved here to keep it under GitHub's size limit: the red/green record, the merge log, and the per-area test lists. Shown red without their fixEach mutation was committed first, made after
The original follow-up's red/green (each half's sources set back to main's) and the string-filter and #1765 sections' own are unchanged. The list rows were re-pinned to #2217's values reading after main brought it in, and those three mutations re-run against them; the rows after them are the review round's, each run locally at its commit (logs kept). Merged with mainMain is merged seven times, each with a merge commit at the top:
An open PR that will conflict, to merge main again after it lands: #2201 (the arena-identity sites in Tests: FILTER string comparisons keep their term semantics when pushed
Tests: STRDT and typed literals build their literal for any datatype IRI
|
|
Thanks for such a careful pass, and for the #2271 heads-up, which saved me a confusing merge. Everything's in on the branch now:
The full gate set is green on Linux at the head ( The description is updated for all of this. It was over GitHub's size limit, so the red/green record, the merge log and the per-area test lists are in a separate comment. |
Since #2374 the bound-object lane keys string terms, and over a union the probe sent a left row on a string object to the per-row scan after keying it, which cost a union string join 2.6% more instructions than before that merge (790M to 811M a query at 7,500 rows). The members share one store and its dictionary novelty, so a string's key is one key in every member: the union's walk now takes the object type and walks any type the lane keys, keeping one match per fact as it does for refs. a_string_object_joins_across_a_union_once_per_fact now runs through the walk: with its fact dedup dropped, ex:b, whose alias both graphs hold, answers twice on the indexed fast-path run.
it_union_annotation_chain came from main (#2214) with cases that query annotated edges across two ledgers. They pass on main, where an annotation is plain triples on a reifier, and answer nothing on next, where it is a triple-term link the chain reads from one store's dictionary. The same-ledger cases still run; the two-ledger ones are off behind TWO_LEDGERS until #2444 fixes the chain across ledgers.
This is the follow-up #2010 said was coming ("Lanes that read one graph, and typed strings on the range scan"), and it grew, on purpose. The first half of it is what the original follow-up was: several single-graph lanes asked "does this query span ledgers?" when what they need is "does this scope read exactly one graph?", so over the union default graph,
FROMnaming several of a ledger's graphs, orFROM NAMEDalone, they read one member's index and answered from that — silently wrong. The honest fix for that is to stand those lanes down and let the general plan answer, which is right but slow over several graphs (up to a few hundred × main on the counts), and I didn't think we should ship a correctness fix that turns fast-but-wrong into slow-but-right on shapes people actually run. So the bulk of this PR is making those shapes fast again correctly: a scope type that says what a query's default graph is (one graph, several graphs of one store, or none), and a union variant of each lane that reads every member's index and answers as the merged graph does. Measured on a clean EC2 box, every one of those shapes is now within its target of main's (wrong) cost, and several are faster than main was.Along the way the union itself needed fixing: a default graph of several graphs is the set union of their facts, and the dedup was keying on the emitted row, so it collapsed solutions the graph alone keeps apart (a list's repeated value, or a constant that matches
1and1.0e0) and adding an empty graph could change an answer. That's now storage's fact identity (#2109'sFactIdentity), and the union's rows stay encoded instead of being decoded at every member scan (#2015). Lists follow #2217: SPARQL reads a list's members as values, as JSON-LD does, so every lane answers list patterns on both surfaces, a repeated member a row each time. Two smaller things rode along because they touch the same seams and were wrong on main: FILTER string comparisons that were pushed into the scan compared text only (so= "a"matched"a"@en), andSTRDT/ typed literals failed the whole query for a datatype namespace the ledger hadn't seen (#1765). Each is its own section below, fwiw, so it can be reviewed on its own.Fixes #1771
Fixes #1765
Fixes #2015
Partially addresses #2075 — the one-graph witness is in (
IndexScope, andone_graph_view()isNoneunder a union, so an index read there doesn't compile), and so is the k-way merge for the partitioned GROUP BY. Still open there:fulltext()'s arena statistics under a union, the Cypher metadata functions (labels,keys,properties), rules over several graphs, and makingbinary_g_idprivate (it's deprecated, 128 sites).Follow-up: #2072
Wrong results this fixes
Reproduced on main (
42bb9646cfor the rows added here,f3c3b00ecfor the original follow-up's), each pinned by a test with a hand-written answer.FROM <g2> FROM <g3>SELECT ?v (COUNT(*) AS ?k) WHERE { ?s ex:amount ?v } GROUP BY ?v1.5:1, 1.5:1, 2.5:1, 2.5:1(each group split per graph)1.5:2, 2.5:2groupBytwin)1.5:1, 1.5:2, 2.5:1, 2.5:11.5:3, 2.5:2?x ex:knows ?y . ?y ex:knows ?z . ?z ex:knows ?xFROM NAMED <g2>alone?x ex:amount ?v FILTER(EXISTS { ?x ex:label ?l } && ?v > 0)x1x1, y1SELECT (COUNT(?s) AS ?n) WHERE { ?s ex:kind ex:T }13SELECT ?p (COUNT(?s) AS ?n) WHERE { ?s ?p ?o } GROUP BY ?pkind:1, tag:1kind:4, tag:3geof:distance(…) <= 500000filterparisbrussels, london, parisf:unionDefaultGraph1; no rows;Salessplit in two4; 3 rows;Ops:1, Sales:3FROM <g1> FROM <gEmpty>?s ex:p 1overa p 1, 1.0e0aa, a(asFROM <g1>alone)FROM <g1> FROM <gEmpty>?s ex:q ?ooverd q (5 5 7)(d,5) (d,7)(d,5) (d,5) (d,7)FROM <g1> FROM <g2>, both holding `alice worksFor acme {ex:a ex:knows (ex:b ex:b)closing a triangleFROM <A> FROM <B>(two ledgers)?s ex:label "chat"@fr, VALUES of it, a join on it, the JSON-LD twin; the same for"A1"^^ex:Code; SPARQL parameters bound to thema, bex:label/ex:code?s ex:label "chat"@fr,"chat"@en,"A1"^^ex:Codeb,c,bFROM <C> FROM <D>,ct:only in D, or coded differently (#1771)?s ex:p "a"^^ct:T;?s ex:p ?oct:Tprinted as another IRId1;ct:T"chat"@frFILTER(sameTerm(?o, "abc"^^ex:custom));FILTER(?o = "abc"^^xsd:token);BIND("abc"^^ex:custom AS ?x)thenDATATYPE(?x)"abc"; every"abc"of any type;xsd:strings2;s4;ex:customFILTER(?o = "a")over"a","a"@en,"a"^^ex:T(pushed)"a"only, as the evaluated filter answersBIND(STRDT(?v, <http://nowhere.example/T>) AS ?x)"…T10:00:00.2Z"^^xsd:dateTimeFILTER(?at > "…T10:00:00.5Z") FILTER(?at > "…T10:00:00Z")(two string bounds the merge ordered as text)INSERT { ex:s ex:ref ?o } WHERE { ex:s ex:p "a" VALUES ?o { <http://unseen-a.example/o> } } ; INSERT DATA { <http://unseen-b.example/y> ex:p "b" }(and, with this PR, the same throughIRI(), a constantBINDorSTRDT)namespace conflict: code 14 …, on every retry#2187 fixed one more row of this table first (a batched subject probe over a graph the index has no branch for), so it's not here anymore; this branch takes main's fix for it. The last two rows came out of review. (So did a cross-ledger double count, but that one never reached main: there the query matched nothing, the #1771 row above.)
Several graphs, fast: the lanes, against their targets
The targets are the multiples of main we set before any lane was built — main is fast on these shapes only because it reads one graph's index, so "as fast as main" isn't reachable while being right, and each target is what that shape's correct answer can reasonably cost. The grouped count has its own target: at most 2× the one-graph lane over a single graph holding the same deduplicated facts (the "floor").
Measured on a c7i.4xlarge (Xeon 8488C), release profile (fat LTO), one harness (
fluree-db-api/examples/multigraph_lanes_ab.rs) built against main42bb9646c, the general plan (this branch's tests with no lane) and this branch. Three rounds in a Latin square, 5 reps each, wall-clock per query; for the targets defined in instructions,perf statinstructions per query (the difference of two runs). Scopes, 3,000 subjects per graph:mg=FROM <g1> FROM <g2>(half overlap),mgd= two disjoint graphs,mg3= three graphs,mgu= the union default graph (four). Every union cell's answer equals its floor's; main's is wrong in all 25 union cells.mgmgdmg3mguFILTER(EXISTS {…} && …)COUNT(?s)over?s ex:kind ex:T1COUNT(?s)per predicateCOUNT(*)grouped by?vCOUNTWall-clock ÷ main on EC2 unless marked. † is instructions ÷ main counted locally (macOS
proc_pid_rusage, release, three interleaved rounds of 10 reps, every cell's spread ≤ 0.6%), for the two lanes whose targets are instruction counts and whose EC2 instruction readings needed settling. Absolute, e.g.mg_exists3.30 ms against main's 9.42 ms (general plan 58.7 ms),dgs_mg_count10.25 ms against 10.24 ms.Two lanes want a word:
mgu_cyclic) first missed its target: on EC2, 5.64× main in instructions against 5.6×, and 6.7× on the clock. It still decoded every row it emitted under a union, which the union's term view made unnecessary, soca5cf37a2emits them encoded, as a scan of the union does. Counted locally, that takesmgu_cyclicfrom 221.7M to 176.4M instructions against main's 39.8M (5.57× → 4.43×), and the other three cells down 20–24% (mg94.2M → 74.7M). The EC2 wall-clock figures were measured before that change; on the clock it was 2.8× / 3.0× / 4.9× / 6.7× main.One graph, the hot path: parity. Against the general-plan build, the one-graph cells (
sg_*,g1_*, the floorsf2*/f3*/fu*, and the one-graph chaindgs_g1_*) are within +2.7% on the clock on EC2, inside each cell's own spread (≤ 9.7%), and within ±1.5% in instructions. The one outlier there,g1_count_predat +5.1% with a ~20% spread, is noise: counted locally it's 0.314M against main's 0.313M (+0.1%, spread ≤ 0.8%), andsg_count_predis +0.4%. The one-graph cyclic join is 2.6% under main locally. Against main on EC2, the largest isdgs_g1_drivenat +1.7%, which predates the lanes (it's the same at their merge base).What changed
One definition of "reads one graph", then a scope type. The original follow-up added
ActiveGraph::reads_one_graph(dataset)and gated every single-graph lane on it. Here that becomesExecutionContext::index_scope() -> Option<IndexScope>:One(IndexMember),Union(MemberSet)(two or more graphs of one store, each member with itsg_id, overlay andto_t, certified to share the store and its dictionary novelty), orEmpty. Members ofFROM <L#g1> FROM <L#g2>only shared a store when the ledger cache served both loads; each ledger is now loaded once per time per dataset (f2a72cfbd), so the certificate holds on every load path. The view split is in the types:one_graph_view()returnsNoneunder a union, and a union gets a decode-onlyTermViewwith nog_idand no index access.Union lanes. Each lane gates on
match ctx.index_scope():Oneis today's lane unchanged,Unionis its union variant (stamped as its own site,…_union),Emptyanswers nothing without reading an index, anything else falls back. A union variant that can't prove a case exact declines with a named reason (fallback:novelty,fallback:arena_type,fallback:list_view,fallback:store_mismatch,fallback:kill_switch). The union variants sit behind the fast-path kill switch, so the general plan stays a differential oracle for them.5dbaa226c), deduplicating by adjacency on the full key(s, p, o_type, o_key, o_i), which is exact in every index order. The object count, the per-predicate count and the grouped count read through it.43d844871).bd4911ee4).219aefe52), keying big numbers by value.3b96f416c), and emits its rows encoded (ca5cf37a2).a787bf7ac).3945cb0b5). Each member resolves its branch and the probed predicate through main'sbranch_or_none/p_id_or_nonewith its own plan, as one graph does (be4c6ae4a), so a member the index has no branch for reads nothing, and one asked to merge novelty there is refused rather than answered short. Todayplan_union_probedeclines any member with novelty, so this changes no answer; it keeps the union from depending on that.Fact identity. A member scan records beside each row the fact it matched (
RowFact: the term a constant object matched, and the list position), and the union's dedup keys on the row plus its fact (608869cb2). Every reader that collapses a union's rows now keys on one set,UnionFactSet(c0edf3f9b), whose keys are 16-byte terms in one buffer, so a kept row allocates nothing of its own. The edge-annotation chain under a union is built once over the whole union instead of once per source (1c756de51).Union rows stay encoded (#2015). Members no longer decode every value as they scan (
b14f0cda5). The one kind of value that's only meaningful inside its graph — an arena handle (a big decimal, a vector), numbered per(graph, predicate)— now carries its graph inBinding::EncodedLit(arena_g_id,9f9869c0d), so it decodes through its own graph anywhere and compares by value where equality matters. Decoding fails closed: an encoded value that can't be decoded is an error, not a value passed through (0e1262e09), with the per-row paths kept as lean as before (7d0f33cbb).Lists (#2217). A list's members are values of the predicate that holds it on both surfaces, a fact per list position, so the union lanes run on list predicates for SPARQL as for JSON-LD, and a repeated member counts each time. Where a request still reads lists as RDF (the Graph Store
GET), a union lane meets cells no stored row is, and stands down withfallback:list_viewfor the general plan.The original follow-up's typed-string and expression work is unchanged from its review: the range scan keeps a bound string's datatype, re-coded into the scanned ledger (that's #1771); a SPARQL typed literal in an expression lowers as
STRDT; and the re-coding happens only where codes can differ.From review. Each of these has a test that fails without it.
8a41c82c6). Every op is lowered before the first one stages, but each carried only the namespaces lowered up to it, so an op that registered a namespace while staging (an IRI it binds and writes) took a code the lowering had already given a later op's namespace, and the request failed on every retry. Each op of a multi-op request now carries the whole request's lowered namespaces.bfded8dfc): the fact a member matched is re-coded with its row (stamp_row_facts). Withex:coded differently in two ledgers,?s ex:p "v"^^ex:dtover both returned a subject both hold twice, and a groundCOUNT(*)counted 2, once this branch made the Multi-ledger datasets: datatype-constraint Sid is never re-encoded per graph, so cross-ledger custom-datatype matches silently drop #1771 shape match.da06179fd,cdd0d7c7c). The per-predicate count checkpoints per batch, reads through the fuel tracker and charges its by-value set as it grows, reserving at most 64K entries up front; a cancellation or an exhausted budget ends the query instead of declining to the general plan as a failed read does (QueryError::ends_the_query). The grouped count charges its runs per batch.42c79e490), in the pushdown's merge and the planner's: as text"…00.5Z"sorts before"…00Z", as instants after it. Both ask the scan's own comparison (ObjectBounds::string_orders_temporals).STRDTrefuses a datatype that can't be an IRI (f5fab7a83,eaa4c1bff), a number or a string with a space in it, as a type error; a datatype name with no scheme stays one term, as on every write path (graph_registry::is_iri_reference).c5a7ed68f): BM25's target and S2's geometry decode throughterm_view(), and one the scope can't decode fails the query instead of skipping the row. Unreachable today (the planner puts search patterns first), so the tests drive the operators.e8b749d30):PlanningContext::current()/history()default toScopeKind::None, as their doc said; EXPLAIN's physical plan and policy queries name their scope (with_dataset_scope(None)).60f3b9aac), under a view policy and across ledgers: a tag the index holds reads its own object type, a tag it doesn't hold reads novelty only.d9b3b2592). Union rows stay encoded, so a FILTER or BIND over a union decoded each value throughterm_view(), which walked the dataset and rebuilt the member set every time. On an EC2 c7i.8xlarge (dev-fast profile, two interleaved rounds, the median of 9 runs each):FILTER(STRLEN(?o) > 3)over a 200,000-value union ~103 ms → ~97.5 ms, itsBINDtwin ~106 → ~100 ms, and one graph 32.8 → 31.2 ms, since the one-graph decode built a view per value too.=against a typed literal pushes into the scan as that term (154b64e7d,d8ed067ad).FILTER(?o = "x"^^ex:T), for a datatype with no value space of its own (a custom datatype,xsd:anyURI,xsd:token), was evaluated per row, since SPARQL lowers the literal toSTRDT("x", ex:T)and a pushed string bound could only be thexsd:stringterm (main pushed it as the plain string, and matched the text under any datatype).STRDTof two constants now folds into an=bound that carries its datatype (ObjectBounds::string_datatype), on both surfaces (JSON-LD's(str-dt "x" "ex:T")too); each reader resolves the datatype against what it reads, and an indexed scan seeks the term as?s ex:p "x"^^ex:Tdoes. Numeric, temporal, boolean and JSON datatypes compare by value and stay evaluated. On an EC2 c7i.8xlarge (dev-fast profile, two interleaved rounds, the median of 9 runs each), over 100,000 values:FILTER(?o = "v7"^^ex:T)~90 ms evaluated → 0.05 ms pushed, thexsd:anyURItwin 122 → 0.05 ms; main took 6.0 and 7.8 ms, and for the custom datatype also returned the plain"v7". The controls held: a plain=0.06 → 0.05 ms (main 6.0 ms, with the typed row too) and a numeric range 1.30 → 1.27 ms (main 1.37 ms).5297e5c5f): the scan's range fallback (a view policy that touches the predicate, a dataset spanning ledgers), property paths' Sid lane, list entries, the RDF list view, shortest paths and search readability read the index without the query's tracker, so the leaflets they touched cost nothing; they're charged at the index-touch rate now, like the scan's index lane.090d29cb0). The fast paths read the index through cursors that carried no tracker and through raw leaflet loads, and the property path's id lane through batched lookups with no tracker, so a tracked query one of them answered paid its floor and its rows however much it read, andmax-fuelcouldn't stop it. Every one of those reads now charges the query's tracker one index touch per leaflet, as the scan's cursor does: the cursor builders infast_path_commonand the cursors the lanes build themselves (count plans, union star counts, vector and constant-star top-k, string-prefix counts, label regex, geo search), the count plans' leaf iterators, the group-by-object count's loads, whole-graph aggregates, andbatched_lookup_*under the frontier's sweeps. Raw leaflet loads go through two helpers that take the tracker (load_leaflet_projection, cached, andload_leaflet_columns_charged), so a load that skips the charge doesn't compile; a cache hit is charged like a miss. A leaf-directory read that decodes no leaflet isn't charged, as in the cursor. The charge sits where the cancellation check already did, once per leaflet, never per row.e99940414). The batched probes read the index throughLeafScan::load_leaflet: the subject probe and the subject star, the bound-object walk (POST, perf(query): probe bound objects in the predicate's POST partition #2374's) and the union's walk, the semijoin's index walk. They charged the rows they matched but not the leaflets they read;load_leafletnow takes the query's tracker and charges one index touch per leaflet, so a probe that loads a leaflet is charged by construction. What stays uncharged: a leaf-directory read that decodes no leaflet (as in the cursor), and the reads that aren't a query's own, such as a view policy's class lookups, the time resolution of anas-of, a ledger view, the indexer and the formatter. History scans already charged their leaf touches.090d29cb0). About 50 cursor and leaflet reads in the fast paths folded the read's error intoQueryError::Internal, which turned a fuel refusal (or a residency miss) into a 500, including in the merged-cursor lanes that already charged. They go throughQueryError::from_ionow, which keeps both.f033bc823,06fc82468): the union probes' per-member plans takeLaneOutput::Encoded(Batched join lanes run under reasoning and decode what they emit #2271), since they emit encoded rows and the union probe declines eager materialization; the cyclic cascade, which main now has decode for an eager caller, takesDecodesForEager, and its union reads decode the same way; and main's flush now hands a declined plan's rows to the per-row path, which under a union (where the one-graph plan always declines) would have stamped the union probeproceedand never run it. That check is kept to the one-graph lane, and the lane suites now also require a batched flush span wherever the union probe must fire (b2aeb8e68).What the fuel costs. Every lane charges the exact leaflets it reads; none needed an estimate, since the charge costs nothing measurable, tracking off or on.
d86a29734). The one cost the charge showed was in the count iterators: their refill is inlined into the per-group loop, and the charge kept the tracker live across it, so every group paid for one more saved register, about 1.1% more instructions on the count plan, tracking off or on. Those refills are out of line now, andcharge_leafletinlines only its enabled check. Measured on an EC2 c7i.8xlarge (fat-LTO release builds, 1,000,000 subjects, rayon on one thread so its spinning doesn't count), instructions per query against main, the same with tracking off and on: the count plan −1.9%,MINUS−4.1%,EXISTS−4.1%,OPTIONAL−0.9%; the chain fold, a class-anchored aggregate, geo search, a numeric-compare count and the path's id lane within 0.6%; a range scan −5.1%. Against the commit before the charge, every lane is within 0.1% but the group-by-object count, whose ±1% is inside its run-to-run spread. Wall time over 5 interleaved runs of 20 queries: the single-threaded lanes within 1% of main (label regex and the range scan 2% faster), and the parallel count lanes 2–21% faster than main, though at a few milliseconds a query their run-to-run spread (5–30%) is wider than the difference between commits.ae72f55f6, perf(query): probe bound objects in the predicate's POST partition #2374), on the same box and build, 100,000 subjects, instructions per query against mainf42ea3784and this branch's head before that merge (06fc82468), tracking off and on alike: the count plan −1.94% against main and the same as before; the cyclic join and a one-or-more path count unchanged; the union bound-object probe 3.3% under the head before the merge; and a union join on a string object, which the merge first sent to the per-row scan (+2.6%), 68.8% under it once the union's walk took strings (09da10e44): 247M instructions a query against 790M, 25 ms against 96 on the clock, and 3.6× under main's (wrong) answer. The leaflet charge inload_leaflet(e99940414) costs nothing measurable: against the commit before it, the one-graph subject and bound-object probes and both union probes are within 0.1%. The one-graph bound-object probe, main's code now, reads +0.1% against main and the subject probe +0.25%, and a constantGRAPHblock +0.5%; all three were there before the merge too, in the branch's shared query path rather than the probes, and the clock doesn't see them: wall time is within ±2% of main on every lane that takes over a millisecond. (The count plan, at under a millisecond, swings more run to run than any of these differences.)42bb9646cto149d02d81, 223 commits that don't touch the lane. Profiled, main inlines the numeric filter (filter_subjects_by_numeric_gtand the row walk under it) into the operator, and this branch keeps the filter as its own function;#[inline(always)]on the filter made it worse (112.44M, +1.4% against main), and on both functions brought it to +0.27%, never to main's count. Label regex moves 0.4% between main commits that don't touch it as well. Wall time is flat on both at 1,000,000 subjects (77.97 against 77.80 ms; 53.60 against 54.69 ms), so they stay as they are, rather than pinned to an inlining the next unrelated change can flip.Behavior changes against main
WHERE): a pushed= "a"no longer matches"a"@enor"a"^^ex:T. The full table is in the string-filter section below.=a temporal, while ordering still reads it as one, so<=and>=can both hold where=doesn't. SPARQL has no=operator for anxsd:stringand anxsd:dateTime, so it's a type error and the FILTER is false. Two of fix(transact): write fidelity, part 2 — one fact identity, microsecond temporals, value reads #2109's microsecond tests expected=to hold there (a JSON-LD filter's bare string against a storeddateTime, and a stored plain string against a typed constant); they now expect false, and their ordering checks are unchanged (ba1d81980).STRDT, typed literals and JSON-LDstr-dtbuild their literal for any datatype IRI, and an update can write an IRIIRI()/UUID()/(iri …)builds in an unseen namespace. JSON-LD'sstr-dtand constantiriarguments expand through the@contextunder the insert's compact-IRI guard. Table in the STRDT with an unregistered datatype IRI fails the query instead of producing the literal #1765 section below.?j1 != ?j2,?j1 < ?j2and the truth value of a JSON value are now type errors, so those rows drop."…"^^rdf:JSONis refused on insert: binding one and then inserting it now returns 400. It used to be stored as a plain string.iriarguments go through the compact-IRI guard, which by default refuses a prefix the@contextdoesn't define, so an IRI in a scheme liketag:,arn:,doi:orinfo:is refused as an undefined prefix unlessopts.strictCompactIriisfalse.STRDTwith a datatype that can't be an IRI (a number, or a string with a space) is a type error: unbound in a query, and an update fails. It used to build a literal typed with the string, which an update stored, or for a number a plain string.FILTER(?at > "…00.5Z") FILTER(?at > "…00Z")answers as evaluated.max-fuelmay now be refused.FILTER(?o = "x"^^ex:T)and its JSON-LD twin push into the scan for a custom datatype,xsd:anyURIorxsd:token, and match only that term; the answers are those the evaluated filter gave on this branch.max-fuelmay now be refused. A refusal inside one of these lanes is a fuel error (400), where it could surface as an internal error (500).COUNT(?s)over a bare decimal or big integer takes the one-graph count instead of falling back; same answers.No wire or index format changes.
ObjectBoundshas a new field,string_datatype(a struct literal needsstring_datatype: None). Two more API notes for an embedder:fluree_db_core::RangeMatchhas a new public field,lang(a struct literal needslang: None, or..Default::default()), andPlanningContext::current()/history()now plan for no index untilwith_dataset_scopegives them their scope (with_dataset_scope(None)for a ledger's own default graph).fluree_db_binary_index::batched_lookup_predicate_refs,batched_lookup_subject_propertiesandbatched_lookup_inbound_refstake the reader's&Trackerlast (&Tracker::disabled()reads unpriced). New public items, additive:QueryError::ends_the_query,ObjectBounds::string_orders_temporals,graph_registry::is_iri_reference,ExecutionContext::with_term_view,fluree_db_core::StringDatatype,Expression::as_typed_string_literal.Known limits
fulltext()under a union still scores against one graph's BM25 arena (Scopes of several graphs: a one-graph witness type, and the readers that still read one graph #2075).Tests
Every lane runs on one shared fixture, the multigraph fixture (
fluree-db-api/tests/support/multigraph.rs): 17 scopes (each union spelling,FROM NAMEDalone,GRAPH, two ledgers, time travel below the index, and unions over a default graph the index holds no leaf for) in three states (indexed, novelty in g2, read below the index), SPARQL and JSON-LD, against hand-written answers and against the general plan with fast paths off, with routing stamps (MustFirethe union site,MustNotFirethe one-graph site, and the reverse on one graph).it_multigraph_lanesholds each lane's matrix, plus two list fixtures — lists on every lane's own predicate in two members, and the same lists only in novelty — where every lane shape answers a hand-written answer on both surfaces, fast paths on and off, SPARQL routes as JSON-LD does, and over indexed lists every union site must fire. One canary keeps the RDF view honest: the per-predicate count with the Graph StoreGET's execution option must stand down withfallback:list_viewand answer the cells. Wherever the nested-loop union probe must fire, the run must also have opened a batched flush span, since the stamp is set at planning, before a flush could still hand its rows to the per-row path. The union probes have their own fixture (support/union_probes.rs) for fact-identity cases its probes must keep apart, and traps for arena literals crossing every consumer (scan, ORDER BY, FILTER, DISTINCT, GROUP BY), on both union spellings, indexed and with novelty.it_union_annotation_chain,it_cyclic_bgp_multiplicityandit_string_filter_pushdownare their own binaries, since they toggle the kill switch;it_union_fact_identityholds the switch lock insidegrp_query.it_sparql_list_members's CONSTRUCT case (from #2217) also runs against an index and overFROM <g1> FROM <g3>, where only one of the two graphs holds the list, so the list rows reach the template encoded and decode through the scope's terms (be4c6ae4a).The red/green record (each fix shown failing without it), the merge log for all seven main merges, and the per-area test lists are in this comment, to keep the description under GitHub's size limit.
Gates
On Linux (EC2 c7i.8xlarge, Amazon Linux 2023 with gcc 14, linked with mold as CI does), all at the head,
09da10e44:cargo fmt --all -- --check, and intestsuite-sparql/: clean.cargo clippy --all --all-features --all-targets --locked -- -D warnings: clean. Intestsuite-sparql/,cargo clippy --all-targets -- -D warnings: clean.cargo check --workspace --all-targets --lockedandcargo check -p fluree-db-server --no-default-features --features native --locked: clean.it_multigraph_lanes,it_union_annotation_chain,it_cyclic_bgp_multiplicity, and every union / lane / fast-path / batched / probe test offluree-db-api,it_fast_path_fuelincluded): 269 of 269.cargo nextest run --workspace --all-features --no-fail-fast --locked: 16,305 of 16,305.cargo test -p fluree-db-api --all-features --test harness_coverage: 2 passed.cargo test --workspace --all-features --doc: 48 passed.cargo test --no-fail-fastintestsuite-sparql/: 85 tests across its 31 result groups (the W3C manifest groups, its unit tests and thew3c_rdfmanifests) pass.Earlier full runs this round, at the heads before main moved, each met one of main's load flakes, both of which passed alone right after:
it_wal::a_transaction_costs_one_flushandit_transact_update_indexed::multi_op_reversal_nets_a_value_the_index_keeps_less_of.Merged with main
Seven merges of
main, the lastae72f55f6(mainf42ea3784, with #2374), plus09da10e44, which lets the union object probe walk string objects too after that merge. How each conflict was resolved is in the evidence comment.FILTER string comparisons keep their term semantics when pushed
FILTER(?o = "a"), and<,<=,>,>=against a plain-string constant, are pushed into the scan as object bounds and the filter is dropped. The bounds compared only the decoded value, so a pushed= "a"also matched"a"@en,"a"@frand"a"^^ex:T. The same comparison evaluated (under||, or as!=) is strict, as decided in D-12 / #1462, so"a"@ensatisfied both= "a"and!= "a". This hit SPARQL, JSON-LD filters and CypherWHERE s.p = "a"alike, and it's why W3Cexpr-equals#eq-4was on the skip register. The register's note there blamed late materialization; the filter never actually ran on that test, since it was pushed.A pushed bound now answers what the evaluated filter answers, for every kind of stored value, on every lane that applies bounds. A string bound is the
xsd:stringterm: it equals onlyxsd:stringobjects, and it ordersxsd:stringobjects and (as the evaluator does) temporal values it can be read as, never a tagged or otherwise-typed string, a number, a boolean or an IRI.What changes
ObjectBoundsmatching takes the stored object's datatype.matches(value, dt)for a flake,matches_encoded(value, o_type)for a binary-index row, andmatches_numberfor the range semijoin's numeric check. The old value-onlymatchesis gone, so the compiler listed every consumer (16 sites, in the binary scan, the batched join probes, the range provider, history, and the range semijoin), and none of them can apply a string bound by text alone anymore.is_xsd_string_datatypeinfluree_db_core::datatypesrecognizes every form a datatypeSidtakes.=never equates a string with a temporal.<,<=,>and>=do order a plain string against adateTime,dateortimevalue by reading it as a value of that kind, as the evaluator does, soFILTER(?at < "2026-01-02T00:00:00Z")overxsd:dateTimekeeps returning what it did. Both sides now order through one function,fluree_db_core::temporal::cmp_with_lexical. That's the function fix(transact): write fidelity, part 2 — one fact identity, microsecond temporals, value reads #2109 introduces to read such strings to the microsecond, so when it lands the scan and the evaluator move together. The temporal slices a string bound seeks are derived from the same function.=and>= && <=push the same two bounds, though, soObjectBoundsnow carriestemporal_string_ordering, set only when no=contributed (RangeConstraint::from_equalitytracks it through the planner's merges). Before this,FILTER(?d = "2026-01-01")overxsd:datematched when pushed, and so didFILTER(?s = "2026-01-01"^^xsd:date)over anxsd:string(on novelty; the index already seeks only dates there), while both are false when evaluated.The binary index seeks the slice the bound admits. POST orders by
(p, o_type, o_key), so a string bound now seeks the predicate'sxsd:stringslice instead of decoding every row the predicate holds. An equality seeks its one string id, as the constant?s :p "a"does, or falls back to novelty alone when the index has never seen the string. A range whose string parses as a date (or another temporal) also seeks those temporal slices. Thestring_bound_seekrouting stamp marks it.Separate FILTERs that can't be merged keep their filter. Two FILTERs on one variable with bounds that can't be ordered against each other (
FILTER(?o > 1) FILTER(?o > "a")) used to merge by picking one bound by type order and consuming both filters, which dropped the other filter.merge_object_boundsnow returnsNonethere, and the second filter stays as a filter. Two string bounds on one side are unorderable too when the bounds order strings against temporals and either string reads as one, since a temporal row orders them by instant and a string row by text (42c79e490, from review; the planner's merge does the same).Only a plain string is read as a temporal. The evaluator read any string-backed literal as a date for
</>, so"2026-01-01"@enand"2026-01-01"^^ex:TpassedFILTER(?d < "2026-02-01"^^xsd:date), though each is a term of its own type. Now it's a plain string only (a simple literal orxsd:string), in either direction, in the evaluator and the bounds alike.A string bound is read as a temporal once per kind. A plain-string range over temporal rows parsed the bound for every row.
temporal::lexical_as_kind_ofreads a lexical as a temporal kind by the same parsecmp_with_lexicaluses (a test pins that the two agree), andObjectBounds::preparekeeps that reading per kind for the scan and the flake lanes.A temporal range also seeks the
xsd:stringslice. A typed-date range sought only the date slice on the index, so a plain string stored as"2026-01-01", which<orders against the date, passed on novelty and was never read on the index. The scan now seeks thexsd:stringslice beside the date one, without the date key range.=never equates the two and keeps the single seek.@fulltextand JSON compare as their own datatypes, and the string builtins read them as text. An@fulltextvalue isf:fullText(asdocs/indexing-and-search/fulltext.mdputs it), so a pushed string bound leaves it out. The evaluator matched it as a plain string on the index only, where it stays late-materialized, and now carriesf:fullTextthere too. JSON reached the evaluator as a plain string on both lanes, so evaluated=and<matched it where the pushed bound didn't; it's anrdf:JSONliteral now. On novelty,CONTAINS,REGEX,STRSTARTS,SUBSTR,CONCATandSTRBEFORErefused an@fulltextvalue (SUBSTRfailed the whole query). All the string builtins now take arguments through one accept-set,reads_as_text(a simple literal,xsd:string, a language tag,@fulltext,rdf:JSON), wherestring_arg,STRBEFORE/STRAFTERandCONCATeach kept a copy, andCONCAT's had drifted.An
=against a typed literal is a bound of its datatype. A string bound used to be thexsd:stringterm only, soFILTER(?o = "a"^^ex:T)was evaluated rather than pushed.ObjectBoundsnow carries a datatype for an=-only string bound (string_datatype), folded fromSTRDTof two constants for a datatype whose value is a string; it matches only objects of that datatype, and an indexed scan seeks the term (typed_string_bound_seek).The R2RML / Iceberg lanes didn't need a change. Their pushdown only prunes files and keeps the FILTER as a residual, and the SQL lane already compares by RDF class (
exact_eq).Out of scope, unchanged and pinned: a bare JSON string as a constant object in a JSON-LD
where("ex:p": "a"), and a Cypher property map{p: "a"}. Both still match the text under any string datatype or tag, asdocs/concepts/datatypes.mddocuments.Behavior changes
Data on one property:
ex:plain "a",ex:xs "a"^^xsd:string,ex:en "a"@en,ex:fr "a"@fr,ex:typed "a"^^ex:T,ex:other "zzz",ex:b_en "b"@en; and on a date property,ex:day "2026-01-01"^^xsd:date,ex:day_s "2026-01-01".FILTER(?o = "a"),"a" = ?o,?o = "a"^^xsd:string(SPARQL);(= ?o "a"),["=", "?o", "a"](JSON-LD);WHERE s.p = "a"(Cypher)FILTER(?o < "b"),?o >= "a" && ?o <= "a",(< "" ?o "b")FILTER(?o > "")FILTER(?d = "2026-01-01")over dates and stringsFILTER(?at = "2026-01-01T10:00:00Z")overxsd:dateTime!=also held for the dateTimeBIND,VALUESand||already answeredFILTER(?d = "2026-01-01"^^xsd:date)FILTER(?d < "2026-02-01"),FILTER(?at < "2026-01-02T00:00:00Z"), and?at >= "…" && ?at <= "…"with one stringFILTER(?o > 1) FILTER(?o > "a")(two FILTERs, SPARQL or JSON-LD)"a"FILTER(?at > "…T10:00:00.5Z") FILTER(?at > "…T10:00:00Z")over a stored…T10:00:00.2ZFILTER(?o = "a"^^ex:T),"a"^^xsd:anyURI,(= ?o (str-dt "a" "ex:T"))"a"of any type, pushed as the plain string)FILTER(?d < "2026-02-01"^^xsd:date)over"2026-01-01"@en,"2026-01-01"^^ex:TFILTER(?d < "2026-02-01"^^xsd:date)over a plain"2026-01-01", pushed, on the index@fulltextvalue, evaluated= "Hello World"/< "Z"on the index@fulltextvalue withCONTAINS,REGEX,STRSTARTS,SUBSTR,CONCAT,STRBEFOREon noveltySUBSTRfailed the query)= '{"a":1}'/< "~"BIND(?json AS ?x), thenDATATYPE(?x)xsd:stringrdf:JSON!=,||forms,= "a"@en,sameTerm"ex:p": "a"(JSON-LD constant object),{p: "a"}(Cypher map)Release note:
FILTERstring comparisons are now exact on every surface. Earlier releases pushed these comparisons into the index scan and matched the string's text under any datatype or language tag, while!=and the same comparison under||were already exact, so"a"@ensatisfied both= "a"and!= "a". An LLM- or hand-writtenFILTER(?label = "Jazz")over"Jazz"@enlabels no longer matches; to compare the text whatever the tag, useFILTER(STR(?label) = "Jazz"), and to match the tag,FILTER(?label = "Jazz"@en). LikewiseFILTER(?d = "2026-01-01")no longer matches anxsd:datevalue, norFILTER(?at = "2026-01-01T10:00:00Z")anxsd:dateTimeone; write the typed literal ("2026-01-01"^^xsd:date). Ordering a date against a plain string with<or>is unchanged, but a language-tagged or custom-typed literal is no longer ordered against a typed date or time. An@fulltextor JSON value no longer equals (or orders against) a plain string on any lane; on an indexed ledgerFILTER(?ft = "…")used to match an@fulltextvalue. CompareSTR(?ft) = "…", or use the string functions, which read both as text everywhere. The same holds for JSON-LD filters and CypherWHERE.Checked, not changed: the integer
=seekFILTER(?v = 7)seeks one numeric type only when every leaflet of the predicate holds it (predicate_otype_uniform), and that check skips leaflets whosep_constnames another predicate. That's sound because no POST leaflet spans two predicates: the rebuild writer and the incremental merge both cut leaflets at ap_idchange (should_flush_for_segmentation,find_segment_end). The test pins it with two-row leaflets: a double7.0answers= 7from the index, and from novelty over an all-integer index. A mutant that always claims uniform fails those rows, and the fast-path kill switch doesn't catch it (the seek isn't a fast path); only the evaluated form does.Performance
Measured locally (macOS, instructions retired per query,
proc_pid_rusage), release profile (fat LTO), an indexed ledger of 20,000 subjects, the mean of three interleaved passes (each the median of 5 reps), the parentc898d982evs this branch.ex:paholds onlyxsd:stringvalues;ex:pbthe same text, nine in ten tagged@en/@fr;ex:nan integer control;ex:dtonlyxsd:dateTimevalues;ex:mdtthe same instants with one in ten as a plain string.FILTER(?o = "v7")FILTER(?o >= "v1" && ?o < "v2")FILTER(?o < "v5")FILTER(?o = "v7")FILTER(?o >= "v1" && ?o < "v2")FILTER(?o < "v5")FILTER(?o > 500 && ?o < 600)FILTER(?o = 7)FILTER(?o < "2026-06-01T00:00:00Z")FILTER(?o < "2026-06-01T00:00:00Z"^^xsd:dateTime)FILTER(?o < "2026-06-01T00:00:00Z"^^xsd:dateTime)FILTER(?o = "2026-03-05T10:00:00Z")FILTER(?o = "v7" || ?o = "v8")FILTER(?o < "2026-06-01T00:00:00Z" || false)The equalities used to decode every value of the predicate, and now they seek the one string id, as
?s :p "a"does. The tagged-heavy ranges drop with the values thexsd:stringslice seek no longer reads, and their rows change, which is the fix. The plain-string range over dateTime values is 16% cheaper: the bound string used to be parsed again for every row, and now it's parsed once per temporal kind (ObjectBounds::prepare), through the same readingtemporal::cmp_with_lexicaluses. The extraxsd:stringseek beside a typed-date range costs nothing measurable on a property with no strings (0.991).The one that's up is the mixed property, by 14.1%, and that's accepted as the cost of the 1,008 plain-string rows it now correctly returns and used to drop (about 3% per row, mostly decoding the strings). The evaluated temporal comparison is +0.4%, about the run-to-run spread (0.4%); what it pays for is the plain-string check the evaluator now makes before reading a string as a temporal.
Along the way, the first cut of the term check cost a numeric range scan about 2% in release, because the generic bound comparison stopped inlining under fat LTO. It's force-inlined now (the numeric rows above). An early version of the parse-once change boxed the parsed lexical on every evaluated comparison (+6.7% on the evaluated temporal shape);
cmp_with_lexicalparses onto the stack again, and a test pins that it and the parse-once path read every lexical alike.STRDT and typed literals build their literal for any datatype IRI
A BIND of
STRDT(…, <iri>), of a SPARQL typed literal like"a"^^<http://nowhere.example/T>, or of JSON-LDstr-dt, failed the whole query with "Unknown datatype IRI" whenever the datatype's namespace wasn't registered on the ledger. SPARQL 1.1 §17.4.2.9 builds the literal from any IRI, and a SPARQLINSERT DATA(or a JSON-LD insert with an absolute@type) of the same literal already succeeds and registers the namespace, so the error wasn't protecting anything a write didn't already allow. The typed-literal case is new with this branch: it now lowers asSTRDT(above), so it reached the same error, where main silently bound the plain"a". The strict check came in as an example in a utility's doc comment rather than as a documented requirement, and #1765 records the spec reading.ComparableValue::to_bindingresolved the datatype with the strict encoder, which returns nothing for an unregistered namespace. Triple-pattern constraints and VALUES rows already used the non-strict form since #1746: a registered namespace gives its Sid, and any other IRI the EMPTY-namespace full-IRI Sid, which matches nothing stored. That rule is now one function,IriEncoder::encode_datatype(fluree-db-query/src/parse/encode.rs), used by SPARQL lowering,to_bindingandDATATYPE().DATATYPE(STRDT(..))used to return an IRI whereDATATYPE(?bound)on the same value returned a Sid. Grouping already counted those as one, but a join on the two found nothing, and the output printed them two ways (nw:Tand the full IRI); they're one term now.The JSON-LD side needed one more piece. A JSON-LD insert runs
@typethrough the strict compact-IRI guard, so{"@value": "x", "@type": "bad:datatype"}is refused as a compact IRI whose prefix the@contextdoesn't define, andstr-dthas to follow the same rule or it becomes a looser second path to the same store.(str-dt ?v "xsd:integer")with noxsdin the context is the slip that makes this matter: main refused it by accident, as an unknown namespace, and without the guard it would have built a literal typed with the IRIxsd:integer, which an update would then persist under a newxsd:namespace. A constantstr-dtdatatype is now expanded the way an insert's@typeis (expand_str_dt_datatypeinparse/where_clause.rs): through the@context, under the same guard, at parse time. A datatype computed at run time (a variable,IRI()) is already an IRI. SPARQL keeps taking any absolute IRI in angle brackets, as itsINSERT DATAdoes.An update that stores such a literal goes through the flake generator's canonicalization (#2009), which re-encodes an EMPTY-namespace datatype through the transaction's registry, so the stored flake carries the namespace code the write registers. That's the same Sid a direct insert of the literal gets, after a reload, an index build and a reindex at the same
t. A DELETE of a literal no fact can carry retracts nothing and registers nothing. A datatype name with no scheme ("T") splits to the empty prefix on every path, so a JSON-LD insert,INSERT DATA,str-dtandSTRDTall store it as the same EMPTY-namespace term.IRI()in an update, and JSON-LDiriconstantsThe same gap had an IRI side. An update whose template took
IRI("http://unseen.example/x"),UUID()or JSON-LD(iri ..)from a BIND, in a namespace the ledger hadn't registered, failed with "Raw IRI from graph source cannot be used as object for flake generation" (or subject, or predicate), whileINSERT DATAof the same IRI succeeds and registers the namespace. A query already returned the IRI, as §17.4.2.8 says it should. Flake generation now gives such a binding the encoder's fallbackSid(EMPTY, iri), the form a WHERE constant in an unseen namespace already has (bound_iri_sidinfluree-db-transact/src/generate/flakes.rs). An assertion canonicalizes it under the namespace the write registers (#2009), so the update stores the termINSERT DATAstores, and a retraction keeps it, so a DELETE of an IRI nothing holds retracts nothing and registers nothing. A_:label (BNODE()output) or a string that isn't an absolute IRI still names nothing to write, and is refused as before.That made JSON-LD's
irithe same kind of looser second path thatstr-dtwas.(iri "ex:x")never expanded through the@context, so with only the flake fix an update would have stored the IRIex:xunder a newex:namespace instead of the term{"@id": "ex:x"}stores. A constantiriargument is now expanded the way an insert's@idis (expand_iri_argumentinparse/where_clause.rs): through the@context, under the same strict compact-IRI guard, so"bad:thing"with nobadprefix is the insert's "Unresolved compact IRI" error andopts.strictCompactIri: falsetakes it verbatim. An argument computed at run time is taken as it is. This applies in queries too, which is why it's its own commit:["iri", "ex:knows"]used to match nothing, andfilter_iri_operand_forms_across_spellingspinned that; it now matches as the full IRI does. While in there, array-form filters turned out to skip this walk entirely, so a constantstr-dtdatatype in an array-form filter wasn't expanded either; both arguments now expand in every expression form, and the array form's bare atoms stay strings.Behavior changes
BIND(STRDT(?v, <http://nowhere.example/T>) AS ?x), namespace unregisteredDATATYPE(?x)is the IRISTRDT(?v, "not an iri"),STRDT(?v, 5),(str-dt ?v "not an iri")<T>,"T") is still one term, as on every write pathBIND("a"^^<http://nowhere.example/T> AS ?x)"a"on main; the error above at this branch's parentSTRDT("a", <bad:datatype>),"a"^^<bad:datatype>INSERT DATAaccepts)INSERT { ?s ex:p ?x } WHERE { … BIND(STRDT(…) AS ?x) }and the JSON-LDstr-dtupdateDATATYPE(STRDT(?v, <T>))againstDATATYPE(?x)with?xthe same literal (fromVALUES, or bound), joined or printedVALUESon main; a BIND failed); the two printed differently(str-dt ?v "urn:example:dt"),"http://…", or?dtbound to an IRI(str-dt ?v "ex:T")withexin the@context(str-dt ?v "bad:datatype"),(str-dt ?v "xsd:integer")with no such prefix@typegives in an insertFILTER,IN,sameTermINSERT { … ?x } WHERE { BIND(IRI("http://unseen.example/x") AS ?x) },UUID(),(iri ..), as subject, predicate or objectINSERT DATAof it(iri "ex:x")withexin the@context, query or updateex:x(a query matched nothing; an update was refused)(iri "bad:thing")with no such prefixbad:thingin a query; refused in an update{"@id": "bad:thing"}gives (strictCompactIri: falsetakes it verbatim)["str-dt", ?v, "ex:T"]in an array-form filterRelease note:
STRDT, a SPARQL typed literal and JSON-LDstr-dtnow build their literal for any datatype IRI, including one in a namespace the ledger hasn't seen, where they used to fail the query with "Unknown datatype IRI". In JSON-LD, astr-dtdatatype written as a string is expanded through the@contextand checked by the same compact-IRI guard as an insert's@type:"ex:T"withexdefined is the expanded IRI, and"xsd:integer"with noxsdprefix is refused with "Unresolved compact IRI" (setopts.strictCompactIri: falseto take it verbatim, as an insert does). An update now writes an IRI thatIRI(),UUID()or JSON-LDiribuilds in a namespace the ledger hasn't seen, where it used to fail with "Raw IRI from graph source cannot be used as …". A constant JSON-LDiriargument is expanded through the@contextlike an@id:["iri", "ex:knows"]withexdefined is the full IRI (it used to match nothing), and an undefined prefix is refused with "Unresolved compact IRI" unlessstrictCompactIriisfalse. A datatype that can't be an IRI (a number, or a string holding a space or another character no IRI holds) is now a type error, where it used to build a literal typed with that string.