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

Cost estimates for materialized derived tables are poor

    XMLWordPrintable

Details

    Description

      (Filing based on discussion with monty )

      When analyzing the trace MDEV-30877, noted this:

      The derived table has

                      "table_scan": {
                        "rows": 13304563,
                        "cost": 1.33e7
                      }
      

      Compare to the non-derived table in the same query:

                      "table": "es",
                      "table_scan": {
                        "rows": 12840562,
                        "cost": 103969
                      }
      

      The numbers of rows are similar but there's 128x difference in costs.

      The number comes from here:

      double JOIN_TAB::scan_time()
      {
        if (table->is_created())
           ...
        else  
        {   
          found_records= records=table->stat_records();
          read_time= found_records ? (double)found_records: 10.0;// TODO:fix this stub
          res= read_time;
        }   
      

      Note the read_time= found_records assignment...

      Attachments

        Activity

          People

            monty Michael Widenius
            psergei Sergei Petrunia
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.