Skip to content

Instantly share code, notes, and snippets.

@bcmiller
Created May 18, 2010 13:24
Show Gist options
  • Save bcmiller/404988 to your computer and use it in GitHub Desktop.
Save bcmiller/404988 to your computer and use it in GitHub Desktop.
from group_members view, and members by role:
mysql> explain SELECT users.uid AS uid,
-> users.name AS users_name,
-> users.picture AS users_picture,
-> og_rap_og_rap_uid.name AS og_rap_og_rap_uid_name
-> FROM users users
-> INNER JOIN og_rap_uid og_rap_uid ON users.uid = og_rap_uid.uid
-> INNER JOIN og_rap og_rap_og_rap_uid ON og_rap_uid.rid = og_rap_og_rap_uid.rid
-> WHERE (users.status <> 0) AND (og_rap_og_rap_uid.hide = 0)
-> ORDER BY users_name ASC
-> ;
+----+-------------+-------------------+--------+-----------------------------+---------+---------+---------------------+-------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------------+--------+-----------------------------+---------+---------+---------------------+-------+----------------------------------------------+
| 1 | SIMPLE | og_rap_uid | index | NULL | PRIMARY | 12 | NULL | 71613 | Using index; Using temporary; Using filesort |
| 1 | SIMPLE | og_rap_og_rap_uid | eq_ref | PRIMARY | PRIMARY | 4 | apci.og_rap_uid.rid | 1 | Using where |
| 1 | SIMPLE | users | eq_ref | PRIMARY,user_force_password | PRIMARY | 4 | apci.og_rap_uid.uid | 1 | Using where |
+----+-------------+-------------------+--------+-----------------------------+---------+---------+---------------------+-------+----------------------------------------------+
3 rows in set (0.04 sec)
mysql>
admins:
mysql> explain SELECT users.uid AS uid,
-> users.name AS users_name,
-> users.picture AS users_picture
-> FROM users users
-> LEFT JOIN og_uid og_uid ON users.uid = og_uid.uid
-> WHERE (users.status <> 0) AND (og_uid.is_admin in ('0', '0'))
-> ORDER BY users_name ASC
-> ;
+----+-------------+--------+--------+-----------------------------+---------+---------+-----------------+--------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+--------+-----------------------------+---------+---------+-----------------+--------+----------------------------------------------+
| 1 | SIMPLE | og_uid | ALL | NULL | NULL | NULL | NULL | 327841 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | users | eq_ref | PRIMARY,user_force_password | PRIMARY | 4 | apci.og_uid.uid | 1 | Using where |
+----+-------------+--------+--------+-----------------------------+---------+---------+-----------------+--------+----------------------------------------------+
2 rows in set (0.01 sec)
mysql>
all members;
mysql> explain SELECT users.uid AS uid,
-> users.name AS users_name,
-> users.picture AS users_picture
-> FROM users users
-> WHERE users.status <> 0
-> ORDER BY users_name ASC
-> ;
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------+
| 1 | SIMPLE | users | ALL | NULL | NULL | NULL | NULL | 2367 | Using where; Using filesort |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------+
1 row in set (0.01 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment