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

EXPLAIN shows non-sensical value for key_len with type=index

    Details

    • Type: Bug
    • Status: In Review (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.1.18, 10.0.28, 10.2.2
    • Fix Version/s: 10.1, 10.2
    • Component/s: None
    • Labels:
      None
    • Sprint:
      10.1.31

      Description

      create table ten(a int);
      insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
      create table one_k(a int);
      insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
      

      create table t1 (
        pk varchar(50),
        a varchar(20),
        filler varchar(100),
        index(a),
        primary key(pk)
      ) engine=innodb;
      insert into t1 select a,a,a from test.one_k;
      

      explain select pk from t1 order by a;
      id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
      1       SIMPLE  t1      index   NULL    a       25      NULL    1120    Using index
      

      The key_len=25 does not make any sense. They key format is

      offset what
      0-1 Column a, NULL-byte
      1-3 Column a, length bytes
      3-23 Column a, 20 characters
      23-25 PK, length bytes
      25- PK, 50 values

      25 bytes means include PK's length but not include the PK value itself.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psergey Sergei Petrunia
                Reporter:
                psergey Sergei Petrunia
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: