<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="637962">
  <date_last_updated>2010-10-26 08:32:19.933009+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/637962</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~pstoev-askmonty</bug_owner_link>
    <milestone_link>https://api.launchpad.net/1.0/maria/+milestone/5.1</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/637962/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/637962/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/637962</bug_web_link>
  <owner>Philip Stoev</owner>
  <assignee>Igor Babaev</assignee>
  <milestone_title>Maria 5.1</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Considerable performance regression on certain queries in maria-5.1-wl24</title>
  <status>In Progress</status>
  <importance>High</importance>
  <created>2010-09-14 11:18:59.335220+00:00</created>
  <description>
<![CDATA[The following query:

SELECT `col_varchar_64_key` FROM `table100000_myisam_int_autoinc`
WHERE ( `col_varchar_64_key` NOT IN ( 'now' , 'rsgxnnowvz' ) OR `col_varchar_64_key`  LIKE CONCAT ('Utah' , '%' ) )
AND ( `col_varchar_10_key`  BETWEEN 'cr' AND 'really' OR `col_varchar_64_key`  IN ( 'j' , 'rcrsgxnn' ) )
AND (  ( `col_varchar_10_key` != 'it' ) OR `col_varchar_10_key` IS  NULL )
ORDER BY `col_varchar_64_key` LIMIT 7;

Takes no time on maria-5.1 but takes over 1 second on maria-5.1-wl24 . Even if the filesort is avoided by removing the ORDER BY, considerable performance difference remains.

EXPLAIN under maria-5.1:

           id: 1
  select_type: SIMPLE
        table: table100000_myisam_int_autoinc
         type: range
possible_keys: col_varchar_10_key,col_varchar_64_key
          key: col_varchar_64_key
      key_len: 67
          ref: NULL
         rows: 99905
        Extra: Using where

EXPLAIN under maria-5.1-wl24

           id: 1
  select_type: SIMPLE
        table: table100000_myisam_int_autoinc
         type: index_merge
possible_keys: col_varchar_10_key,col_varchar_64_key
          key: col_varchar_10_key,col_varchar_64_key
      key_len: 13,67
          ref: NULL
         rows: 54298
        Extra: Using sort_union(col_varchar_10_key,col_varchar_64_key); Using where; Using filesort

The table contains 100K rows and will be uploaded shortly.]]>  </description>
  <activities>
    <activity datechanged="2010-09-14T11:18:59.335220+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Philip Stoev</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2010-09-14T11:19:10.051462+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Igor Babaev (igorb-seattle)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-14T11:19:16.453295+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.1]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-14T11:22:39.564818+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[mysqldump of the table https://bugs.launchpad.net/maria/+bug/637962/+attachment/1582448/+files/bug637962.dump.zip]]>      </newvalue>
      <whatchanged>attachment added</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-14T11:22:55.881680+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[High]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-15T04:08:24.340295+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[Confirmed]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-15T04:08:37.438628+00:00">
      <oldvalue>
<![CDATA[Confirmed]]>      </oldvalue>
      <newvalue>
<![CDATA[In Progress]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-17T08:06:15.144787+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[new test case https://bugs.launchpad.net/maria/+bug/637962/+attachment/1597233/+files/bug637962-2.test]]>      </newvalue>
      <whatchanged>attachment added</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-09-17T08:37:23.359097+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Diff between the FORCE KEY and IGNORE KEY result sets https://bugs.launchpad.net/maria/+bug/637962/+attachment/1597268/+files/bug637962.diff]]>      </newvalue>
      <whatchanged>attachment added</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
  </activities>
  <comments>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/0" datecreated="2010-09-14T11:18:59.335220+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[The following query:

SELECT `col_varchar_64_key` FROM `table100000_myisam_int_autoinc`
WHERE ( `col_varchar_64_key` NOT IN ( 'now' , 'rsgxnnowvz' ) OR `col_varchar_64_key`  LIKE CONCAT ('Utah' , '%' ) )
AND ( `col_varchar_10_key`  BETWEEN 'cr' AND 'really' OR `col_varchar_64_key`  IN ( 'j' , 'rcrsgxnn' ) )
AND (  ( `col_varchar_10_key` != 'it' ) OR `col_varchar_10_key` IS  NULL )
ORDER BY `col_varchar_64_key` LIMIT 7;

Takes no time on maria-5.1 but takes over 1 second on maria-5.1-wl24 . Even if the filesort is avoided by removing the ORDER BY, considerable performance difference remains.

EXPLAIN under maria-5.1:

           id: 1
  select_type: SIMPLE
        table: table100000_myisam_int_autoinc
         type: range
possible_keys: col_varchar_10_key,col_varchar_64_key
          key: col_varchar_64_key
      key_len: 67
          ref: NULL
         rows: 99905
        Extra: Using where

EXPLAIN under maria-5.1-wl24

           id: 1
  select_type: SIMPLE
        table: table100000_myisam_int_autoinc
         type: index_merge
possible_keys: col_varchar_10_key,col_varchar_64_key
          key: col_varchar_10_key,col_varchar_64_key
      key_len: 13,67
          ref: NULL
         rows: 54298
        Extra: Using sort_union(col_varchar_10_key,col_varchar_64_key); Using where; Using filesort

The table contains 100K rows and will be uploaded shortly.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/1" datecreated="2010-09-14T11:22:39.564818+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/2" datecreated="2010-09-16T05:34:08.761586+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[Still repeatable with
------------------------------------------------------------
revno: 2935
committer: Igor Babaev <igor@askmonty.org>
branch nick: maria-5.1-wl24
timestamp: Wed 2010-09-15 16:42:56 -0700
message:
  Fixed bug #637978.
  Fixed a bug in the new code for WL#24 that caused generation of
  an invalid index-merge access plan.
]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/3" datecreated="2010-09-16T08:52:20.352651+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[In order to reproduce this bug, mysqld must be started using MTR

MTR_VERSION=1 perl mysql-test-run.pl --start-and-exit 1st

This will cause mysqld to be started with certain settings, in particular

 --key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/4" datecreated="2010-09-17T08:06:15.144787+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[This is a new test case for the bug
- sort_buffer_size = 1K is used to reduce the number of rows required to trigger the bug
- only FORCE KEY and IGNORE KEY queries are used to make the EXPLAIN unambiguous]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/5" datecreated="2010-09-17T08:36:15.124411+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[The procedure to repeat is as follows:

0. Take a 64-bit machine

1. Branch a fresh tree

bzr branch lp:maria/5.1 maria-5.1-bug637962

2. Clear ccache

ccache -C 

3. Compile

 ./BUILD/compile-pentium-debug-max

4. Run. 

perl mysql-test-run.pl --record --no-check-testcases t/bug637962-2.test

If successfull, MTR will report

mysqltest: At line 1462: "Bug #637962 is repeatable"


]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/6" datecreated="2010-09-17T08:37:23.359097+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/7" datecreated="2010-09-17T08:39:45.477745+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[Please ignore all comments after comment #2, they were about another bug.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/637962/comments/8" datecreated="2010-10-26T08:32:19.118444+00:00">
      <person>Igor Babaev</person>
      <subject>
<![CDATA[Re: Considerable performance regression on certain queries in maria-5.1-wl24]]>      </subject>
      <content>
<![CDATA[This bug should be reproducible with mariadb-5.1/mysql-5.1]]>      </content>
    </comment>
  </comments>
  <messages>
    <message created="2010-09-14 11:22:39.564818+00:00" owner="Philip Stoev">
<![CDATA[]]>      <attachment link="https://bugs.launchpad.net/bugs/637962/+attachment/1582448" type="Unspecified">
        <title>mysqldump of the table</title>
        <file>LPexportBug637962_bug637962.dump.zip</file>
      </attachment>
    </message>
    <message created="2010-09-17 08:06:15.144787+00:00" owner="Philip Stoev">
<![CDATA[This is a new test case for the bug
- sort_buffer_size = 1K is used to reduce the number of rows required to trigger the bug
- only FORCE KEY and IGNORE KEY queries are used to make the EXPLAIN unambiguous]]>      <attachment link="https://bugs.launchpad.net/bugs/637962/+attachment/1597233" type="Unspecified">
        <title>new test case</title>
        <file>LPexportBug637962_bug637962-2.test</file>
      </attachment>
    </message>
    <message created="2010-09-17 08:37:23.359097+00:00" owner="Philip Stoev">
<![CDATA[]]>      <attachment link="https://bugs.launchpad.net/bugs/637962/+attachment/1597268" type="Unspecified">
        <title>Diff between the FORCE KEY and IGNORE KEY result sets</title>
        <file>LPexportBug637962_bug637962.diff</file>
      </attachment>
    </message>
  </messages>
</launchpad-bug>
