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

JSON histogram may contain bucketS than histogram_size allows

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: N/A
    • Fix Version/s: 10.7.1
    • Component/s: Optimizer
    • Labels:
      None

      Description

      One of points from our earlier slack discussion was that there can not be more buckets in a JSON histogram than histogram_size. The below example proves the contrary.

      It is possible that the conclusion was wrong or too generic and there are allowed exceptions from the rule. These exception will need to be a part of histogram_size description in the KB. The description has to be adjust anyway, as now it says that histogram_size means the number of buckets for JSON histograms, and it's certainly not the case.

      --source include/have_sequence.inc
       
      create or replace table t (a int);
      insert into t values (1),(3),(5),(7);
      insert into t select 2 from seq_1_to_25;
      insert into t select 4 from seq_1_to_25;
      insert into t select 6 from seq_1_to_25;
       
      set histogram_size=4, histogram_type=JSON_HB;
      analyze table t persistent for all;
       
      select histogram from mysql.column_stats where table_name = 't';
       
      drop table t;
      

      preview-10.7-MDEV-26519-json-histograms da8bb4b470

      select histogram from mysql.column_stats where table_name = 't';
      histogram
      {
        "histogram_hb_v2": [
          {
            "start": "1",
            "size": 0.240506329,
            "ndv": 2
          },
          {
            "start": "2",
            "size": 0.240506329,
            "ndv": 3
          },
          {
            "start": "4",
            "size": 0.189873418,
            "ndv": 2
          },
          {
            "start": "6",
            "size": 0.316455696,
            "ndv": 1
          },
          {
            "start": "7",
            "end": "7",
            "size": 0.012658228,
            "ndv": 1
          }
        ]
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration