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

I_S.VECTOR_INDEXES: Cache overflow resets values but does not increase CACHE_OVERFLOWS counter

    XMLWordPrintable

Details

    • Q3/2026 Server Maintenance

    Description

      In the test below, when the vector search is run with mhnsw_ef_search=10000, the following query from I_S.VECTOR_INDEXES returns CACHED_NODES=0, MEMORY_SIZE=0, and CACHE_OVERFLOWS is NULL. I can only assume that it is a side effect of a cache overflow, as I don't see any other reason for it.

      --source include/have_sequence.inc
      --source include/have_innodb.inc
       
      SET @cachesize.save = @@mhnsw_max_cache_size;
      SET GLOBAL mhnsw_max_cache_size= 16*1024*1024;
       
      CREATE TABLE t (
        id INT PRIMARY KEY,
        v VECTOR(2000) NOT NULL,
        VECTOR vi(v)
      ) ENGINE=InnoDB;
      INSERT INTO t SELECT seq,
        VEC_FromText(CONCAT('[', seq, ',', REPEAT('1,', 1998), '1]'))
      FROM seq_1_to_3000;
      SELECT CACHED_NODES, MEMORY_SIZE, CACHE_OVERFLOWS
        FROM INFORMATION_SCHEMA.VECTOR_INDEXES;
       
      --echo #
      --echo # With default mhnsw_ef_search=20 this query
      --echo # should not overflow the cache
      --echo #
      SELECT id, VEC_DISTANCE_EUCLIDEAN(
          v, VEC_FromText(CONCAT('[0,', REPEAT('1,', 1998), '1]'))) d FROM t
        ORDER BY d LIMIT 1;
       
      SELECT CACHED_NODES, MEMORY_SIZE, CACHE_OVERFLOWS
        FROM INFORMATION_SCHEMA.VECTOR_INDEXES;
       
      SET mhnsw_ef_search= 10000;
       
      --echo #
      --echo # ... but with mhnsw_ef_search=10000 it probably should
      --echo #
      SELECT id, VEC_DISTANCE_EUCLIDEAN(
          v, VEC_FromText(CONCAT('[0,', REPEAT('1,', 1998), '1]'))) d FROM t
        ORDER BY d LIMIT 1;
       
      SELECT CACHED_NODES, MEMORY_SIZE, CACHE_OVERFLOWS
        FROM INFORMATION_SCHEMA.VECTOR_INDEXES;
       
      DROP TABLE t;
      SET GLOBAL mhnsw_max_cache_size= @cachesize.save;
      

      b9d7dd0f991af35b059631f0f43b7bf390080d96

      SELECT CACHED_NODES, MEMORY_SIZE, CACHE_OVERFLOWS
      FROM INFORMATION_SCHEMA.VECTOR_INDEXES;
      CACHED_NODES	MEMORY_SIZE	CACHE_OVERFLOWS
      0	0	NULL
      #
      # With default mhnsw_ef_search=20 this query
      # should not overflow the cache
      #
      SELECT id, VEC_DISTANCE_EUCLIDEAN(
      v, VEC_FromText(CONCAT('[0,', REPEAT('1,', 1998), '1]'))) d FROM t
      ORDER BY d LIMIT 1;
      id	d
      1	1
      SELECT CACHED_NODES, MEMORY_SIZE, CACHE_OVERFLOWS
      FROM INFORMATION_SCHEMA.VECTOR_INDEXES;
      CACHED_NODES	MEMORY_SIZE	CACHE_OVERFLOWS
      362	4194176	0
      SET mhnsw_ef_search= 10000;
      #
      # ... but with mhnsw_ef_search=10000 it probably should
      #
      SELECT id, VEC_DISTANCE_EUCLIDEAN(
      v, VEC_FromText(CONCAT('[0,', REPEAT('1,', 1998), '1]'))) d FROM t
      ORDER BY d LIMIT 1;
      id	d
      1	1
      SELECT CACHED_NODES, MEMORY_SIZE, CACHE_OVERFLOWS
      FROM INFORMATION_SCHEMA.VECTOR_INDEXES;
      CACHED_NODES	MEMORY_SIZE	CACHE_OVERFLOWS
      0	0	NULL
      

      The patch for MDEV-34805 does not contain a test to show how CACHE_OVERFLOWS works, which is an oversight in itself.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 3h 22m
                  3h 22m
                  Remaining:
                  Remaining Estimate - 3h 22m
                  3h 22m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.