Skip to content

Instantly share code, notes, and snippets.

@kenn
Created June 13, 2014 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenn/c59256c77af5fc03b241 to your computer and use it in GitHub Desktop.
Save kenn/c59256c77af5fc03b241 to your computer and use it in GitHub Desktop.
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