Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EXPLAIN SELECT id_member, real_name
- FROM forum_members
- WHERE id_group = 1 OR FIND_IN_SET(1, additional_groups)
- LIMIT 33;
- *************************** 1. row ***************************
- id: 1
- select_type: SIMPLE
- table: forum_members
- type: ALL
- possible_keys: ID_GROUP,debug
- key: NULL
- key_len: NULL
- ref: NULL
- rows: 1369966
- Extra: Using where
- 1 row in set (0.00 sec)
- Better?
- EXPLAIN
- (SELECT id_member, real_name
- FROM forum_members
- WHERE id_group = 1)
- UNION
- (SELECT id_member, real_name
- FROM forum_members
- WHERE FIND_IN_SET(1, additional_groups))
- LIMIT 33\G
- *************************** 1. row ***************************
- id: 1
- select_type: PRIMARY
- table: forum_members
- type: ref
- possible_keys: ID_GROUP,debug
- key: ID_GROUP
- key_len: 2
- ref: const
- rows: 2
- Extra:
- *************************** 2. row ***************************
- id: 2
- select_type: UNION
- table: forum_members
- type: ALL
- possible_keys: NULL
- key: NULL
- key_len: NULL
- ref: NULL
- rows: 1375021
- Extra: Using where
- *************************** 3. row ***************************
- id: NULL
- select_type: UNION RESULT
- table: <union1,2>
- type: ALL
- possible_keys: NULL
- key: NULL
- key_len: NULL
- ref: NULL
- rows: NULL
- Extra:
- 3 rows in set (0.00 sec)
- Though, I must admit I'm not sure an index on additional_groups would help since it's a function. Better here would probably be to normalize it so you have
- forum_user_groups
- - user_id
- - group_id
Add Comment
Please, Sign In to add comment