Sergey Nuyanzin created FLINK-41731:
---------------------------------------
Summary: Substring search in SQL string functions checks the text
byte by byte
Key: FLINK-41731
URL: https://issues.apache.org/jira/browse/FLINK-41731
Project: Flink
Issue Type: Improvement
Components: API / Core, Table SQL / Runtime
Reporter: Sergey Nuyanzin
Assignee: Sergey Nuyanzin
{{POSITION}}/{{LOCATE}}, {{INSTR}}, {{LIKE '%abc%'}} and {{SPLIT}} find a
substring in a string by walking the text one byte at a time:
- {{BinaryStringData.indexOf}} ({{POSITION}}, {{LOCATE}}, {{INSTR}},
{{contains}} for {{LIKE}}) tries a match at every character of the text, one
after another.
- {{BinarySegmentUtils.find}} ({{SPLIT}}, {{LIKE}} with several parts) checks
every byte of the text against the first byte of the substring.
Example: {{POSITION('zebra' IN s)}}, where {{s}} is a 2000-character ASCII
string with {{zebra}} at the end. The search goes through about 2000 positions
one at a time before it finds the match, even though most bytes could be
skipped in bulk.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)