Repository navigation
fix(#8666): serve LIKE 'prefix%', STARTS WITH and Cypher min()/max() from the index - #8669
Conversation
…from the index SQL: the planner adds the range [prefix, successor) next to a LIKE on an ordered, case sensitive index over a STRING property, keeping the LIKE as a filter. A parameter pattern shapes the plan, so that plan is not cached. Cypher: STARTS WITH becomes a NodeIndexRangeScan range (the predicate stays a filter); a bare min()/max() over one indexed property reads one end of the index (IndexMinMaxStep), like SQL's MIN/MAX FROM INDEX.
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 47 |
🟢 Coverage 96.72% diff coverage · -6.00% coverage variation
Metric Results Coverage variation ✅ -6.00% coverage variation Diff coverage ✅ 96.72% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (66a82a8) 198662 167204 84.17% Head commit (7adb86a) 231408 (+32746) 180872 (+13668) 78.16% (-6.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#8669) 183 177 96.72% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Review of #8669 (LIKE prefix / STARTS WITH / Cypher min-max from index)Overall this is a careful change. The range is only ever a superset with the original predicate kept as a filter, 1. Possible missed rows: Cypher
|
… more tests A case-insensitive index holds case-folded keys, so the folded successor bound could drop rows the predicate accepts (STARTS WITH 'AZ' missed 'azb'). Skipped at anchor selection and at execution. Adds tests for a CI index, non-string parameters and a delete in an open transaction; INDEX_ORDERED_KEY_TYPES is now unmodifiable.
|
Review of #8669 (prefix range for I read the diff and cross-checked it against the code it touches. I did not run the tests: the sandbox blocked the Maven command. Verdict: no blockers. The design is sound and the tests are thorough. Everything below is minor. What I checked and found correct
Suggestions
Nice work on the failure-mode reasoning. Both the case-folded index and the |
…; import order, DISTINCT note
ReviewSolid, carefully reasoned change. The design (range bounds as a superset with the original predicate kept as a filter, collation-independent) is the right one, and the edge cases are well covered: UTF-16 vs UTF-8 successor, case-insensitive indexes, Things to address
Minor / optional
TestsGood coverage (25 new tests plus No security concerns. Performance-wise the change is a clear win (index range or one-end read instead of a type scan), with no extra allocations on the hot paths beyond the one-off bound computation. Not run locally: I reviewed the diff only, not the test suite. |
Review of #8669Overall this is a careful, well-reasoned change. Keeping the original I did not compile or run the tests here. This review is from reading the diff. Things to address
Minor
Security / performanceNo security concerns: the LIKE prefix bounds are built with plain string operations and no new regex compilation. Performance is the point of the change: index-bounded min/max and prefix range scans instead of full scans, with negligible planning overhead. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8669 +/- ##
============================================
+ Coverage 75.87% 75.90% +0.02%
- Complexity 3485 3487 +2
============================================
Files 2058 2059 +1
Lines 198662 198838 +176
Branches 41803 41864 +61
============================================
+ Hits 150734 150920 +186
+ Misses 31499 31467 -32
- Partials 16429 16451 +22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #8666
What
LIKE 'abc%': the planner addss >= 'abc' AND s < 'abd'next to theLIKEwhen an ordered, case sensitive index covers a STRING property. TheLIKEstays as a filter, so the answer never depends on the collation. The prefix is what precedes the first wildcard (\%and\?read as literals), so'ab?d%'and'abc%def'are bounded too. A parameter pattern shapes the plan, so that plan is not cached for other parameters.STARTS WITH: contributes the same two bounds toNodeIndexRangeScan(literal or parameter, the successor is computed when the parameter is resolved); the predicate stays as a filter.min(n.p)/max(n.p):MATCH (n:L) RETURN min(n.p)reads one end of the index (IndexMinMaxStep, shown asMIN FROM INDEX). Only when the index is defined on the label itself, single property, LSM, notNULL_STRATEGY INDEX, case sensitive, on a key type whose index order is Cypher's.QueryHelper.prefixSuccessorsteps over U+D7FF, surrogates and U+FFFF so the bound holds under both UTF-16 and UTF-8 key order.Tests
Issue8666SqlLikePrefixIndexTest(8),Issue8666CypherPrefixAndMinMaxIndexTest(15). Ran the wholequery.opencypherandquery.sqlunit suites (888 classes) green.