Skip to content

Instantly share code, notes, and snippets.

@holysoros
Created November 6, 2017 16:02
Show Gist options
  • Save holysoros/6acb5c97296ac0869f6cb822a1668550 to your computer and use it in GitHub Desktop.
Save holysoros/6acb5c97296ac0869f6cb822a1668550 to your computer and use it in GitHub Desktop.
mysql> EXPLAIN SELECT slug FROM products WHERE deleted_at IS NULL AND id IN (36215, 10736, 40594, 14078, 40466, 1566, 4455, 6746, 41690, 3448,
39094, 13363, 15491, 10913, 4291, 41940, 40392, 10013, 33510, 6962);
+----+-------------+----------+------------+-------+--------------------------+---------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+-------+--------------------------+---------+---------+------+------+----------+-------------+
| 1 | SIMPLE | products | NULL | range | PRIMARY,index_deleted_at | PRIMARY | 4 | NULL | 20 | 10.00 | Using where |
+----+-------------+----------+------------+-------+--------------------------+---------+---------+------+------+----------+-------------+
mysql> EXPLAIN SELECT slug FROM products WHERE deleted_at IS NULL AND id IN (13480, 13585, 4457, 9482, 33882, 7177, 5269, 41473, 36707, 36158,
11455, 9634, 6315, 39226, 38812, 13510, 4480, 6010, 12027, 5961, 33539,
12813, 37593, 5573, 13581, 36572, 14128, 34371, 35410, 786, 11790, 1752,
40770, 9855, 11477, 41274, 3523, 36149, 39216, 13379, 1701, 4585, 40725, 5661);
+----+-------------+----------+------------+-------+--------------------------+------------------+---------+------+------+----------+-----------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+-------+--------------------------+------------------+---------+------+------+----------+-----------------------+
| 1 | SIMPLE | products | NULL | range | PRIMARY,index_deleted_at | index_deleted_at | 10 | NULL | 50 | 100.00 | Using index condition |
+----+-------------+----------+------------+-------+--------------------------+------------------+---------+------+------+----------+-----------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment