okashoi / isucon13-practice-20240629

0 stars 0 forks source link

インデックス春 #3

Closed mism-mism closed 1 week ago

mism-mism commented 1 week ago

SELECT * FROM livestream_tags WHERE livestream_id = 7509

貼る前

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE livestream_tags null ALL null null null null 11694 10 Using where

貼ったあと

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE livestream_tags null ref livestream_tags_livestream_id_index livestream_tags_livestream_id_index 8 const 2 100 null

SELECT image FROM icons WHERE user_id = 1015

貼る前

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE icons null ALL null null null null 256 10 Using where

貼ったあと

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE icons null ref icons_user_id_index icons_user_id_index 8 const 1 100 null

SELECT IFNULL(SUM(l2.tip), 0) FROM users u INNER JOIN livestreams l ON l.user_id = u.id INNER JOIN livecomments l2 ON l2.livestream_id = l.id WHERE u.id = 612;

貼る前

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE u null const PRIMARY PRIMARY 8 const 1 100 Using index
1 SIMPLE l2 null ALL null null null null 1001 100 null
1 SIMPLE l null eq_ref PRIMARY PRIMARY 8 isupipe.l2.livestream_id 1 10 Using where

貼ったあと

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE u null const PRIMARY PRIMARY 8 const 1 100 Using index
1 SIMPLE l null ref PRIMARY,livestreams_user_id_index livestreams_user_id_index 8 const 7 100 Using index
1 SIMPLE l2 null ref livecomments_livestream_id_index livecomments_livestream_id_index 8 isupipe.l.id 1 100 null

SELECT COUNT(*) FROM users u INNER JOIN livestreams l ON l.user_id = u.id INNER JOIN reactions r ON r.livestream_id = l.id WHERE u.id = 104

貼る前

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE u null const PRIMARY PRIMARY 8 const 1 100 Using index
1 SIMPLE r null ALL null null null null 1117 100 null
1 SIMPLE l null eq_ref PRIMARY,livestreams_user_id_index PRIMARY 8 isupipe.r.livestream_id 1 5 Using where

貼ったあと

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE u null const PRIMARY PRIMARY 8 const 1 100 Using index
1 SIMPLE l null ref PRIMARY,livestreams_user_id_index livestreams_user_id_index 8 const 8 100 Using index
1 SIMPLE r null ref reactions_livestream_id_index reactions_livestream_id_index 8 isupipe.l.id 1 100 Using index

SELECT * FROM themes WHERE user_id = 98

貼る前

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE themes null ALL null null null null 1284 10 Using where

貼ったあと

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE themes null ref themes_user_id_index themes_user_id_index 8 const 1 100 null
mism-mism commented 1 week ago

8124