Commit 4497042
committed
opt: normalize LIKE ... ESCAPE
An expression in the form `a LIKE b ESCAPE '/'`, which is parsed as
`like_escape(a, b, '/')`, is now normalized to `a LIKE b`. This is valid
because `\` is the default escape character, so the expressions are
equivalent.
This normalization allows for further optimization, for example:
```sql
CREATE TABLE t (s STRING, INDEX (s));
EXPLAIN SELECT s FROM t WHERE s LIKE 'foo\_bar' ESCAPE '\';
-- BEFORE:
-- • filter
-- │ filter: like_escape(s, e'foo\\_bar', e'\\')
-- │
-- └── • scan
-- table: t@t_pkey
-- spans: FULL SCAN
-- AFTER:
-- • scan
-- table: t@t_s_idx
-- spans: [/'foo_bar' - /'foo_bar']
```
Informs #30192
Release note (performance improvement): Queries with filters in the form
`a LIKE b ESCAPE '\'` are now index-accelerated in some cases which they
were not before.1 parent 3066741 commit 4497042
2 files changed
+75
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2689 | 2689 | | |
2690 | 2690 | | |
2691 | 2691 | | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
0 commit comments