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

INFORMATION_SCHEMA.TABLES.INDEX_LENGTH omits hidden secondary-index size for VECTOR indexes

    XMLWordPrintable

Details

    Description

      INFORMATION_SCHEMA.TABLES.INDEX_LENGTH underreports the size of an InnoDB VECTOR index backed by a hidden graph table. This can make metadata-based storage accounting inaccurate.

      How to repeat:

      CREATE DATABASE vector_index_size_test;
      USE vector_index_size_test;
       
      CREATE TABLE vector_size (
        id INT PRIMARY KEY,
        v VECTOR(4) NOT NULL,
        VECTOR INDEX vi(v)
      ) ENGINE=InnoDB;
       
      INSERT INTO vector_size
      SELECT seq, VEC_FromText(CONCAT('[', seq, ',', seq + 1, ',', seq + 2, ',', seq + 3, ']'))
      FROM seq_1_to_20000;
       
      ANALYZE TABLE vector_size;
      FLUSH TABLE vector_size;
       
      SELECT t.INDEX_LENGTH AS table_index_bytes,
             s.NAME AS hidden_graph_name,
             s.CLUST_INDEX_SIZE * @@innodb_page_size AS hidden_data_bytes,
             s.OTHER_INDEX_SIZE * @@innodb_page_size AS hidden_secondary_bytes,
             (s.CLUST_INDEX_SIZE + s.OTHER_INDEX_SIZE) * @@innodb_page_size AS vector_index_bytes,
             t.INDEX_LENGTH >= (s.CLUST_INDEX_SIZE + s.OTHER_INDEX_SIZE) * @@innodb_page_size AS invariant_holds
      FROM INFORMATION_SCHEMA.TABLES AS t
      JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS AS s
        ON s.NAME = CONCAT(t.TABLE_SCHEMA, '/', t.TABLE_NAME, '#i#01')
      WHERE t.TABLE_SCHEMA = DATABASE()
        AND t.TABLE_NAME = 'vector_size';
      

      Actual result:

      table_index_bytes: 16384
      hidden_data_bytes: 16384
      hidden_secondary_bytes: 32768
      vector_index_bytes: 49152
      invariant_holds: 0

      TABLES.INDEX_LENGTH reports only 16,384 bytes while the hidden graph's clustered and secondary indexes occupy 49,152 bytes.

      Expected result:

      TABLES.INDEX_LENGTH should be at least (CLUST_INDEX_SIZE + OTHER_INDEX_SIZE) * innodb_page_size for the table's sole VECTOR index, so invariant_holds should be 1.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              imchifan 刘启帆
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.