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

MIN/MAX optimization doesnt work for int_col > INET_ATON

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      create database db;
      use db;
       
      CREATE TABLE `test` (
        `a` int(11) NOT NULL AUTO_INCREMENT,
        `b` bigint(20) DEFAULT NULL,
        PRIMARY KEY (`a`),
        KEY `idx_b` (`b`)
      ) ENGINE=InnoDB AUTO_INCREMENT=129033 DEFAULT CHARSET=latin1

      Fill it with data:

      for i in `seq 1 254` ; do for z in `seq 1 254` ; do echo "insert into test (b) values (INET_ATON('192.168.${i}.${z}'));" ; done ; done | mysql db

      Check query execution plan:

      explain select MIN(b) from test where b >= inet_aton('192.168.119.32')\G

      Results from MySQL:

      Database changed
      mysql> explain select MIN(b) from test where b >= inet_aton('192.168.119.32')\G
      *************************** 1. row ***************************
                 id: 1
        select_type: SIMPLE
              table: NULL
               type: NULL
      possible_keys: NULL
                key: NULL
            key_len: NULL
                ref: NULL
               rows: NULL
              Extra: Select tables optimized away
      1 row in set (0.00 sec)

      Results from MariaDB:

      MariaDB [db]> explain select MIN(b) from test where b >= inet_aton('192.168.119.32')\G
      *************************** 1. row ***************************
                 id: 1
        select_type: SIMPLE
              table: test
               type: range
      possible_keys: idx_b
                key: idx_b
            key_len: 9
                ref: NULL
               rows: 32545
              Extra: Using where; Using index
      1 row in set (0.00 sec)

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            psergei Sergei Petrunia
            Votes:
            1 Vote for this issue
            Watchers:
            2 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.