Last active
August 29, 2015 14:05
-
-
Save kfly8/2e9e144f608dfcf7bc0f to your computer and use it in GitHub Desktop.
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
CREATE TABLE user_event_ranking ( | |
event_id INTEGER, | |
user_id INTEGER, | |
score INTEGER, | |
PRIMARY KEY (event_id, user_id), | |
INDEX KEY (event_id, score) | |
); | |
CREATE TABLE user_event_ranking ( | |
id INTEGER AUTO_INCREMENT, | |
event_id INTEGER, | |
user_id INTEGER, | |
score INTEGER, | |
PRIMARY KEY (id), | |
INDEX KEY (event_id, score) | |
); | |
# SELECT event_id, user_id FROM user_event_ranking ORDER BY score LIMIT 10 | |
#「考えなしにサロゲートをキーを使いたくない」 | |
#「よく考えればuser_idが主キー(の一部)になるテーブルはある」 | |
# この例だと、ちょうどcovering indexになる。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment