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

Partitioning changes the query result: natural language full-text search on MyISAM or Aria misses a word in 1 of 4 rows

    XMLWordPrintable

Details

    Description

      Likely cause: commit 2f09b28e0f7f8e4291003a9b46c62b54f3bf4454 (MDEV-7705), which added full-text search to partitioned tables in CS 10.3.3. Before that change, a partitioned table could not have a FULLTEXT index.

      --source include/have_partition.inc
      CREATE TABLE t1 (a INT, t TEXT, FULLTEXT (t)) ENGINE=MyISAM PARTITION BY HASH (a) PARTITIONS 2;
      INSERT INTO t1 VALUES (1, 'apple banana'), (2, 'cherry grape'), (3, 'melon lemon'), (4, 'peach plum');
      --let $n= `SELECT COUNT(*) FROM t1 WHERE MATCH (t) AGAINST ('apple')`
      if (!$n)
      {
        --die A natural language full-text search on a partitioned MyISAM table does not find a word that is in 1 of 4 rows
      }
      CREATE TABLE t2 (a INT, t TEXT, FULLTEXT (t)) ENGINE=Aria PARTITION BY HASH (a) PARTITIONS 2;
      INSERT INTO t2 SELECT * FROM t1;
      --let $n= `SELECT COUNT(*) FROM t2 WHERE MATCH (t) AGAINST ('apple')`
      if (!$n)
      {
        --die A natural language full-text search on a partitioned Aria table does not find a word that is in 1 of 4 rows
      }
      DROP TABLE t1, t2;

      Leads to:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026

      mysqltest: At line 7: A natural language full-text search on a partitioned MyISAM table does not find a word that is in 1 of 4 rows

      Partitioning changes the query result. Without partitioning, the same search finds the row. The 50% threshold is applied to each partition on its own: 'apple' is in 1 of the 2 rows of its partition, so it is ignored. The relevance values also differ from the table without partitioning. Boolean mode is not affected. Aria and debug builds give the same result.

      From the code it seems that ha_partition::ft_init_ext() calls ft_init_ext() of each partition on its own, and the weight (GWS_PROB in storage/myisam/ftdefs.h, the same in Aria) uses the record count of that partition. The relevance values of different partitions are then also on different scales.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 1h
                  1h

                  Git Integration

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