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

wrong result with index_merge_sort_intersection and rowid_filter=on

    XMLWordPrintable

Details

    • Q1/2026 Server Maintenance

    Description

      to reproduce:

      docker run --name sds3 -d -p 4001:3306 --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 mariadb:11.4.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --init-connect='SET NAMES utf8mb4 COLLATE utf8mb4_unicode_bin'

      and

      mysql -h127.0.0.1 -uroot -P4001 < init.sql

      mysql -h127.0.0.1 -uroot -P4001 < query.sql

      Expected result:

      id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
      1	SIMPLE	TAB2	ref	TAB2_IX4	TAB2_IX4	43	const	5	Using index condition; Using where
      comp_cd	upr_brd_no	brd_no
      C1000	1000999	1004996
      C1000	1000999	1004995
      C1000	1000999	1004997
      C1000	1000999	1004999
      C1000	1000999	1004998
      

      Wrong Result

      id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
      1	SIMPLE	TAB2	index_merge|filter	TAB2_IX2,TAB2_IX4	TAB2_IX2,TAB2_IX4|TAB2_IX4	5,43|43	NULL	1 (0%)Using sort_intersect(TAB2_IX2,TAB2_IX4); Using where; Using rowid filter
      comp_cd	upr_brd_no	brd_no
      C1000	1000999	1004998
      

      Wrong results started qwith 11.0, 10.10 and before are not affected.

      Correct results with

      set optimizer_switch='index_merge=off';

      or !

      set optimizer_switch='rowid_filter=off';

      Seems i happens , if row_id filter and sort_intersect will be used in combination from optimizer

      id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
      1	SIMPLE	TAB2	index_merge|filter	TAB2_IX2,TAB2_IX4	TAB2_IX2,TAB2_IX4|TAB2_IX4	5,43|43	NULL	1 (0%)Using sort_intersect(TAB2_IX2,TAB2_IX4); Using where; Using rowid filter
      

      See also the sister issue TODO-5754 for updates relevant to this task.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Richard Richard Stracke
              Votes:
              1 Vote for this issue
              Watchers:
              6 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.