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

Table elimination not applied to outer joins without WHERE

    XMLWordPrintable

Details

    Description

      I have no idea if this is a bug, but I'd expect it to work, so I hope it's worth reporting.

      In the following test case the right table is read, but it doesn't affect the results in any way:

      MariaDB [test]> SHOW CREATE TABLE city \G
      *************************** 1. row ***************************
             Table: city
      Create Table: CREATE TABLE `city` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `name` varchar(80) NOT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
      1 row in set (0.00 sec)
       
      MariaDB [test]> SHOW CREATE TABLE user \G
      *************************** 1. row ***************************
             Table: user
      Create Table: CREATE TABLE `user` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `city_id` int(11) NOT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1
      1 row in set (0.00 sec)
       
      MariaDB [test]> EXPLAIN SELECT c.name FROM city c LEFT JOIN user u ON c.id = u.city_id;
      +------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra                                           |
      +------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
      |    1 | SIMPLE      | c     | ALL  | NULL          | NULL | NULL    | NULL |    2 |                                                 |
      |    1 | SIMPLE      | u     | ALL  | NULL          | NULL | NULL    | NULL |   15 | Using where; Using join buffer (flat, BNL join) |
      +------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
      2 rows in set (0.00 sec)

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            f_razzoli Federico Razzoli
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.