Created
October 21, 2012 23:19
-
-
Save kaja47/3928896 to your computer and use it in GitHub Desktop.
MySQL - same queries, vastly different perfomance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- InnoDB table posts (uid, chan, board, threadId, id, ....) | |
-- primary (uid) | |
-- index (chan, board, threadId, id) | |
-- slow as fuck (Using where; Using index) | |
select distinct board | |
from posts | |
where chan = '4chan' | |
-- fast (Using where; Using index for group-by) | |
select distinct chan, board | |
from posts | |
where chan = '4chan' | |
-- fast (Using where; Using index for group-by) | |
select board | |
from posts | |
where chan = '4chan' | |
group by chan, board |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment