Repository navigation
branch-4.1: [fix](search) Keep numeric SEARCH leaves on the inverted index #70488 - #70547
Open
guptashivam04 wants to merge 1 commit into
Open
guptashivam04 wants to merge 1 commit into
guptashivam04 wants to merge 1 commit into
Conversation
A SEARCH leaf on a numeric (BKD) field went through read_from_index without skip_try. When the hit count was over inverted_index_skip_threshold percent of the segment (50 by default), the iterator returned INVERTED_INDEX_BYPASS and the segment iterator fell back to row evaluation. SEARCH has no row path, so the query failed with "SearchExpr should not be executed without inverted index". It usually showed up on the second run, once the exact hit count came from the inverted index query cache. Set skip_try for SEARCH leaves so they always use the index. MATCH and plain predicates keep the bypass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: None
Related PR: #70488 (master fix), #64782 (same fix, closed without merge)
Problem Summary:
search()has no row-by-row path, but a SEARCH term on a numeric (BKD) field goes throughread_from_indexwithoutskip_try. When the value matches more thaninverted_index_skip_thresholdpercent of a segment (50 by default), the iterator returnsINVERTED_INDEX_BYPASS, the segment iterator falls back to row evaluation, and the query fails:It often passes on a cold run and fails once the exact hit count comes from the inverted index query cache, so it looks random to users. An account or tenant id on a table loaded per account is enough to hit it.
This sets
skip_tryfor the direct index reader leaf inFunctionSearch::build_leaf_query, so SEARCH always reads the index. MATCH and plain predicates keep the bypass. Workaround on unpatched versions:SET inverted_index_skip_threshold = 100.Release note
Fix
search()failing with "SearchExpr should not be executed without inverted index" when a term on a numeric field matches more thaninverted_index_skip_thresholdpercent of a segment.Check List (For Author)
Test
Regression test
search/test_search_bkd_skip_threshold, same checks and expected output as master: one value covers 70% of the segment, on a variant subcolumn and on an INT column, alone, with a text term, with OR, in standard mode and with ORDER BY ... LIMIT. Unlike the master version, it warms both numeric leaves once before the checks, because on 4.1 the first lookup of a value passes on the BKD estimate and only later lookups see the exact count from the query cache. With the warm-up, each dense check fails on its own without the fix. Ran locally against a 4.1 cluster: fails before the fix with "SearchExpr should not be executed without inverted index", passes after, and still passes withdefault_variant_max_subcolumns_countset to 1 globally (the test pins it to 2048).FunctionSearchTest.TestBuildLeafQueryVariantNestedIntUsesDirectIndexReadernow checksskip_try; compiled locally, not run locally.Timing on 2M rows (cache off, median): 20% match 18 ms before vs 14 ms after, 70% match fails before and takes 17 ms after.
Behavior changed:
inverted_index_skip_thresholdfor numeric fields; queries that failed now return results.Does this need documentation?
Check List (For Reviewer who merge this PR)