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

Use table check constraints in optimizer

    XMLWordPrintable

Details

    • Task
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Optimizer
    • None
    • 10.3.6-1, 10.4.0-1

    Description

      Consider two tables defined as

      create table t1 (a int primary key, b int, check b < 5); 
      create table t2 (a int primary key);
      

      and a query

      select * from t1, t2 where t1.b=t2.a and t2.a > 2;
      

      If to take into account the check constraint on t1.b then the query will be looking as

      select * from t1, t2 where t1.b=t2.a and t2.a > 2 and t1.b < 5;
      

      As t1.b is equal to t2.a a much better condition on the column t2.a can be deduced:
      t2.a > 2 and t2.a < 5

      Consider another query

      select * from t1, t2 where t1.a=t2.b and t2.a > 10;
      

      As in the previous one, a new condition for t2.a can be deduced: t2.a > 10 and t2.a < 5
      This condition is always false, so there is no need to evaluate the query.

      Attachments

        Activity

          People

            igor Igor Babaev
            shagalla Galina Shalygina
            Votes:
            1 Vote for this issue
            Watchers:
            6 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.