hedwig100 / isucon13

0 stars 0 forks source link

sql1246 #7

Open hedwig100 opened 1 year ago

hedwig100 commented 1 year ago
++ dirname ./slowquery.sh
+ cd .
+ rotate_filepath=
+ '[' 0 -eq 1 ']'
+ sudo mysqldumpslow -s t /var/log/mysql/mysql-slow.log
+ head -n 100

Reading mysql slow query log from /var/log/mysql/mysql-slow.log
Count: 5444  Time=0.03s (137s)  Lock=0.00s (0s)  Rows=3.6 (19419), isucon[isucon]@localhost
  SELECT * FROM livestream_tags WHERE livestream_id = N

Count: 9852  Time=0.01s (57s)  Lock=0.00s (0s)  Rows=0.7 (7210), isucon[isucon]@localhost
  SELECT image FROM icons WHERE user_id = N

Count: 196632  Time=0.00s (42s)  Lock=0.00s (0s)  Rows=0.4 (80378), 2users@localhost
  #

Count: 3303  Time=0.01s (23s)  Lock=0.00s (0s)  Rows=1.0 (3303), isucon[isucon]@localhost
  SELECT IFNULL(SUM(l2.tip), N) 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 = N

Count: 3305  Time=0.01s (22s)  Lock=0.00s (0s)  Rows=1.0 (3305), isucon[isucon]@localhost
  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 = N

Count: 746  Time=0.02s (18s)  Lock=0.00s (0s)  Rows=1.0 (746), isucon[isucon]@localhost
  SELECT slot FROM reservation_slots WHERE start_at = N AND end_at = N

Count: 8196  Time=0.00s (16s)  Lock=0.00s (0s)  Rows=1.0 (8196), isucon[isucon]@localhost
  SELECT * FROM themes WHERE user_id = N

Count: 28293  Time=0.00s (15s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  DELETE FROM livecomments
  WHERE
  id = N AND
  livestream_id = N AND
  (SELECT COUNT(*)
  FROM
  (SELECT 'S' AS text) AS texts
  INNER JOIN
  (SELECT CONCAT('S', 'S', 'S') AS pattern) AS patterns
  ON texts.text LIKE patterns.pattern) >= N

Count: 233  Time=0.05s (12s)  Lock=0.00s (0s)  Rows=0.2 (46), isucon[isucon]@localhost
  SELECT id, user_id, livestream_id, word FROM ng_words WHERE user_id = N AND livestream_id = N

Count: 1925  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  COMMIT

Count: 19394  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=1.0 (19394), isucon[isucon]@localhost
  SELECT * FROM tags WHERE id = N

Count: 91  Time=0.06s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  UPDATE reservation_slots SET slot = slot - N WHERE start_at >= N AND end_at <= N

Count: 93  Time=0.05s (4s)  Lock=0.00s (0s)  Rows=8.1 (751), isucon[isucon]@localhost
  SELECT * FROM reservation_slots WHERE start_at >= N AND end_at <= N FOR UPDATE

Count: 1000  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  INSERT INTO users (id, name, display_name, description, password) VALUES (N, 'S', 'S', 'S', 'S')

Count: 78  Time=0.05s (3s)  Lock=0.00s (0s)  Rows=1.5 (118), isucon[isucon]@localhost
  SELECT * FROM livestreams WHERE user_id = N

Count: 200  Time=0.02s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@localhost
  delete from records where domain_id=N and name='S' and type='S'

Count: 7990  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (7990), isucon[isucon]@localhost
  SELECT * FROM users WHERE id = N

Count: 199  Time=0.01s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  INSERT INTO icons (user_id, image) VALUES (N, 'S')

Count: 510  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  INSERT INTO themes (user_id, dark_mode) VALUES (N, true)

Count: 490  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  INSERT INTO themes (user_id, dark_mode) VALUES (N, false)

Count: 400  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.5 (200), isudns[isudns]@localhost
  SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=N and type='S' and name='S' and domain_id=N

Count: 201  Time=0.01s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@localhost
  commit

Count: 4275  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (4275), isucon[isucon]@localhost
  SELECT * FROM livestreams WHERE id = N

Count: 21  Time=0.06s (1s)  Lock=0.00s (0s)  Rows=0.1 (3), isucon[isucon]@localhost
  SELECT * FROM ng_words WHERE user_id = N AND livestream_id = N ORDER BY created_at DESC

Count: 199  Time=0.01s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost
  DELETE FROM icons WHERE user_id = N

Count: 18  Time=0.06s (1s)  Lock=0.00s (0s)  Rows=1.4 (26), isucon[isucon]@localhost
  SELECT * FROM ng_words WHERE livestream_id = N

Count: 200  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isudns[isudns]@localhost
  SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=N and name='S' and domain_id=N

Count: 1875  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1874), isucon[isucon]@localhost
  SELECT * FROM users WHERE name = 'S'

Count: 1672  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isucon[isucon]@localhost