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

Pushdown conditions into non-mergeable views/derived tables

Details

    Description

      It is possible to do condition pushdown into non-mergable VIEWs or derived tables.

      Example:

      select ...
      from 
        (select col1, max(col2) as max_val 
         from t2 
         group by t1 ) TBL
      where 
         col1 !='foo' and max_val > 100

      here, both parts of top-level select's WHERE clause can be pushed into derived table's HAVING clause.

      Implementation challenges

      Moving condition from one select into another changes the context which condition is used in.
      Table condition pushdown produces strictest-possible conditions, but has a property that certain part of condition can be attached to multiple tables.
      Doing the same thing here will cause trouble: if the same part of the condition is both in subquery's HAVING and in upper select's WHERE, it should e.g. automagically changes its used_tables() depending on what context we're looking at it from.
      The solution to this is to do limited pushdown: only push down expressions that we can completely remove from upper query's WHERE.

      Pushdown may also require adjustments to ref_pointer_array. Sanja and Igor seem to understand the details of this.

      Attachments

        Issue Links

          Activity

            psergei Sergei Petrunia created issue -
            psergei Sergei Petrunia made changes -
            Field Original Value New Value
            Description It is possible to do condition pushdown into non-mergable VIEWs or derived tables.

            Example:
            {noformat}
            select ...
            from
              (select col1, max(col2) as max_val
               from t2
               group by t1 ) TBL
            where
               col1 !='foo' and max_val > 100
            {noformat}

            here, both parts of top-level select's WHERE clause can be pushed into derived table's HAVING clause.
            psergei Sergei Petrunia made changes -
            Component/s Optimizer [ 10200 ]
            Labels optimizer
            psergei Sergei Petrunia made changes -
            psergei Sergei Petrunia made changes -
            Fix Version/s 10.2 [ 14601 ]
            psergei Sergei Petrunia made changes -
            Priority Major [ 3 ] Minor [ 4 ]
            psergei Sergei Petrunia made changes -
            Description It is possible to do condition pushdown into non-mergable VIEWs or derived tables.

            Example:
            {noformat}
            select ...
            from
              (select col1, max(col2) as max_val
               from t2
               group by t1 ) TBL
            where
               col1 !='foo' and max_val > 100
            {noformat}

            here, both parts of top-level select's WHERE clause can be pushed into derived table's HAVING clause.
            It is possible to do condition pushdown into non-mergable VIEWs or derived tables.

            Example:
            {noformat}
            select ...
            from
              (select col1, max(col2) as max_val
               from t2
               group by t1 ) TBL
            where
               col1 !='foo' and max_val > 100
            {noformat}

            here, both parts of top-level select's WHERE clause can be pushed into derived table's HAVING clause.

            h2. Implementation challenges
            Moving condition from one select into another changes the context which condition is used in.
            Table condition pushdown produces strictest-possible conditions, but has a property that certain part of condition can be attached to multiple tables.
            Doing the same thing here will cause trouble: if the same part of the condition is both in subquery's HAVING and in upper select's WHERE, it should e.g. automagically changes its used_tables() depending on what context we're looking at it from.
            The solution to this is to do limited pushdown: only push down expressions that we can completely remove from upper query's WHERE.
            psergei Sergei Petrunia made changes -
            Description It is possible to do condition pushdown into non-mergable VIEWs or derived tables.

            Example:
            {noformat}
            select ...
            from
              (select col1, max(col2) as max_val
               from t2
               group by t1 ) TBL
            where
               col1 !='foo' and max_val > 100
            {noformat}

            here, both parts of top-level select's WHERE clause can be pushed into derived table's HAVING clause.

            h2. Implementation challenges
            Moving condition from one select into another changes the context which condition is used in.
            Table condition pushdown produces strictest-possible conditions, but has a property that certain part of condition can be attached to multiple tables.
            Doing the same thing here will cause trouble: if the same part of the condition is both in subquery's HAVING and in upper select's WHERE, it should e.g. automagically changes its used_tables() depending on what context we're looking at it from.
            The solution to this is to do limited pushdown: only push down expressions that we can completely remove from upper query's WHERE.
            It is possible to do condition pushdown into non-mergable VIEWs or derived tables.

            Example:
            {noformat}
            select ...
            from
              (select col1, max(col2) as max_val
               from t2
               group by t1 ) TBL
            where
               col1 !='foo' and max_val > 100
            {noformat}

            here, both parts of top-level select's WHERE clause can be pushed into derived table's HAVING clause.

            h2. Implementation challenges
            Moving condition from one select into another changes the context which condition is used in.
            Table condition pushdown produces strictest-possible conditions, but has a property that certain part of condition can be attached to multiple tables.
            Doing the same thing here will cause trouble: if the same part of the condition is both in subquery's HAVING and in upper select's WHERE, it should e.g. automagically changes its used_tables() depending on what context we're looking at it from.
            The solution to this is to do limited pushdown: only push down expressions that we can completely remove from upper query's WHERE.

            Pushdown may also require adjustments to {{ref_pointer_array}}. Sanja and Igor seem to understand the details of this.
            elenst Elena Stepanova made changes -
            Issue Type Bug [ 1 ] Task [ 3 ]
            psergei Sergei Petrunia made changes -
            Labels optimizer gsoc16 optimizer
            monty Michael Widenius made changes -
            monty Michael Widenius made changes -
            Assignee Michael Widenius [ monty ]
            monty Michael Widenius made changes -
            Assignee Michael Widenius [ monty ] Sergei Petrunia [ psergey ]
            alvinr Alvin Richards (Inactive) made changes -
            Labels gsoc16 optimizer Compatibility gsoc16 optimizer
            svoj Sergey Vojtovich made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            svoj Sergey Vojtovich made changes -
            Labels Compatibility gsoc16 optimizer Compatibility foundation gsoc16 optimizer
            svoj Sergey Vojtovich made changes -
            Labels Compatibility foundation gsoc16 optimizer Compatibility contribution foundation gsoc16 optimizer
            svoj Sergey Vojtovich made changes -
            Assignee Sergei Petrunia [ psergey ] Igor Babaev [ igor ]
            svoj Sergey Vojtovich made changes -
            monty Michael Widenius made changes -
            Assignee Igor Babaev [ igor ] Michael Widenius [ monty ]
            monty Michael Widenius made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            monty Michael Widenius made changes -
            Assignee Michael Widenius [ monty ] Igor Babaev [ igor ]
            alvinr Alvin Richards (Inactive) made changes -
            Rank Ranked higher
            alvinr Alvin Richards (Inactive) made changes -
            Sprint 10.2.2-2 [ 92 ]
            alvinr Alvin Richards (Inactive) made changes -
            Rank Ranked lower
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.2.2-2 [ 92 ] 10.2.2-2, 10.2.2-3 [ 92, 94 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.2.2-2, 10.2.2-3 [ 92, 94 ] 10.2.2-2, 10.2.2-3, 10.2.2-4 [ 92, 94, 96 ]
            alvinr Alvin Richards (Inactive) made changes -
            Sprint 10.2.2-2, 10.2.2-3, 10.2.2-4 [ 92, 94, 96 ] 10.2.2-2, 10.2.2-4 [ 92, 96 ]
            alvinr Alvin Richards (Inactive) made changes -
            Epic Link MDEV-10872 [ 58182 ]
            psergei Sergei Petrunia made changes -
            igor Igor Babaev (Inactive) made changes -
            Fix Version/s 10.2.2 [ 22013 ]
            Fix Version/s 10.2 [ 14601 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            alvinr Alvin Richards (Inactive) made changes -
            Labels Compatibility contribution foundation gsoc16 optimizer Approved Compatibility contribution foundation gsoc16 optimizer
            Krishnadas Krishnadas made changes -
            Attachment MDEV-9197.zip [ 42680 ]
            alvinr Alvin Richards (Inactive) made changes -
            Labels Approved Compatibility contribution foundation gsoc16 optimizer Approved Compatibility NRE-307517 contribution foundation gsoc16 optimizer
            alvinr Alvin Richards (Inactive) made changes -
            NRE Projects NRE-307517
            alvinr Alvin Richards (Inactive) made changes -
            Labels Approved Compatibility NRE-307517 contribution foundation gsoc16 optimizer Approved Compatibility contribution foundation gsoc16 optimizer
            alvinr Alvin Richards (Inactive) made changes -
            NRE Approved Yes [ 10304 ]
            alvinr Alvin Richards (Inactive) made changes -
            Labels Approved Compatibility contribution foundation gsoc16 optimizer Compatibility contribution foundation gsoc16 optimizer
            bar Alexander Barkov made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 72747 ] MariaDB v4 [ 132736 ]
            psergei Sergei Petrunia made changes -

            People

              igor Igor Babaev (Inactive)
              psergei Sergei Petrunia
              Votes:
              8 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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