Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mysql> explain SELECT * FROM messages USE INDEX (index_messages_on_friend_id_and_id) WHERE friend_id = 100 AND (id < 1000000) ORDER BY id DESC LIMIT 10\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: messages
type: range
possible_keys: index_messages_on_friend_id_and_id
key: index_messages_on_friend_id_and_id
key_len: 8
ref: NULL
rows: 183182
Extra: Using where
1 row in set (0.00 sec)
mysql> explain SELECT * FROM messages USE INDEX (index_messages_on_friend_id) WHERE friend_id = 100 AND (id < 1000000) ORDER BY id DESC LIMIT 10\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: messages
type: ref
possible_keys: index_messages_on_friend_id
key: index_messages_on_friend_id
key_len: 4
ref: const
rows: 97612
Extra: Using where
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment