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

Optimization: short-cut SELECT with aggregation if HAVING has turned false

    XMLWordPrintable

Details

    Description

      (Coming from Monty's observations of queries ServiceNow makes)

      Consider a query:

      select ... from t1 where ... having count(value)= 0;
      select ... from t1 where ... having count(value)< 10;
      

      The idea is, as soon as we get enough matching row(s), we know the query would produce an empty resultset. This means we can stop the execution.

      Requirements

      Implicit grouping is needed, or GROUP BY with "HAVING group_col=.." so there's only one group.

      Execution

      The aggregate function could have an attached "end detector". "end detection" will detect when the HAVING condition becomes false and signal to stop the execution.

      Attachments

        Activity

          People

            bsrikanth Srikanth Bondalapati
            psergei Sergei Petrunia
            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.