Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-34911

Make SUBSTR(col, 1, n) = const_str sargable

    XMLWordPrintable

Details

    Description

      Conditions looking like

      SUBSTR(str_col, 1, n) = const_str 
      

      where the prefix of str_col is compared against a constant value can be rewritten as range conditions as

      const_str_low <= str_col <= const_str_high
      

      which will improve the optimizer capabilities of building better execution plan (for example, using indexes on column str_col and applying range optimizations).
      The similar transformation is already implemented for conditions like

      str_col LIKE 'foo%'
      

      aiming for the same goal.

      Similar rewrite is implemented for DATE() and YEAR() function at MDEV-8320, and that approach may be used as a reference.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              oleg.smirnov Oleg Smirnov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.