Closed pinkumohikan closed 2 years ago
mysql> explain SELECT player_id, MIN(created_at) AS min_created_at FROM visit_history WHERE tenant_id = 45 AND competition_id = '4d1b6fea5' GROUP BY player_id\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: visit_history
partitions: NULL
type: ref
possible_keys: tenant_id_idx
key: tenant_id_idx
key_len: 8
ref: const
rows: 102942
filtered: 10.00
Extra: Using where; Using temporary
1 row in set, 1 warning (0.00 sec)
mysql> ALTER TABLE visit_history ADD INDEX (tenant_id, competition_id, player_id, created_at);
Query OK, 0 rows affected (35.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> explain SELECT player_id, MIN(created_at) AS min_created_at FROM visit_history WHERE tenant_id = 45 AND competition_id = '4d1b6fea5' GROUP BY player_id\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: visit_history
partitions: NULL
type: ref
possible_keys: tenant_id_idx,tenant_id
key: tenant_id
key_len: 1030
ref: const,const
rows: 3146
filtered: 100.00
Extra: Using index
1 row in set, 1 warning (0.00 sec)
https://portal.isucon.net/contestant/benchmark_jobs/1597
Score: 3743 Score Breakdown: base=3743, deduction=0
01:50:35.982227 leaderboardの表示に1秒以上かかったため1人の参加者が離脱しました。
refs #1
に対するチューニング