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

Simplify IN predicate processing for NULL-aware materialization involving only one column

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5
    • 10.5
    • Optimizer
    • None

    Description

      Looks like it is possible to skip the building sorted Ordered_key structures for subselect_rowid_merge_engine when there is only one key in the materialized subquery.

      We have predicate

      left_expr IN (SELECT <subq1>)
      

      where left_expr is a scalar (not a tuple). The logic in this case looks as follows:

      if (left_expr is NULL) {
        if (subq1 produced any rows) {
          // note that we don't care if subq1 has produced
          // NULLs or not.
          NULL IN (<some values>) -> UNKNOWN, i.e. NULL.
        } else {
          NULL IN ({empty-set}) -> FALSE. 
        }
      } else {
        // left_expr is a non-NULL value
        if (subq1 output has a match for left_expr) {
          left_expr IN (..., left_expr ...) -> TRUE
        } else {
          // no "known" matches.
          if (subq1 output has a NULL) {
            left_expr IN ( ... NULL ...) -> 
             (NULL could have been a match or not)
             -> NULL.
          } else {
            // subq1 didn't produce any "UNKNOWNs" so
            // we're positive there weren't any matches
            -> FALSE.
          }
        }
      }
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              oleg.smirnov Oleg Smirnov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.