Skip to content

Index of acl rules might not be used properly #4904

@juliusknorr

Description

@juliusknorr
MariaDB [nextcloud]> explain SELECT DISTINCT b.id FROM oc_deck_boards b LEFT JOIN oc_deck_board_acl acl ON b.id = acl.board_id WHERE (owner = 'admin') OR ((acl.participant = 'admin') AND (acl.type = 0)) OR ((acl.participant IN ('group', 'group2')) AND (acl.type = 1));
+------+-------------+-------+-------+------------------------------------------+---------------------+---------+----------------+------+------------------------------------+
| id   | select_type | table | type  | possible_keys                            | key                 | key_len | ref            | rows | Extra                              |
+------+-------------+-------+-------+------------------------------------------+---------------------+---------+----------------+------+------------------------------------+
|    1 | SIMPLE      | b     | index | idx_owner_modified                       | idx_owner_modified  | 263     | NULL           | 1    | Using index; Using temporary       |
|    1 | SIMPLE      | acl   | ref   | deck_board_acl_uq_i,deck_board_acl_idx_i | deck_board_acl_uq_i | 8       | nextcloud.b.id | 1    | Using where; Using index; Distinct |
+------+-------------+-------+-------+------------------------------------------+---------------------+---------+----------------+------+------------------------------------+
2 rows in set (0.003 sec)

MariaDB [nextcloud]> show create table oc_deck_board_acl;
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table             | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| oc_deck_board_acl | CREATE TABLE `oc_deck_board_acl` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `board_id` bigint(20) NOT NULL,
  `type` int(11) NOT NULL,
  `participant` varchar(64) NOT NULL,
  `permission_edit` tinyint(1) DEFAULT 0,
  `permission_share` tinyint(1) DEFAULT 0,
  `permission_manage` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `deck_board_acl_uq_i` (`board_id`,`type`,`participant`),
  KEY `deck_board_acl_idx_i` (`board_id`),
  KEY `idx_participant_type` (`participant`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.004 sec)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions