Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. select some_other_column
  2. from `table`
  3. order by primary_index_column asc
  4. limit 4000000, 10;
  5.  
  6. select some_other_column
  7. from `table`
  8. order by secondary_index_column asc
  9. limit 4000000, 10;
  10.  
  11. mysql> explain select some_other_column from `table` order by primary_index_column limit 4000000, 10;
  12. +----+-------------+---------+-------+---------------+---------+---------+------+---------+-------+
  13. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
  14. +----+-------------+---------+-------+---------------+---------+---------+------+---------+-------+
  15. | 1 | SIMPLE | table | index | NULL | PRIMARY | 4 | NULL | 4000010 | |
  16. +----+-------------+---------+-------+---------------+---------+---------+------+---------+-------+
  17.  
  18. mysql> explain select some_other_column from `table` order by secondary_index_column limit 4000000, 10;
  19. +----+-------------+---------+------+---------------+------+---------+------+---------+----------------+
  20. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
  21. +----+-------------+---------+------+---------------+------+---------+------+---------+----------------+
  22. | 1 | SIMPLE | table | ALL | NULL | NULL | NULL | NULL | 4642945 | Using filesort |
  23. +----+-------------+---------+------+---------------+------+---------+------+---------+----------------+
  24.  
  25. ALTER TABLE `table` ADD INDEX mynewndx (indexed_column,some_other_column);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement