mysql> explain SELECT DISTINCT s.*  FROM kronolith_shares s  LEFT JOIN kronolith_shares_users AS u ON u.share_id = s.share_id LEFT JOIN kronolith_shares_groups AS g ON g.share_id = s.share_id WHERE s.share_owner = 'mike' OR (s.perm_creator & 2) != 0 OR (s.perm_default & 2) != 0 OR ( u.user_uid = 'mike' AND (u.perm & 2) != 0) OR (g.group_uid IN (459,1035) AND (g.perm & 2) != 0) ORDER BY s.attribute_name ASC;                                                                                                                                            +----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+---------------------------------+
| id | select_type | table | type | possible_keys                        | key                                  | key_len | ref              | rows | Extra                           |
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+---------------------------------+
|  1 | SIMPLE      | s     | ALL  | kronolith_shares_share_owner_idx     | NULL                                 | NULL    | NULL             |   12 | Using temporary; Using filesort |
|  1 | SIMPLE      | u     | ref  | kronolith_shares_users_share_id_idx  | kronolith_shares_users_share_id_idx  | 4       | horde.s.share_id |    2 | Distinct                        |
|  1 | SIMPLE      | g     | ref  | kronolith_shares_groups_share_id_idx | kronolith_shares_groups_share_id_idx | 4       | horde.s.share_id |    2 | Using where; Distinct           |
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+---------------------------------+


...and without the DISTINCT:

mysql> explain SELECT  s.*  FROM kronolith_shares s  LEFT JOIN kronolith_shares_users AS u ON u.share_id = s.share_id LEFT JOIN kronolith_shares_groups AS g ON g.share_id = s.share_id WHERE s.share_owner = 'mike' OR (s.perm_creator & 2) != 0 OR (s.perm_default & 2) != 0 OR ( u.user_uid = 'mike' AND (u.perm & 2) != 0) OR (g.group_uid IN (459,1035) AND (g.perm & 2) != 0) ORDER BY s.attribute_name ASC;
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+----------------+
| id | select_type | table | type | possible_keys                        | key                                  | key_len | ref              | rows | Extra          |
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+----------------+
|  1 | SIMPLE      | s     | ALL  | kronolith_shares_share_owner_idx     | NULL                                 | NULL    | NULL             |   12 | Using filesort |
|  1 | SIMPLE      | u     | ref  | kronolith_shares_users_share_id_idx  | kronolith_shares_users_share_id_idx  | 4       | horde.s.share_id |    2 |                |
|  1 | SIMPLE      | g     | ref  | kronolith_shares_groups_share_id_idx | kronolith_shares_groups_share_id_idx | 4       | horde.s.share_id |    2 | Using where    |
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+----------------+



...and with GROUP BY:
mysql> EXPLAIN SELECT s.*  FROM kronolith_shares s  LEFT JOIN kronolith_shares_users AS u ON u.share_id = s.share_id LEFT JOIN kronolith_shares_groups AS g ON g.share_id = s.share_id WHERE s.share_owner = 'mike' OR (s.perm_creator & 2) != 0 OR (s.perm_default & 2) != 0 OR ( u.user_uid = 'mike' AND (u.perm & 2) != 0) OR (g.group_uid IN (459,1035) AND (g.perm & 2) != 0) GROUP BY s.share_id  ORDER BY s.attribute_name ASC
    -> ;
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+---------------------------------+
| id | select_type | table | type | possible_keys                        | key                                  | key_len | ref              | rows | Extra                           |
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+---------------------------------+
|  1 | SIMPLE      | s     | ALL  | kronolith_shares_share_owner_idx     | NULL                                 | NULL    | NULL             |   12 | Using temporary; Using filesort |
|  1 | SIMPLE      | u     | ref  | kronolith_shares_users_share_id_idx  | kronolith_shares_users_share_id_idx  | 4       | horde.s.share_id |    2 |                                 |
|  1 | SIMPLE      | g     | ref  | kronolith_shares_groups_share_id_idx | kronolith_shares_groups_share_id_idx | 4       | horde.s.share_id |    2 | Using where                     |
+----+-------------+-------+------+--------------------------------------+--------------------------------------+---------+------------------+------+---------------------------------+