Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Last active August 30, 2016 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winebarrel/7938971 to your computer and use it in GitHub Desktop.
Save winebarrel/7938971 to your computer and use it in GitHub Desktop.
CREATE TABLE games (
author STRING HASH,
game_id NUMBER RANGE,
INDEX game-type-id-index (game_type_id NUMBER) ALL,
GLOBAL INDEX game-title-index (title STRING, version NUMBER) ALL
) read=4 write=4
ap-northeast-1> insert into games (author, game_id, game_type_id, title, version)
-> values ('Yamada', 100, 2, 'Dragon X', 1), ('Yamada', 101, 2, 'Dragon X', 2);
// 2 rows changed (0.10 sec)
ap-northeast-1> select all * from games;
[
{"author":"Yamada","game_id":100,"game_type_id":2,"title":"Dragon X","version":1},
{"author":"Yamada","game_id":101,"game_type_id":2,"title":"Dragon X","version":2}
]
// 2 rows in set (0.07 sec)
ap-northeast-1> select * from games use index (game-title-index) where title = 'Dragon X';
[
{"author":"Yamada","game_id":100,"game_type_id":2,"title":"Dragon X","version":1},
{"author":"Yamada","game_id":101,"game_type_id":2,"title":"Dragon X","version":2}
]
// 2 rows in set (0.28 sec)
ap-northeast-1> select * from games use index (game-title-index) where title = 'Dragon X' and version = 2;
[
{"author":"Yamada","game_id":101,"game_type_id":2,"title":"Dragon X","version":2}
]
// 1 row in set (0.06 sec)
ap-northeast-1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment