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

LP:887496 - Wrong result with LooseScan , multipart keys

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      The following query:

      SELECT * FROM t1
      WHERE a IN (
      SELECT t2.a
      FROM t2 , t3
      WHERE t2.b = t3.b
      );

      returns

      5
      5

      when executed with loosescan=on, even though t1 contains only one row where a = 5 .

      EXPLAIN:

      id select_type table type possible_keys key key_len ref rows Extra
      1 PRIMARY t2 index b b 9 NULL 2 Using where; Using index; LooseScan
      1 PRIMARY t3 ref b b 4 test.t2.b 1 Using index; FirstMatch(t2)
      1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)

      minimal switch: semijoin=on,loosescan=on

      full switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on

      bzr version-info
      revision-id: <email address hidden>
      date: 2011-11-07 16:39:02 +0400
      build-date: 2011-11-08 12:26:06 +0200
      revno: 3273
      branch-nick: maria-5.3

      test case:

      CREATE TABLE t1 (a int);
      INSERT INTO t1 VALUES (9),(0),(8),(5);

      CREATE TABLE t2 (a int, b varchar(1), KEY (b,a));
      INSERT INTO t2 VALUES (5,'r'),(5,'z');

      CREATE TABLE t3 (a int, b varchar(1), KEY (b,a));
      INSERT INTO t3 VALUES (5,'r'),(5,'z');

      SET SESSION optimizer_switch='loosescan=on';

      SELECT * FROM t1
      WHERE a IN (
      SELECT t2.a
      FROM t2 , t3
      WHERE t2.b = t3.b
      );

      Attachments

        Activity

          People

            igor Igor Babaev (Inactive)
            philipstoev Philip Stoev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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