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

ANALYZE FORMAT=JSON fields are incorrect for UNION ALL queries

    XMLWordPrintable

Details

    Description

      create table t1 (a int);
      insert into t1 values (1),(2),(3);
       
      create table t2 (a int);
      insert into t2 values (10),(11);
      

      analyze format=json 
      select * from (select a from t1 union all select a from t2) TBL;
      

      Shows something like this:

              "table": {
                "table_name": "<derived2>",
                "access_type": "ALL",
                "r_loops": 1,
                "rows": 5,
                "r_rows": 5,
                "r_table_time_ms": 0.039263025,
                "r_other_time_ms": 0.028563309,
                "filtered": 100,
                "r_filtered": 100,
                "materialized": {
                  "query_block": {
                    "union_result": {
                      "table_name": "<union2,3>",
                      "access_type": "ALL",
                      "r_loops": 0,
                      "r_rows": null,
      

      note r_loops=0, r_rows:null. This is clearly incorrect.

      Note that regular UNION (not UNION ALL) one gets correct result:

                "materialized": {
                  "query_block": {
                    "union_result": {
                      "table_name": "<union2,3>",
                      "access_type": "ALL",
                      "r_loops": 1,
                      "r_rows": 5,
      

      Attachments

        Activity

          People

            oleg.smirnov Oleg Smirnov
            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.