|
From: Duncan P. <no...@gi...> - 2026-10-14 16:04:48
|
Branch: refs/heads/develop Home: https://github.com/eXist-db/exist Commit: 226d33084135284f4c4c19f11b6e29e26aaca3dd https://github.com/eXist-db/exist/commit/226d33084135284f4c4c19f11b6e29e26aaca3dd Author: Juri Leino <gi...@li...> Date: 2026-10-06 (Tue, 06 Oct 2026) Changed paths: M exist-core/src/main/java/org/exist/xquery/ForExpr.java M exist-core/src/main/java/org/exist/xquery/WhereClause.java A exist-core/src/test/xquery/xquery3/where-single-step.xqm Log Message: ----------- [bugfix] Only evaluate a where clause in a single step if it navigates from the for variable WhereClause.preEval evaluates the where expression once for the whole input sequence of the outer for clause, binding the for variable to all input items, and maps the resulting nodes back to the input items via their context. That is only correct if the where expression navigates from the for variable. If the variable is used as a value, e.g. as a comparison key in a predicate (`where $items//item[name = $q]`), or if the result is not mapped back through the node context (`where $d[name = 'x']`, `where matches($d/name, 'x')`, `where ft:query($d/name, 'x')`), the where clause silently drops all items. Variables bound by intermediate let/for clauses have no value at all yet. Only use the single step evaluation if every reference to the outer for variable is in a navigating position (path root, left operand of a comparison, operands of and/or) and no variable of an intermediate clause is referenced. Unknown expressions fall back to per-item evaluation. This is the actual cause of https://github.com/eXist-db/exist/issues/2204, which was previously masked in the index functions only. Co-Authored-By: Claude Opus 5.5 (1M context) <no...@an...> Commit: dcd6c04675a5cea680706143be7e593b163c384d https://github.com/eXist-db/exist/commit/dcd6c04675a5cea680706143be7e593b163c384d Author: Juri Leino <gi...@li...> Date: 2026-10-06 (Tue, 06 Oct 2026) Changed paths: M extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/FieldLookup.java M extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/Lookup.java A extensions/indexes/range/src/test/java/org/exist/xquery/modules/range/LoopVariableLookupRegressionTest.java Log Message: ----------- [bugfix] Do not force per-item evaluation of range lookups keyed by a variable Since the fix for #2204, range:eq and range:field-eq report a CONTEXT_ITEM dependency whenever a key argument references a variable. The range index rewriter turns `item[id = $id]` into such a lookup even without an index, so `collection($c)/item[id = $id]` inside a for loop is evaluated once per document. Each of those evaluations runs the optimize pragmas over the whole context sequence, making every iteration quadratic in the collection size: ~20x slower than 6.4.1 for the reported query. The dependency was only a mask for the where clause single step evaluation, which now checks the where expression itself. Restore the previous getDependencies(). Closes https://github.com/eXist-db/exist/issues/6619 Co-Authored-By: Claude Opus 5.5 (1M context) <no...@an...> Commit: 2536344afa69ce52b12ff9d9a80b0671c79593f7 https://github.com/eXist-db/exist/commit/2536344afa69ce52b12ff9d9a80b0671c79593f7 Author: Juri Leino <gi...@li...> Date: 2026-10-06 (Tue, 06 Oct 2026) Changed paths: M extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/Query.java M extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/QueryField.java M extensions/indexes/ngram/src/main/java/org/exist/xquery/modules/ngram/NGramSearch.java Log Message: ----------- [optimize] Do not force per-item evaluation of full-text and ngram lookups keyed by a variable ft:query, ft:query-field and ngram:contains report a CONTEXT_ITEM dependency whenever a query argument references a local variable, which forces the enclosing path to evaluate them once per context item, the same cost as https://github.com/eXist-db/exist/issues/6619 for range lookups. The dependency was only a mask for the where clause single step evaluation, which now checks the where expression itself. Restore the previous getDependencies(). The #2204 for-variable tests of both modules still pass. Co-Authored-By: Claude Opus 5.5 (1M context) <no...@an...> Commit: 8cece0d229e85cb67403a1a95058cd31fea36ab9 https://github.com/eXist-db/exist/commit/8cece0d229e85cb67403a1a95058cd31fea36ab9 Author: Juri Leino <gi...@li...> Date: 2026-10-06 (Tue, 06 Oct 2026) Changed paths: M exist-indexes-jmh/README.md A exist-indexes-jmh/src/main/java/org/exist/indexing/jmh/LoopVariablePredicateBenchmark.java Log Message: ----------- [test] Add a JMH benchmark for predicates keyed by a variable over many documents The where clause benchmarks load three documents, so they cannot show costs that grow with the number of documents in a step's context sequence, as in https://github.com/eXist-db/exist/issues/6619. LoopVariablePredicateBenchmark stores 100 to 4000 small documents, with and without a range index, and runs the predicate with a literal, an outer variable and a loop variable as key, plus a where clause that is evaluated in a single step and one that has to be evaluated per item (#2204). Co-Authored-By: Claude Opus 5.5 (1M context) <no...@an...> Commit: b31c793ed67fcd978ad41bf1e54352d364b2bd96 https://github.com/eXist-db/exist/commit/b31c793ed67fcd978ad41bf1e54352d364b2bd96 Author: Duncan Paterson <dun...@us...> Date: 2026-10-14 (Wed, 14 Oct 2026) Changed paths: M exist-core/src/main/java/org/exist/xquery/ForExpr.java M exist-core/src/main/java/org/exist/xquery/WhereClause.java A exist-core/src/test/xquery/xquery3/where-single-step.xqm M exist-indexes-jmh/README.md A exist-indexes-jmh/src/main/java/org/exist/indexing/jmh/LoopVariablePredicateBenchmark.java M extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/Query.java M extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/QueryField.java M extensions/indexes/ngram/src/main/java/org/exist/xquery/modules/ngram/NGramSearch.java M extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/FieldLookup.java M extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/Lookup.java A extensions/indexes/range/src/test/java/org/exist/xquery/modules/range/LoopVariableLookupRegressionTest.java Log Message: ----------- Merge pull request #6801 from line-o/fix/6619-collection-in-loop [bugfix] Fix quadratic range lookups keyed by a loop variable and the where clause single step evaluation Compare: https://github.com/eXist-db/exist/compare/2047f531827c...b31c793ed67f To unsubscribe from these emails, change your notification settings at https://github.com/eXist-db/exist/settings/notifications |