Skip to content

Instantly share code, notes, and snippets.

@rfk
Created August 25, 2017 00:56
Show Gist options
  • Save rfk/c0138b09cc02d3b1b21563f30b6d5501 to your computer and use it in GitHub Desktop.
Save rfk/c0138b09cc02d3b1b21563f30b6d5501 to your computer and use it in GitHub Desktop.
MariaDB [weave0]> EXPLAIN SELECT * FROM bso0 WHERE ttl < (UNIX_TIMESTAMP() - 1000) ORDER BY ttl LIMIT 10000;
+------+-------------+-------+-------+---------------+-------------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+-------------+---------+------+------+-------------+
| 1 | SIMPLE | bso0 | range | bso_ttl_idx | bso_ttl_idx | 4 | NULL | 5 | Using where |
+------+-------------+-------+-------+---------------+-------------+---------+------+------+-------------+
1 row in set (0.00 sec)
MariaDB [weave0]>
MariaDB [weave0]> EXPLAIN SELECT * FROM batch_upload_items0 WHERE batch < (UNIX_TIMESTAMP() - 1000) * 1000 ORDER BY batch LIMIT 100000;
+------+-------------+---------------------+------+---------------+------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+---------------------+------+---------------+------+---------+------+------+-----------------------------+
| 1 | SIMPLE | batch_upload_items0 | ALL | PRIMARY | NULL | NULL | NULL | 1 | Using where; Using filesort |
+------+-------------+---------------------+------+---------------+------+---------+------+------+-----------------------------+
1 row in set (0.00 sec)
MariaDB [weave0]>
MariaDB [weave0]> EXPLAIN SELECT * FROM batch_upload_items0 WHERE batch < (333333333 - 1000) * 1000 ORDER BY batch LIMIT 100000;
+------+-------------+---------------------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+---------------------+-------+---------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | batch_upload_items0 | range | PRIMARY | PRIMARY | 8 | NULL | 1 | 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