Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

スコア記録 #1

Open
izumin5210 opened this issue Nov 11, 2023 · 35 comments
Open

スコア記録 #1

izumin5210 opened this issue Nov 11, 2023 · 35 comments

Comments

@izumin5210
Copy link
Member

No description provided.

@izumin5210
Copy link
Member Author

Go 実装初期スコア: 0

{"pass":true,"score":0,"success":242,"fail":63,"messages":["リクエストがタイムアウトしました (GET /)","リクエストがタイムアウトしました (GET /@catherine)","リクエストがタイムアウトしました (GET /@elise)","リクエストがタイムアウトしました (GET /@elma)","リクエストがタイムアウトしま した (GET /@esperanza)","リクエストがタイムアウトしました (GET /@graciela)","リクエストがタイ ムアウトしました (GET /@marianne)","リクエストがタイムアウトしました (GET /@mindy)","リクエス トがタイムアウトしました (GET /@patsy)","リクエストがタイムアウトしました (GET /@roxie)","リクエストがタイムアウトしました (POST /login)","リクエストがタイムアウトしました (POST /register)"]}

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 11, 2023

アクセスログ・クエリログを出す: 0

access.log

$ sudo cat /var/log/nginx/access.log | ./alp ltsv -r --sort sum -o count,1xx,2xx,3xx,4xx,5xx,method,uri,min,max,sum,avg,p90,p95,p99 -m '/image/\d+.(jpg|png|gif)','/posts/\d+','/@\w+'

+-------+-----+-----+-----+-----+-----+--------+--------------------------+-------+--------+---------+-------+--------+--------+--------+
| COUNT | 1XX | 2XX | 3XX | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX   |   SUM   |  AVG  |  P90   |  P95   |  P99   |
+-------+-----+-----+-----+-----+-----+--------+--------------------------+-------+--------+---------+-------+--------+--------+--------+
| 61    | 0   | 7   | 0   | 54  | 0   | GET    | /                        | 1.200 | 10.011 | 545.807 | 8.948 | 10.008 | 10.008 | 10.011 |
| 13    | 0   | 4   | 0   | 9   | 0   | GET    | /@\w+                    | 0.632 | 10.003 | 110.314 | 8.486 | 10.003 | 10.003 | 10.003 |
| 14    | 0   | 14  | 0   | 0   | 0   | GET    | /posts/\d+               | 0.056 | 1.536  | 10.136  | 0.724 | 1.196  | 1.536  | 1.536  |
| 58    | 0   | 0   | 58  | 0   | 0   | POST   | /login                   | 0.020 | 0.440  | 4.196   | 0.072 | 0.104  | 0.420  | 0.440  |
| 76    | 0   | 76  | 0   | 0   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.128  | 1.124   | 0.015 | 0.080  | 0.096  | 0.128  |
| 4     | 0   | 0   | 4   | 0   | 0   | POST   | /register                | 0.012 | 0.072  | 0.164   | 0.041 | 0.072  | 0.072  | 0.072  |
| 2     | 0   | 0   | 1   | 1   | 0   | POST   | /                        | 0.000 | 0.108  | 0.108   | 0.054 | 0.108  | 0.108  | 0.108  |
| 1     | 0   | 1   | 0   | 0   | 0   | GET    | /initialize              | 0.032 | 0.032  | 0.032   | 0.032 | 0.032  | 0.032  | 0.032  |
| 17    | 0   | 17  | 0   | 0   | 0   | GET    | /js/timeago.min.js       | 0.004 | 0.004  | 0.016   | 0.001 | 0.004  | 0.004  | 0.004  |
| 26    | 0   | 26  | 0   | 0   | 0   | GET    | /login                   | 0.000 | 0.008  | 0.012   | 0.000 | 0.000  | 0.004  | 0.008  |
| 17    | 0   | 17  | 0   | 0   | 0   | GET    | /favicon.ico             | 0.000 | 0.004  | 0.008   | 0.000 | 0.004  | 0.004  | 0.004  |
| 1     | 0   | 0   | 1   | 0   | 0   | POST   | /comment                 | 0.004 | 0.004  | 0.004   | 0.004 | 0.004  | 0.004  | 0.004  |
| 17    | 0   | 17  | 0   | 0   | 0   | GET    | /js/main.js              | 0.000 | 0.004  | 0.004   | 0.000 | 0.000  | 0.004  | 0.004  |
| 1     | 0   | 0   | 1   | 0   | 0   | GET    | /logout                  | 0.004 | 0.004  | 0.004   | 0.004 | 0.004  | 0.004  | 0.004  |
| 17    | 0   | 17  | 0   | 0   | 0   | GET    | /css/style.css           | 0.000 | 0.000  | 0.000   | 0.000 | 0.000  | 0.000  | 0.000  |
| 1     | 0   | 0   | 0   | 1   | 0   | GET    | /admin/banned            | 0.000 | 0.000  | 0.000   | 0.000 | 0.000  | 0.000  | 0.000  |
+-------+-----+-----+-----+-----+-----+--------+--------------------------+-------+--------+---------+-------+--------+--------+--------+

slow.log

$ sudo mysqldumpslow -s t /var/log/mysql/slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 1483  Time=1.01s (1501s)  Lock=0.00s (0s)  Rows=2.9 (4272), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N

Count: 1497  Time=0.30s (453s)  Lock=0.00s (0s)  Rows=1.0 (1497), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = N

Count: 61  Time=0.35s (21s)  Lock=0.00s (0s)  Rows=10001.0 (610059), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` ORDER BY `created_at` DESC

Count: 14  Time=0.55s (7s)  Lock=0.00s (0s)  Rows=8.6 (121), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC

Count: 18351  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.7 (12279), isuconp[isuconp]@localhost
  #

Count: 13  Time=0.31s (4s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 5933  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.0 (5933), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 13  Time=0.09s (1s)  Lock=0.00s (0s)  Rows=10.8 (141), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 3  Time=0.38s (1s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 90  Time=0.01s (1s)  Lock=0.00s (0s)  Rows=1.0 (90), isuconp[isuconp]@localhost
  SELECT * FROM `posts` WHERE `id` = N

Count: 3  Time=0.36s (1s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.32s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.45s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 1  Time=0.44s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=10.8 (141), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1  Time=0.32s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.29s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 1  Time=0.16s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 58  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (45), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1  Time=0.10s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `imgdata`, `body`) VALUES (N,'S','S','S')

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 4  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 9150  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

Count: 9150  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

適当に index はる: 23014

{"pass":true,"score":23014,"success":21793,"fail":0,"messages":[]}
ALTER TABLE `users` ADD INDEX (`authority`);
ALTER TABLE `users` ADD INDEX (`account_name`);
ALTER TABLE `posts` ADD INDEX (`created_at`);
ALTER TABLE `posts` ADD INDEX (`user_id`);
ALTER TABLE `comments` ADD INDEX (`user_id`);
ALTER TABLE `comments` ADD INDEX (`post_id`);
access.log

+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 733   | 0   | 733   | 0   | 0   | 0   | GET    | /                        | 0.060 | 0.608 | 246.209 | 0.336 | 0.456 | 0.484 | 0.544 |
| 12643 | 0   | 12643 | 0   | 0   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.004 | 0.176 | 136.229 | 0.011 | 0.024 | 0.040 | 0.072 |
| 160   | 0   | 160   | 0   | 0   | 0   | GET    | /posts                   | 0.072 | 0.728 | 76.139  | 0.476 | 0.592 | 0.620 | 0.700 |
| 1128  | 0   | 1128  | 0   | 0   | 0   | GET    | /posts/\d+               | 0.004 | 0.220 | 58.110  | 0.052 | 0.108 | 0.132 | 0.176 |
| 185   | 0   | 185   | 0   | 0   | 0   | GET    | /@\w+                    | 0.016 | 0.476 | 41.307  | 0.223 | 0.344 | 0.392 | 0.432 |
| 543   | 0   | 0     | 543 | 0   | 0   | POST   | /login                   | 0.028 | 0.216 | 25.740  | 0.047 | 0.092 | 0.108 | 0.144 |
| 130   | 0   | 0     | 65  | 65  | 0   | POST   | /                        | 0.004 | 0.268 | 6.512   | 0.050 | 0.124 | 0.176 | 0.220 |
| 74    | 0   | 0     | 74  | 0   | 0   | POST   | /register                | 0.016 | 0.184 | 5.896   | 0.080 | 0.124 | 0.152 | 0.184 |
| 1451  | 0   | 1451  | 0   | 0   | 0   | GET    | /favicon.ico             | 0.000 | 0.072 | 3.944   | 0.003 | 0.008 | 0.012 | 0.028 |
| 1451  | 0   | 1451  | 0   | 0   | 0   | GET    | /css/style.css           | 0.000 | 0.072 | 3.780   | 0.003 | 0.008 | 0.012 | 0.028 |
| 1451  | 0   | 1451  | 0   | 0   | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.060 | 3.692   | 0.003 | 0.008 | 0.012 | 0.028 |
| 1451  | 0   | 1451  | 0   | 0   | 0   | GET    | /js/main.js              | 0.004 | 0.084 | 3.660   | 0.003 | 0.008 | 0.012 | 0.028 |
| 84    | 0   | 0     | 84  | 0   | 0   | POST   | /comment                 | 0.004 | 0.116 | 2.132   | 0.025 | 0.052 | 0.068 | 0.116 |
| 170   | 0   | 170   | 0   | 0   | 0   | GET    | /login                   | 0.000 | 0.076 | 1.096   | 0.006 | 0.016 | 0.020 | 0.072 |
| 74    | 0   | 0     | 0   | 74  | 0   | GET    | /admin/banned            | 0.004 | 0.132 | 0.948   | 0.013 | 0.028 | 0.056 | 0.132 |
| 85    | 0   | 0     | 85  | 0   | 0   | GET    | /logout                  | 0.000 | 0.028 | 0.288   | 0.003 | 0.008 | 0.012 | 0.028 |
| 1     | 0   | 1     | 0   | 0   | 0   | GET    | /initialize              | 0.020 | 0.020 | 0.020   | 0.020 | 0.020 | 0.020 | 0.020 |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Count: 733  Time=0.08s (58s)  Lock=0.00s (0s)  Rows=10032.0 (7353469), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` ORDER BY `created_at` DESC

Count: 160  Time=0.09s (13s)  Lock=0.00s (0s)  Rows=9895.9 (1583340), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `created_at` <= 'S' ORDER BY `created_at` DESC

Count: 231010  Time=0.00s (11s)  Lock=0.00s (0s)  Rows=7.4 (1712816), isuconp[isuconp]@localhost
  #

Count: 13771  Time=0.00s (11s)  Lock=0.00s (0s)  Rows=1.0 (13771), isuconp[isuconp]@localhost
  SELECT * FROM `posts` WHERE `id` = N

Count: 55993  Time=0.00s (9s)  Lock=0.00s (0s)  Rows=1.0 (55993), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 19980  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=1.2 (23383), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N

Count: 21108  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=1.0 (21108), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = N

Count: 65  Time=0.05s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `imgdata`, `body`) VALUES (N,'S','S','S')

Count: 84  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 74  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 5984  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1128  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.3 (10534), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC

Count: 543  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (458), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 185  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1837), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 185  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1837), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 185  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (185), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 185  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (185), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (26), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 21  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (21), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 22  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (22), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (11), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 74  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 3201  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 113904  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 113905  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#3 画像をファイルに書き出し: 28329

{"pass":true,"score":28329,"success":26987,"fail":0,"messages":[]}
access.log

+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 855   | 0   | 855   | 0   | 0   | 0   | GET    | /                        | 0.060 | 0.588 | 277.668 | 0.325 | 0.436 | 0.460 | 0.516 |
| 200   | 0   | 200   | 0   | 0   | 0   | GET    | /posts                   | 0.060 | 0.792 | 91.728  | 0.459 | 0.580 | 0.616 | 0.676 |
| 15915 | 0   | 15915 | 0   | 0   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.120 | 62.192  | 0.004 | 0.012 | 0.016 | 0.036 |
| 1361  | 0   | 1361  | 0   | 0   | 0   | GET    | /posts/\d+               | 0.004 | 0.284 | 61.352  | 0.045 | 0.104 | 0.136 | 0.180 |
| 205   | 0   | 205   | 0   | 0   | 0   | GET    | /@\w+                    | 0.016 | 0.492 | 43.644  | 0.213 | 0.324 | 0.360 | 0.444 |
| 623   | 0   | 0     | 623 | 0   | 0   | POST   | /login                   | 0.004 | 0.212 | 30.044  | 0.048 | 0.092 | 0.108 | 0.144 |
| 78    | 0   | 0     | 78  | 0   | 0   | POST   | /register                | 0.016 | 0.176 | 5.476   | 0.070 | 0.128 | 0.144 | 0.176 |
| 1791  | 0   | 1791  | 0   | 0   | 0   | GET    | /js/main.js              | 0.000 | 0.064 | 5.028   | 0.003 | 0.008 | 0.016 | 0.036 |
| 1791  | 0   | 1791  | 0   | 0   | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.064 | 4.996   | 0.003 | 0.008 | 0.016 | 0.032 |
| 1791  | 0   | 1791  | 0   | 0   | 0   | GET    | /favicon.ico             | 0.000 | 0.068 | 4.952   | 0.003 | 0.008 | 0.016 | 0.028 |
| 1791  | 0   | 1791  | 0   | 0   | 0   | GET    | /css/style.css           | 0.000 | 0.100 | 4.744   | 0.003 | 0.008 | 0.016 | 0.032 |
| 138   | 0   | 0     | 69  | 69  | 0   | POST   | /                        | 0.004 | 0.140 | 3.668   | 0.027 | 0.068 | 0.084 | 0.120 |
| 89    | 0   | 0     | 89  | 0   | 0   | POST   | /comment                 | 0.004 | 0.156 | 1.976   | 0.022 | 0.044 | 0.056 | 0.156 |
| 212   | 0   | 212   | 0   | 0   | 0   | GET    | /login                   | 0.008 | 0.084 | 1.280   | 0.006 | 0.012 | 0.024 | 0.068 |
| 106   | 0   | 0     | 106 | 0   | 0   | GET    | /logout                  | 0.004 | 0.076 | 0.816   | 0.008 | 0.024 | 0.040 | 0.072 |
| 78    | 0   | 0     | 0   | 78  | 0   | GET    | /admin/banned            | 0.000 | 0.068 | 0.740   | 0.009 | 0.020 | 0.048 | 0.068 |
| 1     | 0   | 1     | 0   | 0   | 0   | GET    | /initialize              | 0.032 | 0.032 | 0.032   | 0.032 | 0.032 | 0.032 | 0.032 |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Count: 855  Time=0.09s (73s)  Lock=0.00s (0s)  Rows=10034.3 (8579332), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` ORDER BY `created_at` DESC

Count: 200  Time=0.10s (20s)  Lock=0.00s (0s)  Rows=9896.0 (1979190), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `created_at` <= 'S' ORDER BY `created_at` DESC

Count: 240439  Time=0.00s (13s)  Lock=0.00s (0s)  Rows=8.8 (2117597), isuconp[isuconp]@localhost
  #

Count: 66355  Time=0.00s (11s)  Lock=0.00s (0s)  Rows=1.0 (66355), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 23549  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=1.2 (27403), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N

Count: 24910  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=1.0 (24910), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = N

Count: 89  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1361  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.6 (13001), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC

Count: 78  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 69  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1361  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1361), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 623  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (517), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1633  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 205  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (205), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 205  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (2126), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 205  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (2126), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 205  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (205), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (34), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 78  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 21  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (21), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (25), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (32), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (17), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (19), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 119698  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

Count: 119690  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 1051  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#4: posts を全件 SELECT するのをやめる: 41121

CPU usage は app : mysql = 1 : 4 くらい

{"pass":true,"score":40190,"success":41121,"fail":214,"messages":["1ページに表示される画像の数が足りません (GET /posts)"]}
access.log

+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 977   | 0   | 977   | 0   | 0   | 0   | GET    | /                        | 0.036 | 0.644 | 449.764 | 0.460 | 0.536 | 0.552 | 0.604 |
| 3259  | 0   | 3259  | 0   | 0   | 0   | GET    | /posts/\d+               | 0.004 | 0.084 | 42.284  | 0.013 | 0.028 | 0.036 | 0.048 |
| 413   | 0   | 413   | 0   | 0   | 0   | GET    | /@\w+                    | 0.008 | 0.236 | 36.056  | 0.087 | 0.136 | 0.156 | 0.184 |
| 19062 | 0   | 19062 | 0   | 0   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.016 | 16.268  | 0.001 | 0.004 | 0.004 | 0.004 |
| 585   | 0   | 0     | 585 | 0   | 0   | POST   | /login                   | 0.004 | 0.088 | 12.504  | 0.021 | 0.032 | 0.040 | 0.052 |
| 61    | 0   | 0     | 61  | 0   | 0   | POST   | /register                | 0.012 | 0.068 | 2.012   | 0.033 | 0.044 | 0.052 | 0.068 |
| 116   | 0   | 0     | 58  | 58  | 0   | POST   | /                        | 0.004 | 0.068 | 1.816   | 0.016 | 0.044 | 0.048 | 0.064 |
| 4056  | 0   | 4056  | 0   | 0   | 0   | GET    | /js/main.js              | 0.000 | 0.012 | 1.744   | 0.000 | 0.004 | 0.004 | 0.004 |
| 4056  | 0   | 4056  | 0   | 0   | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.012 | 1.724   | 0.000 | 0.000 | 0.004 | 0.004 |
| 4056  | 0   | 4056  | 0   | 0   | 0   | GET    | /favicon.ico             | 0.000 | 0.012 | 1.724   | 0.000 | 0.004 | 0.004 | 0.004 |
| 4056  | 0   | 4056  | 0   | 0   | 0   | GET    | /css/style.css           | 0.000 | 0.012 | 1.596   | 0.000 | 0.000 | 0.004 | 0.004 |
| 99    | 0   | 0     | 99  | 0   | 0   | POST   | /comment                 | 0.004 | 0.036 | 0.940   | 0.009 | 0.016 | 0.020 | 0.036 |
| 214   | 0   | 214   | 0   | 0   | 0   | GET    | /posts                   | 0.000 | 0.012 | 0.356   | 0.002 | 0.004 | 0.008 | 0.012 |
| 206   | 0   | 206   | 0   | 0   | 0   | GET    | /login                   | 0.000 | 0.016 | 0.236   | 0.001 | 0.004 | 0.004 | 0.008 |
| 61    | 0   | 0     | 0   | 61  | 0   | GET    | /admin/banned            | 0.004 | 0.012 | 0.140   | 0.002 | 0.004 | 0.008 | 0.012 |
| 103   | 0   | 0     | 103 | 0   | 0   | GET    | /logout                  | 0.000 | 0.008 | 0.072   | 0.001 | 0.004 | 0.004 | 0.004 |
| 1     | 0   | 1     | 0   | 0   | 0   | GET    | /initialize              | 0.048 | 0.048 | 0.048   | 0.048 | 0.048 | 0.048 | 0.048 |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Count: 977  Time=0.34s (328s)  Lock=0.00s (0s)  Rows=20.0 (19540), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 288245  Time=0.00s (27s)  Lock=0.00s (0s)  Rows=0.7 (196791), isuconp[isuconp]@localhost
  #

Count: 82565  Time=0.00s (26s)  Lock=0.00s (0s)  Rows=1.0 (82565), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 23600  Time=0.00s (11s)  Lock=0.00s (0s)  Rows=1.0 (22512), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N

Count: 26859  Time=0.00s (9s)  Lock=0.00s (0s)  Rows=1.0 (26859), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = N

Count: 3259  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=9.9 (32222), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC

Count: 99  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 3259  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3259), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 585  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (482), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 58  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 61  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1932  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 413  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.8 (4061), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 413  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (413), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 413  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.8 (4061), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 69  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (69), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (54), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 413  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (413), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 50  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (50), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (47), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (37), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 39  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (39), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 61  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (23), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (16), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (24), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (11), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 143662  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

Count: 143439  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 1144  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

#2 makePosts の N+1 クエリを解消: 53289

{"pass":true,"score":53289,"success":54318,"fail":249,"messages":["1ページに表示される画像の数が足りません (GET /posts)"]}
access.log

+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 1161  | 0   | 1161  | 0   | 0   | 0   | GET    | /                        | 0.024 | 0.528 | 418.809 | 0.361 | 0.416 | 0.428 | 0.456 |
| 4661  | 0   | 4661  | 0   | 0   | 0   | GET    | /posts/\d+               | 0.004 | 0.060 | 33.740  | 0.007 | 0.016 | 0.020 | 0.032 |
| 23911 | 0   | 23911 | 0   | 0   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.028 | 28.604  | 0.001 | 0.004 | 0.004 | 0.008 |
| 705   | 0   | 0     | 705 | 0   | 0   | POST   | /login                   | 0.008 | 0.124 | 20.600  | 0.029 | 0.052 | 0.060 | 0.088 |
| 570   | 0   | 570   | 0   | 0   | 0   | GET    | /@\w+                    | 0.004 | 0.100 | 11.334  | 0.020 | 0.036 | 0.044 | 0.060 |
| 73    | 0   | 0     | 73  | 0   | 0   | POST   | /register                | 0.016 | 0.108 | 3.584   | 0.049 | 0.080 | 0.088 | 0.108 |
| 5646  | 0   | 5646  | 0   | 0   | 0   | GET    | /favicon.ico             | 0.000 | 0.024 | 3.448   | 0.001 | 0.004 | 0.004 | 0.008 |
| 5646  | 0   | 5646  | 0   | 0   | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.020 | 3.172   | 0.001 | 0.004 | 0.004 | 0.004 |
| 5646  | 0   | 5646  | 0   | 0   | 0   | GET    | /css/style.css           | 0.000 | 0.012 | 3.148   | 0.001 | 0.004 | 0.004 | 0.004 |
| 5646  | 0   | 5646  | 0   | 0   | 0   | GET    | /js/main.js              | 0.000 | 0.024 | 3.128   | 0.001 | 0.004 | 0.004 | 0.004 |
| 138   | 0   | 0     | 69  | 69  | 0   | POST   | /                        | 0.016 | 0.084 | 2.536   | 0.018 | 0.048 | 0.056 | 0.076 |
| 131   | 0   | 0     | 131 | 0   | 0   | POST   | /comment                 | 0.004 | 0.052 | 1.652   | 0.013 | 0.020 | 0.028 | 0.036 |
| 249   | 0   | 249   | 0   | 0   | 0   | GET    | /posts                   | 0.004 | 0.016 | 0.628   | 0.003 | 0.008 | 0.008 | 0.016 |
| 242   | 0   | 242   | 0   | 0   | 0   | GET    | /login                   | 0.000 | 0.008 | 0.360   | 0.001 | 0.004 | 0.004 | 0.008 |
| 73    | 0   | 0     | 0   | 73  | 0   | GET    | /admin/banned            | 0.000 | 0.020 | 0.264   | 0.004 | 0.012 | 0.012 | 0.020 |
| 121   | 0   | 0     | 121 | 0   | 0   | GET    | /logout                  | 0.004 | 0.008 | 0.140   | 0.001 | 0.004 | 0.004 | 0.004 |
| 1     | 0   | 1     | 0   | 0   | 0   | GET    | /initialize              | 0.036 | 0.036 | 0.036   | 0.036 | 0.036 | 0.036 | 0.036 |
+-------+-----+-------+-----+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 1161  Time=0.34s (396s)  Lock=0.00s (0s)  Rows=20.0 (23220), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 73746  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=3.2 (232690), isuconp[isuconp]@localhost
  #

Count: 1163  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=9.5 (11042), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 4661  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=9.8 (45701), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 5293  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (5293), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1171  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=19.9 (23277), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4661  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (4579), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N) GROUP BY `post_id`

Count: 131  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 4661  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4661), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 1163  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.7 (4293), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

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

Count: 73  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 659  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (5853), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 705  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (584), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 69  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 597  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.2 (4311), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 618  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.2 (5079), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 596  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.7 (5770), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.8 (2496), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 525  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.6 (5584), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 389  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.2 (4347), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 57  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=38.7 (2207), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 80  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.9 (2389), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 455  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.3 (2887), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.8 (2222), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 570  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.1 (5776), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 58  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.8 (1555), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 345  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.4 (1855), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 245  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.2 (3226), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.9 (1531), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 570  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (570), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 98  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.1 (3149), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 570  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.1 (5776), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 570  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (570), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (76), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 187  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.7 (2570), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1351  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (986), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 149  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.0 (2086), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 80  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (80), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (62), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.0 (774), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.8 (540), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 14  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=41.8 (585), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 16  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=44.5 (712), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 77  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.1 (2706), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=47.7 (907), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 84  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (167), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.1 (1428), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (748), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 58  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (58), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (57), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 28  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.3 (1213), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (64), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 67  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.9 (2542), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.3 (1133), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.3 (1250), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.0 (522), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.5 (2332), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (47), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 84  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.5 (1470), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 65  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.5 (1006), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (742), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.4 (552), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (832), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (43), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.2 (992), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (1510), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (19), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 80  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (798), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (384), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=50.3 (302), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (378), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 53  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.6 (1408), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (737), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.1 (991), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (16), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.1 (461), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 48  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.8 (999), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 58  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (520), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (511), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (14), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 33  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.8 (93), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.0 (150), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 2  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=54.0 (108), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (258), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) GROUP BY `post_id`

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.0 (304), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (329), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 2  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (239), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (108), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (101), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (195), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (27), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=58.0 (232), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.0 (230), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (50), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N) GROUP BY `post_id`

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (92), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.0 (215), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.5 (75), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.5 (69), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=57.0 (57), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (36), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N) GROUP BY `post_id`

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.6 (128), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.0 (36), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (6), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.0 (33), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.0 (49), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (9), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N) GROUP BY `post_id`

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.0 (19), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.0 (28), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.0 (36), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (2), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N) GROUP BY `post_id`

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 943  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 36277  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 36526  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

@izumin5210
Copy link
Member Author

#5 posts 取得で created_at DESC の index を強制: 71693

Go が CPU を7~8割ほど使うようになった

{"pass":true,"score":70189,"success":71693,"fail":629,"messages":["1ページに表示される画像の数が足りません (GET /posts)"]}
access.log

+-------+-----+-------+------+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX  | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+------+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 41446 | 0   | 41445 | 0    | 1   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.004 | 0.032 | 126.564 | 0.003 | 0.008 | 0.008 | 0.016 |
| 2037  | 0   | 0     | 2036 | 1   | 0   | POST   | /login                   | 0.004 | 0.144 | 108.708 | 0.053 | 0.092 | 0.104 | 0.124 |
| 3485  | 0   | 3483  | 0    | 2   | 0   | GET    | /                        | 0.004 | 0.064 | 53.284  | 0.015 | 0.028 | 0.028 | 0.040 |
| 3542  | 0   | 3540  | 0    | 2   | 0   | GET    | /posts/\d+               | 0.008 | 0.052 | 35.464  | 0.010 | 0.020 | 0.024 | 0.032 |
| 363   | 0   | 0     | 362  | 1   | 0   | POST   | /register                | 0.012 | 0.160 | 22.056  | 0.061 | 0.088 | 0.100 | 0.120 |
| 742   | 0   | 741   | 0    | 1   | 0   | GET    | /@\w+                    | 0.004 | 0.080 | 15.544  | 0.021 | 0.032 | 0.040 | 0.048 |
| 4867  | 0   | 4867  | 0    | 0   | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.024 | 10.576  | 0.002 | 0.004 | 0.008 | 0.012 |
| 4867  | 0   | 4867  | 0    | 0   | 0   | GET    | /favicon.ico             | 0.004 | 0.024 | 10.460  | 0.002 | 0.004 | 0.008 | 0.012 |
| 4867  | 0   | 4867  | 0    | 0   | 0   | GET    | /js/main.js              | 0.004 | 0.024 | 10.156  | 0.002 | 0.004 | 0.008 | 0.012 |
| 508   | 0   | 0     | 254  | 254 | 0   | POST   | /                        | 0.004 | 0.100 | 9.988   | 0.020 | 0.048 | 0.060 | 0.076 |
| 4867  | 0   | 4866  | 0    | 1   | 0   | GET    | /css/style.css           | 0.000 | 0.024 | 9.776   | 0.002 | 0.004 | 0.008 | 0.012 |
| 470   | 0   | 0     | 470  | 0   | 0   | POST   | /comment                 | 0.004 | 0.048 | 5.092   | 0.011 | 0.016 | 0.020 | 0.028 |
| 641   | 0   | 641   | 0    | 0   | 0   | GET    | /posts                   | 0.000 | 0.028 | 2.356   | 0.004 | 0.008 | 0.012 | 0.020 |
| 362   | 0   | 0     | 0    | 362 | 0   | GET    | /admin/banned            | 0.004 | 0.024 | 1.836   | 0.005 | 0.012 | 0.012 | 0.024 |
| 462   | 0   | 462   | 0    | 0   | 0   | GET    | /login                   | 0.004 | 0.036 | 1.772   | 0.004 | 0.008 | 0.008 | 0.016 |
| 232   | 0   | 0     | 232  | 0   | 0   | GET    | /logout                  | 0.000 | 0.024 | 0.880   | 0.004 | 0.008 | 0.012 | 0.020 |
| 2     | 0   | 2     | 0    | 0   | 0   | GET    | /initialize              | 0.036 | 0.056 | 0.092   | 0.046 | 0.056 | 0.056 | 0.056 |
+-------+-----+-------+------+-----+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 97759  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=3.3 (323621), isuconp[isuconp]@localhost
  #

Count: 470  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 3487  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=4.1 (14170), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 363  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 254  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 3487  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.7 (5801), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 3485  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (69700), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 3498  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.8 (69389), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3542  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.2 (32498), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3542  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (3258), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N) GROUP BY `post_id`

Count: 4738  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4738), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

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

Count: 3542  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3542), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 2037  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (1806), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.6 (3452), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 742  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (7545), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 96  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.8 (2865), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 77  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.5 (2730), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 742  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (742), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2368  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 63  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.6 (2430), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.5 (2148), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 742  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (7545), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 742  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (742), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 71  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.7 (1681), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 490  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.2 (4018), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 486  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.8 (4267), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 460  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.6 (3476), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.6 (1404), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 411  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (4059), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 434  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.8 (2960), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.4 (1326), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 360  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.8 (2103), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 294  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (3047), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=47.5 (1140), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (762), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 363  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1153), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 2  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 201  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (2382), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 114  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.5 (3704), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.9 (791), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 240  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (1222), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 175  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.5 (2359), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 117  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.3 (3429), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (106), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 96  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (956), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 2  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 77  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.8 (912), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 87  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (2056), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 74  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.3 (2831), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 96  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (96), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 77  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (77), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.4 (2902), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 63  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (811), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 59  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.1 (2721), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (717), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 63  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (63), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 188  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (374), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (81), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.7 (1822), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 155  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.5 (690), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.5 (1325), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 71  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (561), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=50.0 (500), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 83  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.6 (2207), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 91  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.3 (1574), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 71  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (71), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.0 (300), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 2  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 53  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.1 (2179), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.9 (468), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (68), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.1 (1667), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.2 (1477), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.8 (442), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (203), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 55  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (767), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.0 (1760), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 36  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=44.0 (1583), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=57.0 (285), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (32), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (254), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) GROUP BY `post_id`

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (382), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.3 (271), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (43), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (24), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=54.0 (162), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (18), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.8 (266), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 33  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.1 (531), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.7 (167), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (100), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N) GROUP BY `post_id`

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (20), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.2 (389), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (68), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N) GROUP BY `post_id`

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (17), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.0 (95), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (36), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.5 (40), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=58.7 (352), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.0 (184), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.0 (54), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (12), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.5 (69), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.7 (92), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (12), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N) GROUP BY `post_id`

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.0 (28), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.5 (67), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (44), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.0 (49), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (4), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N) GROUP BY `post_id`

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.0 (36), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.0 (38), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.0 (32), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (23), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.0 (27), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.0 (25), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.0 (25), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1780  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 47669  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 48310  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#6 静的ファイルを Nginx から配信: 102835

{"pass":true,"score":100672,"success":102835,"fail":880,"messages":["1ページに表示される画像の数が足りません (GET /posts)"]}
access.log

+-------+-----+-------+------+-----+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX  | 4XX | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+------+-----+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 2798  | 0   | 0     | 2798 | 0   | 0   | POST   | /login                   | 0.012 | 0.096 | 93.183 | 0.033 | 0.056 | 0.064 | 0.076 |
| 4793  | 0   | 4793  | 0    | 0   | 0   | GET    | /                        | 0.004 | 0.068 | 50.643 | 0.011 | 0.020 | 0.024 | 0.032 |
| 5079  | 0   | 5079  | 0    | 0   | 0   | GET    | /posts/\d+               | 0.004 | 0.040 | 35.328 | 0.007 | 0.012 | 0.016 | 0.028 |
| 57929 | 0   | 57929 | 0    | 0   | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.029 | 25.093 | 0.000 | 0.000 | 0.002 | 0.012 |
| 507   | 0   | 0     | 507  | 0   | 0   | POST   | /register                | 0.012 | 0.112 | 20.632 | 0.041 | 0.060 | 0.068 | 0.084 |
| 1033  | 0   | 1033  | 0    | 0   | 0   | GET    | /@\w+                    | 0.004 | 0.084 | 15.064 | 0.015 | 0.024 | 0.028 | 0.040 |
| 674   | 0   | 0     | 337  | 337 | 0   | POST   | /                        | 0.000 | 0.084 | 9.628  | 0.014 | 0.040 | 0.052 | 0.072 |
| 636   | 0   | 0     | 636  | 0   | 0   | POST   | /comment                 | 0.004 | 0.060 | 5.228  | 0.008 | 0.012 | 0.016 | 0.024 |
| 880   | 0   | 880   | 0    | 0   | 0   | GET    | /posts                   | 0.000 | 0.032 | 2.660  | 0.003 | 0.008 | 0.012 | 0.020 |
| 654   | 0   | 654   | 0    | 0   | 0   | GET    | /login                   | 0.000 | 0.020 | 1.696  | 0.003 | 0.008 | 0.008 | 0.016 |
| 507   | 0   | 0     | 0    | 507 | 0   | GET    | /admin/banned            | 0.000 | 0.032 | 1.600  | 0.003 | 0.008 | 0.012 | 0.016 |
| 327   | 0   | 0     | 327  | 0   | 0   | GET    | /logout                  | 0.000 | 0.024 | 0.836  | 0.003 | 0.004 | 0.008 | 0.016 |
| 1     | 0   | 1     | 0    | 0   | 0   | GET    | /initialize              | 0.024 | 0.024 | 0.024  | 0.024 | 0.024 | 0.024 | 0.024 |
| 6972  | 0   | 6972  | 0    | 0   | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 6972  | 0   | 6972  | 0    | 0   | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 6972  | 0   | 6972  | 0    | 0   | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 6972  | 0   | 6972  | 0    | 0   | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-------+------+-----+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 135198  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=3.2 (428706), isuconp[isuconp]@localhost
  #

Count: 636  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 507  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 4800  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=2.2 (10557), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 4800  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.9 (4541), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 337  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 4793  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=20.0 (95860), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 4809  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.7 (94780), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5079  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.1 (46268), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 5079  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (4676), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N) GROUP BY `post_id`

Count: 6410  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6410), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

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

Count: 5079  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5079), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 2798  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (2471), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.6 (4623), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1033  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (10651), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 108  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.0 (4107), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.6 (3970), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1033  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1033), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 3362  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.5 (2777), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 83  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.5 (2947), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1033  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (10651), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1033  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1033), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 97  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.5 (2575), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 702  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.2 (5783), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 690  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (6140), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=47.5 (2184), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 668  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.8 (5221), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 595  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (6205), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.8 (1706), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 621  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.6 (4125), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.7 (1992), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 466  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (2760), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 401  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.7 (3892), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (1095), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1543), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 366  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.2 (1885), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 247  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.6 (3359), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 150  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.4 (4866), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 507  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (142), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 267  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.5 (3083), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1328), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 152  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.4 (4476), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.6 (1003), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 108  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.8 (1379), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=50.1 (752), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (134), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (928), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 108  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (108), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (118), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 96  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.4 (3685), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.3 (3603), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 123  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (2905), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 167  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.8 (1970), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 97  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (860), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 205  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.4 (900), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 83  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (985), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 128  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.4 (2221), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 109  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.5 (2890), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 83  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (83), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 97  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (97), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.8 (444), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 114  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.1 (2289), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.9 (569), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (730), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.6 (666), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.3 (2360), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.9 (2211), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (49), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (46), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (82), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.3 (1204), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 161  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (322), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (62), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.8 (1048), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (365), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) GROUP BY `post_id`

Count: 115  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.5 (401), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (228), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.8 (279), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.4 (1186), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.7 (337), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=54.0 (216), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (23), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 67  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.7 (183), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=44.1 (1146), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.1 (936), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (252), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.9 (148), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N) GROUP BY `post_id`

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (30), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.2 (435), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.7 (78), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.2 (366), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (76), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N) GROUP BY `post_id`

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (19), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.6 (93), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=58.1 (407), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.4 (304), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.4 (137), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.0 (72), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.0 (230), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.9 (26), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N) GROUP BY `post_id`

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.0 (165), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.2 (186), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.5 (126), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (69), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (88), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.0 (98), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.0 (43), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (72), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.5 (79), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.0 (56), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=48.0 (48), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.0 (29), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.0 (35), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.0 (25), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2306  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 66006  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 66886  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#7 外部コマンド呼び出しをやめる: 114241

CPU 使い切れなくなった

{"pass":true,"score":117273,"success":114241,"fail":857,"messages":["1ページに表示される画像の数が足りません (GET /posts)"]}
access.log

+-------+-----+-------+------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX  | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 7197  | 0   | 7197  | 0    | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 59.940 | 0.008 | 0.012 | 0.016 | 0.020 |
| 5722  | 0   | 5722  | 0    | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.032 | 31.728 | 0.006 | 0.008 | 0.012 | 0.016 |
| 60873 | 0   | 60873 | 0    | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.030 | 25.434 | 0.000 | 0.000 | 0.002 | 0.011 |
| 1499  | 0   | 1499  | 0    | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.036 | 18.200 | 0.012 | 0.020 | 0.020 | 0.024 |
| 1162  | 0   | 0     | 581  | 581  | 0   | POST   | /                        | 0.004 | 0.068 | 14.488 | 0.012 | 0.028 | 0.048 | 0.060 |
| 4694  | 0   | 0     | 4694 | 0    | 0   | POST   | /login                   | 0.000 | 0.016 | 10.204 | 0.002 | 0.004 | 0.008 | 0.008 |
| 1165  | 0   | 0     | 1165 | 0    | 0   | POST   | /register                | 0.004 | 0.060 | 8.600  | 0.007 | 0.012 | 0.012 | 0.016 |
| 1095  | 0   | 0     | 1095 | 0    | 0   | POST   | /comment                 | 0.004 | 0.064 | 8.040  | 0.007 | 0.012 | 0.012 | 0.020 |
| 1165  | 0   | 0     | 0    | 1165 | 0   | GET    | /admin/banned            | 0.004 | 0.016 | 2.516  | 0.002 | 0.004 | 0.008 | 0.008 |
| 857   | 0   | 857   | 0    | 0    | 0   | GET    | /posts                   | 0.000 | 0.012 | 1.796  | 0.002 | 0.004 | 0.008 | 0.008 |
| 848   | 0   | 848   | 0    | 0    | 0   | GET    | /login                   | 0.004 | 0.012 | 1.336  | 0.002 | 0.004 | 0.004 | 0.008 |
| 424   | 0   | 0     | 424  | 0    | 0   | GET    | /logout                  | 0.004 | 0.012 | 0.644  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1     | 0   | 1     | 0    | 0    | 0   | GET    | /initialize              | 0.072 | 0.072 | 0.072  | 0.072 | 0.072 | 0.072 | 0.072 |
| 7060  | 0   | 7060  | 0    | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 7060  | 0   | 7060  | 0    | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 7060  | 0   | 7060  | 0    | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 7060  | 0   | 7060  | 0    | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-------+------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 188923  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=3.1 (581862), isuconp[isuconp]@localhost
  #

Count: 1165  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1095  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 7207  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.5 (10605), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 581  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 7207  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.7 (5251), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 7197  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=20.0 (143940), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 7216  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=19.7 (142475), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5722  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.6 (49466), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

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

Count: 5722  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (5047), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N) GROUP BY `post_id`

Count: 7163  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7163), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 5722  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5722), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 4694  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (4270), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1499  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (15303), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 193  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.4 (6248), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 6355  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 166  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.1 (5831), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1499  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1499), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.2 (4972), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 133  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.0 (5051), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 164  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.1 (4286), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1499  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1499), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 152  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.9 (3484), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1499  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (15303), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.5 (2685), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 753  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.4 (6322), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.3 (2807), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.6 (2656), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 782  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (6256), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 681  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.3 (6303), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 708  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.1 (5045), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 1165  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (1687), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 622  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.3 (3899), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 540  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (5404), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 667  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (1329), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 550  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.6 (3059), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.5 (1653), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 166  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.8 (1952), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 198  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.5 (6440), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 193  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.8 (2090), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 193  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (193), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 157  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.5 (4163), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.8 (1666), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 385  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.8 (1831), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 315  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.1 (3506), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 285  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.0 (3718), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 133  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.8 (1697), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 166  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (166), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (170), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 169  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.4 (4977), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 164  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.8 (1439), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 148  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.4 (5233), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 149  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (3523), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 152  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.7 (1170), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 164  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (164), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 133  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (133), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 114  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.2 (4359), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 181  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.0 (3080), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.3 (3207), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 152  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (152), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 45  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.7 (660), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 188  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.3 (2128), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.9 (899), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=48.4 (775), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 55  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.3 (2548), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.1 (2999), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.5 (1050), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (131), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.8 (937), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 196  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.1 (795), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.9 (1625), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.7 (897), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 113  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.6 (1651), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (57), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (95), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (563), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) GROUP BY `post_id`

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (382), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (68), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=53.1 (478), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=56.5 (339), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 121  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.2 (387), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 126  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.8 (358), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 21  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.0 (1156), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.7 (557), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.5 (792), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (38), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 45  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.9 (220), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N) GROUP BY `post_id`

Count: 45  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (45), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 36  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (574), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.3 (261), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (128), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N) GROUP BY `post_id`

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (16), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.9 (503), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (32), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=58.5 (585), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (160), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (81), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.6 (256), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.5 (331), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.5 (343), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.3 (333), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.4 (391), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (113), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.7 (276), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (30), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.9 (255), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.6 (248), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=45.5 (273), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.7 (159), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.4 (197), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (27), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N) GROUP BY `post_id`

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.8 (139), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=42.2 (169), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.0 (80), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=45.0 (135), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.8 (103), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (10), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N) GROUP BY `post_id`

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.0 (52), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=48.0 (48), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.0 (55), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.0 (28), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.0 (49), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3578  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 92244  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 93101  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#8 クエリの typo を修正: 136134

fail になってなかったのか…
CPU はマシになった(80%程度の利用)

{"pass":true,"score":136134,"success":124922,"fail":0,"messages":[]}
access.log

+-------+-----+-------+------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT | 1XX |  2XX  | 3XX  | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+-------+-----+-------+------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 6342  | 0   | 6342  | 0    | 0    | 0   | GET    | /                        | 0.004 | 0.056 | 59.500 | 0.009 | 0.016 | 0.016 | 0.024 |
| 5741  | 0   | 5741  | 0    | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.036 | 37.220 | 0.006 | 0.012 | 0.012 | 0.020 |
| 1437  | 0   | 1437  | 0    | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.044 | 19.632 | 0.014 | 0.020 | 0.024 | 0.032 |
| 1310  | 0   | 1310  | 0    | 0    | 0   | GET    | /posts                   | 0.004 | 0.036 | 18.836 | 0.014 | 0.020 | 0.024 | 0.028 |
| 73701 | 0   | 73701 | 0    | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.031 | 17.856 | 0.000 | 0.000 | 0.001 | 0.008 |
| 1114  | 0   | 0     | 557  | 557  | 0   | POST   | /                        | 0.004 | 0.084 | 15.612 | 0.014 | 0.044 | 0.056 | 0.064 |
| 4592  | 0   | 0     | 4592 | 0    | 0   | POST   | /login                   | 0.004 | 0.036 | 11.956 | 0.003 | 0.004 | 0.008 | 0.012 |
| 1132  | 0   | 0     | 1132 | 0    | 0   | POST   | /register                | 0.004 | 0.068 | 9.332  | 0.008 | 0.012 | 0.012 | 0.020 |
| 1032  | 0   | 0     | 1032 | 0    | 0   | POST   | /comment                 | 0.004 | 0.044 | 8.444  | 0.008 | 0.012 | 0.012 | 0.028 |
| 1132  | 0   | 0     | 0    | 1132 | 0   | GET    | /admin/banned            | 0.004 | 0.016 | 2.892  | 0.003 | 0.004 | 0.008 | 0.012 |
| 876   | 0   | 876   | 0    | 0    | 0   | GET    | /login                   | 0.004 | 0.012 | 1.576  | 0.002 | 0.004 | 0.004 | 0.008 |
| 438   | 0   | 0     | 438  | 0    | 0   | GET    | /logout                  | 0.000 | 0.012 | 0.716  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1     | 0   | 1     | 0    | 0    | 0   | GET    | /initialize              | 0.096 | 0.096 | 0.096  | 0.096 | 0.096 | 0.096 | 0.096 |
| 6489  | 0   | 6489  | 0    | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 6489  | 0   | 6489  | 0    | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 6489  | 0   | 6489  | 0    | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 6489  | 0   | 6489  | 0    | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+-----+-------+------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 193362  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=4.0 (775413), isuconp[isuconp]@localhost
  #

Count: 7660  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=11.7 (89472), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1132  Time=0.01s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1032  Time=0.01s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 557  Time=0.01s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 7660  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=4.1 (31654), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 7669  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=19.6 (150566), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6342  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=20.0 (126840), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 5741  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=8.7 (49869), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

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

Count: 5741  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (5113), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N) GROUP BY `post_id`

Count: 7563  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7563), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1313  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=58.0 (76119), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5741  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5741), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 4592  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (4154), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1310  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (26200), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N WHERE `posts`.`created_at` <= 'S' ORDER BY `created_at` DESC LIMIT N

Count: 7153  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1437  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (14682), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 168  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.9 (5864), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 182  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.3 (5876), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 167  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.4 (4910), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1437  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1437), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.4 (4174), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 109  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.1 (4149), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1437  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1437), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 156  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.1 (3610), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1437  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (14682), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.4 (2775), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.5 (2757), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 755  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.3 (5499), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 808  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.1 (6542), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 671  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.2 (6182), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 728  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.5 (6158), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.6 (2284), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.3 (1864), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.3 (4209), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1132  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 91  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (1614), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 720  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (1437), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 480  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (4919), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 540  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.5 (2956), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 182  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.8 (1964), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 168  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.7 (1966), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 334  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.3 (3773), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.5 (5724), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 181  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.5 (5874), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 168  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (168), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 167  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1645), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 182  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (182), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 357  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (1685), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 167  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (167), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 153  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.3 (5400), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 280  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.8 (3582), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 200  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.3 (2451), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.4 (3920), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.8 (1396), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 156  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.8 (1214), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.4 (890), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (158), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.5 (4192), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 109  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.7 (1389), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 156  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (156), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (136), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.9 (932), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 109  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (109), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 140  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.9 (2920), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (3097), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.1 (2631), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.4 (2183), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 138  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.3 (2394), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.4 (1047), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 213  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.5 (969), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 44  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=44.0 (1937), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=54.8 (1480), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.6 (922), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (68), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (372), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 91  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (91), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 91  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (538), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) GROUP BY `post_id`

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=56.7 (567), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.7 (769), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (49), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.4 (345), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 100  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.0 (1402), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.5 (625), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 125  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.2 (405), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 22  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.3 (534), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (43), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.6 (892), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 44  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (654), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.7 (300), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.5 (210), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (124), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N) GROUP BY `post_id`

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.6 (147), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (31), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (18), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (108), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 29  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.5 (479), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.9 (117), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N) GROUP BY `post_id`

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.9 (189), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (24), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.5 (300), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=45.9 (321), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.4 (247), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.6 (245), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.6 (302), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.3 (218), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.0 (147), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.8 (209), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.8 (228), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (36), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N) GROUP BY `post_id`

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.3 (177), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.5 (70), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.0 (156), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (18), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.8 (167), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.2 (173), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.7 (167), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.0 (160), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=45.0 (135), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (6), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N) GROUP BY `post_id`

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=56.0 (56), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.0 (29), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 94618  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

Count: 94618  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 4126  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

Go の処理時間の40%ちょっとを GetIndex の template でつかってる

image

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#11 cache-control: 221409

恒例行事
CPU はほぼ使い切ってて、 Go と MySQL でトントンか Go がちょい多いかもくらい

{"pass":true,"score":221409,"success":209136,"fail":0,"messages":[]}
access.log

+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX | 2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 8589   | 0   | 8589 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 104.899 | 0.012 | 0.020 | 0.020 | 0.028 |
| 6289   | 0   | 6289 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.004 | 0.048 | 57.565  | 0.009 | 0.016 | 0.016 | 0.024 |
| 2140   | 0   | 2140 | 0      | 0    | 0   | GET    | /posts                   | 0.004 | 0.056 | 37.295  | 0.017 | 0.024 | 0.028 | 0.032 |
| 1388   | 0   | 1388 | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.068 | 26.928  | 0.019 | 0.028 | 0.032 | 0.040 |
| 5820   | 0   | 0    | 5820   | 0    | 0   | POST   | /login                   | 0.000 | 0.024 | 19.372  | 0.003 | 0.008 | 0.008 | 0.012 |
| 1106   | 0   | 0    | 553    | 553  | 0   | POST   | /                        | 0.000 | 0.108 | 17.247  | 0.016 | 0.044 | 0.056 | 0.068 |
| 1115   | 0   | 0    | 1115   | 0    | 0   | POST   | /register                | 0.004 | 0.060 | 10.416  | 0.009 | 0.012 | 0.016 | 0.020 |
| 914    | 0   | 0    | 914    | 0    | 0   | POST   | /comment                 | 0.004 | 0.048 | 8.868   | 0.010 | 0.016 | 0.016 | 0.024 |
| 1115   | 0   | 0    | 0      | 1115 | 0   | GET    | /admin/banned            | 0.000 | 0.020 | 3.664   | 0.003 | 0.008 | 0.008 | 0.012 |
| 1790   | 0   | 1790 | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.012 | 3.420   | 0.002 | 0.004 | 0.004 | 0.008 |
| 139777 | 0   | 4536 | 135241 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.018 | 2.846   | 0.000 | 0.000 | 0.000 | 0.000 |
| 895    | 0   | 0    | 895    | 0    | 0   | GET    | /logout                  | 0.004 | 0.012 | 1.512   | 0.002 | 0.004 | 0.004 | 0.008 |
| 1      | 0   | 1    | 0      | 0    | 0   | GET    | /initialize              | 0.076 | 0.076 | 0.076   | 0.076 | 0.076 | 0.076 | 0.076 |
| 9635   | 0   | 1    | 9634   | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 9635   | 0   | 1    | 9634   | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 9635   | 0   | 1    | 9634   | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 9635   | 0   | 1    | 9634   | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 10733  Time=0.00s (11s)  Lock=0.00s (0s)  Rows=13.1 (140767), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 230191  Time=0.00s (10s)  Lock=0.00s (0s)  Rows=4.5 (1025058), isuconp[isuconp]@localhost
  #

Count: 1115  Time=0.01s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 914  Time=0.01s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 10733  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=4.6 (49076), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 553  Time=0.01s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 10750  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=19.7 (211534), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8589  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=20.0 (171780), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 6289  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=8.8 (55255), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2146  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=58.3 (125127), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10661  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (10661), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 8948  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (8948), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 6289  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (5647), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N) GROUP BY `post_id`

Count: 2140  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (42800), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N WHERE `posts`.`created_at` <= 'S' ORDER BY `created_at` DESC LIMIT N

Count: 5820  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.8 (4925), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 6289  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6289), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `id` = N

Count: 10890  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1388  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.1 (14076), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 197  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.2 (5749), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.8 (5633), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.2 (5467), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.0 (4483), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1388  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1388), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1388  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1388), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 1388  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.1 (14076), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 160  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.4 (3261), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 125  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.3 (3290), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (3206), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 866  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (6852), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.1 (3124), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 801  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.8 (7069), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 737  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.5 (7026), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 766  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.7 (5866), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 699  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.6 (4630), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 731  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (1459), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 625  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.4 (3402), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 1115  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.1 (1507), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 525  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (5383), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=47.1 (1789), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (1300), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 190  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.6 (5625), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 178  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.4 (5770), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 357  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.2 (3983), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 306  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.3 (4068), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 119  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.3 (4556), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (170), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 429  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (2207), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 197  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.8 (1929), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.8 (1831), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.7 (1891), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 197  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (197), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (162), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 130  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.3 (4587), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 153  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (3618), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 141  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.6 (3751), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 160  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.7 (3308), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.4 (2179), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.0 (3242), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 160  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.8 (1096), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.7 (1502), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (118), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 177  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.7 (2241), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 125  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.8 (1100), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 160  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (160), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 125  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (125), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (1074), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (2723), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (136), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (565), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 241  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.4 (1051), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.8 (1045), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (76), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=51.4 (514), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 28  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.8 (330), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=44.1 (1542), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (73), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=54.9 (934), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 99  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.6 (1542), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (599), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=48.8 (390), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (434), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) GROUP BY `post_id`

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (35), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (38), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.5 (506), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.6 (892), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 130  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.3 (435), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.4 (681), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=54.8 (219), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (189), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N) GROUP BY `post_id`

Count: 44  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.2 (757), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.7 (415), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 45  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.9 (129), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (38), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 28  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (111), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N) GROUP BY `post_id`

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.3 (173), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 28  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (28), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.4 (467), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.5 (186), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.4 (426), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=42.7 (299), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.6 (242), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.2 (130), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.7 (257), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.9 (229), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.0 (150), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.9 (175), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.2 (73), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) GROUP BY `post_id`

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (18), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.7 (172), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (27), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.8 (199), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.2 (186), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=51.5 (103), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.7 (125), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (9), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N, N) GROUP BY `post_id`

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (6), isuconp[isuconp]@localhost
  SELECT `post_id`, count(N) AS `count` FROM `comments` WHERE `post_id` IN (N, N) GROUP BY `post_id`

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.0 (52), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=53.0 (53), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.0 (41), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.0 (32), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6329  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 111931  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

Count: 111931  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

@izumin5210
Copy link
Member Author

#13 コメント件数を posts table にキャッシュ: 231517

スコアは微増だが、負荷は Go にちょっと寄った

{"pass":true,"score":231517,"success":218566,"fail":0,"messages":[]}
access.log

+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX | 2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 9019   | 0   | 9019 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 89.478 | 0.010 | 0.016 | 0.020 | 0.024 |
| 6862   | 0   | 6862 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.032 | 50.857 | 0.007 | 0.012 | 0.016 | 0.020 |
| 2250   | 0   | 2250 | 0      | 0    | 0   | GET    | /posts                   | 0.004 | 0.036 | 32.903 | 0.015 | 0.020 | 0.024 | 0.028 |
| 1513   | 0   | 1513 | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.064 | 24.804 | 0.016 | 0.024 | 0.028 | 0.036 |
| 6087   | 0   | 0    | 6087   | 0    | 0   | POST   | /login                   | 0.000 | 0.024 | 20.920 | 0.003 | 0.008 | 0.008 | 0.012 |
| 1164   | 0   | 0    | 582    | 582  | 0   | POST   | /                        | 0.012 | 0.076 | 18.331 | 0.016 | 0.044 | 0.052 | 0.064 |
| 1001   | 0   | 0    | 1001   | 0    | 0   | POST   | /comment                 | 0.004 | 0.068 | 11.408 | 0.011 | 0.016 | 0.020 | 0.024 |
| 1207   | 0   | 0    | 1207   | 0    | 0   | POST   | /register                | 0.004 | 0.080 | 11.124 | 0.009 | 0.012 | 0.016 | 0.020 |
| 1207   | 0   | 0    | 0      | 1207 | 0   | GET    | /admin/banned            | 0.008 | 0.024 | 4.108  | 0.003 | 0.008 | 0.008 | 0.012 |
| 1810   | 0   | 1810 | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.016 | 4.011  | 0.002 | 0.004 | 0.008 | 0.008 |
| 144940 | 0   | 4846 | 140094 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.017 | 2.836  | 0.000 | 0.000 | 0.000 | 0.000 |
| 905    | 0   | 0    | 905    | 0    | 0   | GET    | /logout                  | 0.000 | 0.012 | 1.872  | 0.002 | 0.004 | 0.008 | 0.008 |
| 1      | 0   | 1    | 0      | 0    | 0   | GET    | /initialize              | 0.056 | 0.056 | 0.056  | 0.056 | 0.056 | 0.056 | 0.056 |
| 10231  | 0   | 1    | 10230  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 10231  | 0   | 1    | 10230  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 10231  | 0   | 1    | 10230  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 10231  | 0   | 1    | 10230  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 11282  Time=0.00s (9s)  Lock=0.00s (0s)  Rows=13.0 (146999), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 205617  Time=0.00s (8s)  Lock=0.00s (0s)  Rows=4.9 (1015179), isuconp[isuconp]@localhost
  #

Count: 1207  Time=0.01s (6s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1001  Time=0.01s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 582  Time=0.01s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 11289  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=19.7 (222413), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9019  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=20.0 (180380), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at`, `comment_count` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 6862  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=8.8 (60527), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 11440  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (11440), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 2263  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=58.3 (132042), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2250  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (45000), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at`, `comment_count` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N WHERE `posts`.`created_at` <= 'S' ORDER BY `created_at` DESC LIMIT N

Count: 8739  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8739), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 6087  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (5182), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 6862  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6862), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 10345  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 230  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.3 (7431), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1513  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (15666), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 161  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.7 (5580), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 146  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.8 (5522), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1513  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1513), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 153  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.4 (4498), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 154  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.2 (4034), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 92  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.3 (3712), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1513  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (15666), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1513  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1513), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 141  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.3 (3284), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1001  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1001  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 936  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.5 (7957), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.7 (2779), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 863  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.4 (7225), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 781  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.7 (7563), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 844  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.5 (6339), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 775  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.7 (5189), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.5 (2043), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 1207  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 597  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (5978), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=47.0 (1928), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 654  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.8 (3761), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 90  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.5 (1579), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 230  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.5 (7471), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 435  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.2 (4870), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 230  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (230), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 343  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.0 (4469), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 454  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (2271), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 179  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.6 (5291), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 161  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (161), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 152  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.6 (4044), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 146  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (146), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 138  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.4 (4885), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 138  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.4 (5298), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 153  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (153), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 148  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.6 (3493), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 141  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (141), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 92  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (92), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 215  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.0 (2802), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 154  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (154), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.9 (2368), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 167  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (3347), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.2 (935), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 163  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.0 (2769), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1001  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 255  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.4 (1117), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 52  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.4 (2413), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 39  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.3 (558), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (134), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=41.1 (3245), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 250  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (497), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.2 (470), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (322), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 90  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (90), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 103  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.0 (1437), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 29  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.4 (1432), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=52.4 (944), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=55.1 (937), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (41), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (47), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 126  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.3 (420), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 39  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (39), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 65  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.6 (170), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (19), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (108), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (27), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (660), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=57.0 (114), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.4 (391), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.3 (533), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.1 (274), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.6 (428), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.4 (482), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.3 (327), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=43.0 (129), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.4 (187), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=45.8 (229), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.5 (165), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.7 (180), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.6 (197), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (18), isuconp[isuconp]@localhost
  SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY `post_id` ORDER BY `created_at` DESC) AS `rank` FROM `comments` WHERE `post_id` IN (N, N)) AS `comments` WHERE `rank` <= N ORDER BY `rank` DESC

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (154), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.5 (126), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=46.5 (93), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (92), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=49.0 (49), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=44.0 (44), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.0 (39), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.0 (28), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 99577  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 6463  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

Count: 99577  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

@izumin5210
Copy link
Member Author

#14 コメントごとに現在最新n件目なのかを事前計算: 243319

スコア微増だが、構造をシンプルにすることを優先。

{"pass":true,"score":243319,"success":229627,"fail":0,"messages":[]}
access.log

+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX | 2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 9495   | 0   | 9495 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 84.970 | 0.009 | 0.016 | 0.016 | 0.020 |
| 7321   | 0   | 7321 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.060 | 48.115 | 0.007 | 0.012 | 0.012 | 0.020 |
| 2460   | 0   | 2460 | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.060 | 25.320 | 0.010 | 0.016 | 0.020 | 0.024 |
| 1645   | 0   | 1645 | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.044 | 20.672 | 0.013 | 0.020 | 0.020 | 0.028 |
| 6420   | 0   | 0    | 6420   | 0    | 0   | POST   | /login                   | 0.000 | 0.028 | 19.516 | 0.003 | 0.008 | 0.008 | 0.012 |
| 1214   | 0   | 0    | 607    | 607  | 0   | POST   | /                        | 0.004 | 0.152 | 18.692 | 0.015 | 0.044 | 0.056 | 0.064 |
| 1102   | 0   | 0    | 1102   | 0    | 0   | POST   | /comment                 | 0.004 | 0.096 | 12.988 | 0.012 | 0.016 | 0.020 | 0.024 |
| 1314   | 0   | 0    | 1314   | 0    | 0   | POST   | /register                | 0.004 | 0.100 | 11.031 | 0.008 | 0.012 | 0.012 | 0.020 |
| 1860   | 0   | 1860 | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.020 | 3.860  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1314   | 0   | 0    | 0      | 1314 | 0   | GET    | /admin/banned            | 0.000 | 0.016 | 3.808  | 0.003 | 0.008 | 0.008 | 0.012 |
| 152051 | 0   | 5029 | 147022 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.021 | 3.068  | 0.000 | 0.000 | 0.000 | 0.000 |
| 930    | 0   | 0    | 930    | 0    | 0   | GET    | /logout                  | 0.000 | 0.012 | 1.748  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1      | 0   | 1    | 0      | 0    | 0   | GET    | /initialize              | 0.096 | 0.096 | 0.096  | 0.096 | 0.096 | 0.096 | 0.096 |
| 10706  | 0   | 1    | 10705  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 10706  | 0   | 1    | 10705  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 10706  | 0   | 1    | 10705  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 10706  | 0   | 1    | 10705  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 222360  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=3.9 (869331), isuconp[isuconp]@localhost
  #

Count: 1314  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1102  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 11965  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=5.4 (64699), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 607  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 12340  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=19.8 (243828), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9495  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=20.0 (189900), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at`, `comment_count` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 7321  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=8.9 (65485), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 12315  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (12315), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 9842  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9842), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2460  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (49200), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at`, `comment_count` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N WHERE `posts`.`created_at` <= 'S' ORDER BY `created_at` DESC LIMIT N

Count: 7321  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7321), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 6420  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (5490), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 10148  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1645  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (16857), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 1645  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1645), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1645  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (16857), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1645  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1645), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 1100  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.4 (9205), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 1102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1050  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.7 (9114), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 941  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.6 (9045), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 994  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.4 (7351), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.8 (7214), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 809  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.5 (5271), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1314  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 239  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.7 (4958), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 767  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.8 (4428), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 201  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.6 (4551), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 536  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.6 (6239), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 195  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.6 (3239), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.6 (3616), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 239  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (239), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 346  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.5 (7440), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 402  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.5 (5815), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 404  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.6 (5505), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 518  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (2664), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 201  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (201), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 309  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.6 (6373), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 282  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.7 (6690), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 244  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.8 (6303), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (194), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 169  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.8 (2500), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 257  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.6 (4791), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.3 (2818), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 195  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (195), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 237  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.9 (5892), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 226  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.8 (5160), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 263  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.5 (4064), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 154  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.6 (1934), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 242  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.1 (4149), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 94  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.3 (2470), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 169  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (169), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.04s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 170  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.8 (4552), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 159  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.8 (4420), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (116), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 154  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.8 (4436), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 94  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (94), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 154  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (154), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 278  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.4 (1224), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 121  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.9 (3620), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 110  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.8 (3386), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.0 (969), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 234  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (464), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.2 (1147), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.8 (1027), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (88), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.5 (493), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (37), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.5 (725), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 56  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.6 (1772), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (38), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 56  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.7 (1831), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (23), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.6 (354), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.7 (1079), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (41), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.6 (370), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 65  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.9 (186), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.6 (158), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.4 (654), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (11), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (24), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.2 (387), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.7 (104), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.7 (220), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.0 (111), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (12), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=39.0 (78), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 108090  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Prepare

Count: 108090  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Close stmt

Count: 6180  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 12, 2023

#15 interpolateParams=true: 257888

いつもの。まだ早かったか…(?)

CPU usage は Go : DB = 3 : 1 くらいなので、真面目に Go の方を見たほうがいい。

{"pass":true,"score":257888,"success":242726,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 10312  | 0   | 10312 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.040 | 75.472 | 0.007 | 0.012 | 0.012 | 0.016 |
| 8081   | 0   | 8081  | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.036 | 40.255 | 0.005 | 0.008 | 0.012 | 0.016 |
| 2580   | 0   | 2580  | 0      | 0    | 0   | GET    | /posts                   | 0.004 | 0.028 | 21.528 | 0.008 | 0.012 | 0.016 | 0.020 |
| 1340   | 0   | 0     | 670    | 670  | 0   | POST   | /                        | 0.004 | 0.080 | 18.664 | 0.014 | 0.036 | 0.056 | 0.064 |
| 1894   | 0   | 1894  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.032 | 17.864 | 0.009 | 0.016 | 0.016 | 0.020 |
| 7026   | 0   | 0     | 7026   | 0    | 0   | POST   | /login                   | 0.000 | 0.020 | 17.323 | 0.002 | 0.004 | 0.008 | 0.012 |
| 1303   | 0   | 0     | 1303   | 0    | 0   | POST   | /comment                 | 0.004 | 0.076 | 13.588 | 0.010 | 0.016 | 0.016 | 0.024 |
| 1473   | 0   | 0     | 1473   | 0    | 0   | POST   | /register                | 0.004 | 0.080 | 11.552 | 0.008 | 0.012 | 0.012 | 0.016 |
| 1940   | 0   | 1940  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.016 | 3.936  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1473   | 0   | 0     | 0      | 1473 | 0   | GET    | /admin/banned            | 0.004 | 0.020 | 3.820  | 0.003 | 0.004 | 0.008 | 0.012 |
| 158946 | 0   | 5434  | 153512 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.019 | 3.086  | 0.000 | 0.000 | 0.000 | 0.000 |
| 970    | 0   | 0     | 970    | 0    | 0   | GET    | /logout                  | 0.000 | 0.012 | 1.812  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.088 | 0.088 | 0.088  | 0.088 | 0.088 | 0.088 | 0.088 |
| 11422  | 0   | 1     | 11421  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 11422  | 0   | 1     | 11421  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 11422  | 0   | 1     | 11421  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 11422  | 0   | 1     | 11421  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 1473  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1303  Time=0.01s (6s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 12901  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=4.5 (57853), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 670  Time=0.01s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 13278  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=19.8 (262269), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10312  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=20.0 (206240), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at`, `comment_count` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N ORDER BY `created_at` DESC LIMIT N

Count: 8081  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=8.7 (70681), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 13951  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (13951), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 11094  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (11094), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 8081  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8081), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2580  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (51600), isuconp[isuconp]@localhost
  SELECT `posts`.`id`, `user_id`, `body`, `mime`, `posts`.`created_at`, `comment_count` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N WHERE `posts`.`created_at` <= 'S' ORDER BY `created_at` DESC LIMIT N

Count: 7026  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (6056), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1303  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 1894  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (19396), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 9304  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1894  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1894), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1894  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1894), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 1894  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.2 (19397), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1303  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1303  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1139  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.5 (9631), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 1131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.3 (9363), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 1057  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.7 (10285), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1030  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.3 (7563), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 990  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.6 (6547), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1473  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 782  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.5 (8245), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 846  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.6 (4777), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 283  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.4 (5770), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 661  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (7960), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 558  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.1 (7323), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 494  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.0 (7405), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 213  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.1 (4698), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 403  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.7 (8731), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 681  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (1360), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 436  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.3 (7087), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 283  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (283), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 574  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (2946), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 410  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (6941), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 210  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.3 (3851), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 209  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.4 (3430), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 353  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.7 (7307), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 347  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (6507), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 156  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.1 (3764), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 213  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (213), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 191  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.4 (2747), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 293  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.7 (6664), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 188  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.6 (2365), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 210  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (210), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 210  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (210), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 213  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.8 (5064), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 156  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (156), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 190  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (190), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.3 (2499), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 188  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (188), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 311  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.3 (1345), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 183  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.7 (4525), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 171  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.9 (4429), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1303  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 1  Time=0.04s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 72  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.0 (2014), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (95), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 99  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (1028), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 191  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.6 (683), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.9 (555), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 72  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (72), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 99  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (99), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=27.9 (2456), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8996  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=26.9 (2125), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.5 (944), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 61  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=28.9 (1761), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 52  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.7 (452), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.1 (761), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (31), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 42  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=29.5 (1239), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 52  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (52), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.6 (569), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=31.7 (1173), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (23), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.3 (196), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (18), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 22  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=30.2 (665), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (27), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=33.9 (441), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.5 (71), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=32.8 (361), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=34.0 (102), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.0 (175), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=37.2 (149), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=40.0 (80), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=38.5 (77), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=35.0 (70), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=36.0 (36), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.5 (5), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N, N) AND `freshness` < N ORDER BY `created_at` DESC

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 8996  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

案の定というか、template の実行で時間を使っている

Go

Screenshot 2023-11-13 at 0 15 52

@izumin5210
Copy link
Member Author

#16 post.html の事前計算: 293496

CPU を75%程度しか使えてない

{"pass":true,"score":293496,"success":275927,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 12162  | 0   | 12162 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.036 | 40.504 | 0.003 | 0.004 | 0.008 | 0.008 |
| 1458   | 0   | 0     | 1458   | 0    | 0   | POST   | /comment                 | 0.008 | 0.104 | 26.272 | 0.018 | 0.024 | 0.024 | 0.040 |
| 1472   | 0   | 0     | 736    | 736  | 0   | POST   | /                        | 0.020 | 0.108 | 23.756 | 0.016 | 0.044 | 0.060 | 0.068 |
| 9663   | 0   | 9663  | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.020 | 18.024 | 0.002 | 0.004 | 0.004 | 0.008 |
| 2013   | 0   | 0     | 2013   | 0    | 0   | POST   | /register                | 0.004 | 0.068 | 14.376 | 0.007 | 0.012 | 0.012 | 0.016 |
| 8210   | 0   | 0     | 8210   | 0    | 0   | POST   | /login                   | 0.000 | 0.016 | 12.012 | 0.001 | 0.004 | 0.004 | 0.008 |
| 2176   | 0   | 2176  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.024 | 10.800 | 0.005 | 0.008 | 0.008 | 0.012 |
| 2880   | 0   | 2880  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.028 | 9.724  | 0.003 | 0.004 | 0.008 | 0.008 |
| 177394 | 0   | 6125  | 171269 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.016 | 3.207  | 0.000 | 0.000 | 0.000 | 0.000 |
| 2178   | 0   | 2178  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.024 | 3.164  | 0.001 | 0.004 | 0.004 | 0.008 |
| 2013   | 0   | 0     | 0      | 2013 | 0   | GET    | /admin/banned            | 0.000 | 0.020 | 2.676  | 0.001 | 0.004 | 0.004 | 0.008 |
| 1089   | 0   | 0     | 1089   | 0    | 0   | GET    | /logout                  | 0.000 | 0.008 | 1.184  | 0.001 | 0.004 | 0.004 | 0.004 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.100 | 0.100 | 0.100  | 0.100 | 0.100 | 0.100 | 0.100 |
| 13393  | 0   | 1     | 13392  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 13393  | 0   | 1     | 13392  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 13393  | 0   | 1     | 13392  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 13393  | 0   | 1     | 13392  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 2194  Time=0.01s (13s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 2013  Time=0.01s (10s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 1458  Time=0.01s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 12162  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (243240), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 736  Time=0.01s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 16640  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (16640), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 9663  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (9663), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 2880  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=20.0 (57600), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 8210  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.9 (7121), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2176  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (22541), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 1458  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.9 (12875), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2176  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2176), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2176  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2176), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2176  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (22541), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 2194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2194), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2480  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2480), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 6483  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1458  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1458  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 2013  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 293  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (293), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 288  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (288), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 226  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (226), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 206  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (206), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 229  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (229), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 201  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (201), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 196  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (196), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (131), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1458  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 127  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (127), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 138  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1645), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 141  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1537), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (68), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 113  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1455), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (51), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 105  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1039), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1221), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 96  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (857), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 36  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (36), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6271  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 66  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (983), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 91  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (182), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 59  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (932), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (54), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (541), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (587), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 45  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (315), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (35), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (410), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (104), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (150), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (282), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (60), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (40), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (100), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (21), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (22), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6271  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 16, 2023

innodb_flush_log_at_trx_commit = 1 & disable-log-bin = 1: 313114

CPU は85%くらい

{"pass":true,"score":313114,"success":292013,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 14222  | 0   | 14222 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.032 | 47.859 | 0.003 | 0.004 | 0.008 | 0.008 |
| 10671  | 0   | 10671 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.004 | 0.032 | 20.344 | 0.002 | 0.004 | 0.004 | 0.008 |
| 1690   | 0   | 0     | 845    | 845  | 0   | POST   | /                        | 0.004 | 0.076 | 19.195 | 0.011 | 0.044 | 0.052 | 0.060 |
| 2884   | 0   | 2884  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.024 | 13.808 | 0.005 | 0.008 | 0.008 | 0.012 |
| 9706   | 0   | 0     | 9706   | 0    | 0   | POST   | /login                   | 0.000 | 0.020 | 13.703 | 0.001 | 0.004 | 0.004 | 0.008 |
| 2142   | 0   | 0     | 2142   | 0    | 0   | POST   | /comment                 | 0.008 | 0.028 | 11.875 | 0.006 | 0.008 | 0.012 | 0.015 |
| 3000   | 0   | 3000  | 0      | 0    | 0   | GET    | /posts                   | 0.004 | 0.016 | 10.664 | 0.004 | 0.008 | 0.008 | 0.012 |
| 2493   | 0   | 0     | 2493   | 0    | 0   | POST   | /register                | 0.000 | 0.032 | 4.220  | 0.002 | 0.004 | 0.004 | 0.008 |
| 184293 | 0   | 6522  | 177771 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.020 | 3.816  | 0.000 | 0.000 | 0.000 | 0.000 |
| 2493   | 0   | 0     | 0      | 2493 | 0   | GET    | /admin/banned            | 0.000 | 0.024 | 3.504  | 0.001 | 0.004 | 0.004 | 0.008 |
| 2254   | 0   | 2254  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.012 | 3.428  | 0.002 | 0.004 | 0.004 | 0.008 |
| 1127   | 0   | 0     | 1127   | 0    | 0   | GET    | /logout                  | 0.000 | 0.008 | 1.500  | 0.001 | 0.004 | 0.004 | 0.008 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.132 | 0.132 | 0.132  | 0.132 | 0.132 | 0.132 | 0.132 |
| 13830  | 0   | 1     | 13829  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 13830  | 0   | 1     | 13829  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 13830  | 0   | 1     | 13829  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 13830  | 0   | 1     | 13829  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 14222  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=20.0 (284440), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

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

Count: 10671  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (10671), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 3000  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=20.0 (60000), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 9706  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.9 (8579), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2884  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=10.4 (30074), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 2987  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 2142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2987  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.2 (18434), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2884  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2884), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2884  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2884), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2884  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (30074), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 3398  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3398), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2987  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2987), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2493  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 2493  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 2142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 2142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 4947  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 405  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (405), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 845  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 352  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (352), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1  Time=0.08s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 292  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (292), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 228  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (228), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 293  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (293), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 293  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (293), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 269  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (269), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 2142  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 166  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (166), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 99  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (99), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 92  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (92), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 146  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (146), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 175  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1906), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 169  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (2011), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 152  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1963), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 189  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (378), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 140  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1390), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 127  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1768), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 107  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (1593), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 122  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (1090), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (79), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 40  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (40), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 75  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (1190), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 77  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (612), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 28  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (28), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 85  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (255), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 4660  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 50  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (841), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (54), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (399), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (603), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (276), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.7 (505), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (136), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.8 (297), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (125), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.9 (230), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (132), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (92), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (48), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.0 (50), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4660  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

app と bench が別 AZ で動いてたのを修正: 559844

キレそう(自業自得)
image

{"pass":true,"score":559844,"success":545359,"fail":0,"messages":[]}

CPU を全部使い切るようになった
80%くらいを Go が使っている

access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 16157  | 0   | 16157 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 154.308 | 0.010 | 0.016 | 0.020 | 0.028 |
| 11704  | 0   | 11704 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.040 | 87.415  | 0.007 | 0.016 | 0.016 | 0.024 |
| 7080   | 0   | 7080  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.052 | 64.879  | 0.009 | 0.016 | 0.020 | 0.024 |
| 7832   | 0   | 0     | 7832   | 0    | 0   | POST   | /login                   | 0.000 | 0.052 | 56.826  | 0.007 | 0.016 | 0.016 | 0.024 |
| 1172   | 0   | 0     | 586    | 586  | 0   | POST   | /                        | 0.000 | 0.136 | 28.828  | 0.025 | 0.052 | 0.068 | 0.088 |
| 1810   | 0   | 1810  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.048 | 25.871  | 0.014 | 0.024 | 0.028 | 0.036 |
| 808    | 0   | 0     | 808    | 0    | 0   | POST   | /comment                 | 0.008 | 0.132 | 22.752  | 0.028 | 0.040 | 0.044 | 0.068 |
| 3130   | 0   | 3130  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.032 | 17.116  | 0.005 | 0.012 | 0.012 | 0.016 |
| 1157   | 0   | 0     | 1157   | 0    | 0   | POST   | /register                | 0.004 | 0.056 | 13.848  | 0.012 | 0.020 | 0.024 | 0.032 |
| 1565   | 0   | 0     | 1565   | 0    | 0   | GET    | /logout                  | 0.004 | 0.028 | 8.340   | 0.005 | 0.012 | 0.012 | 0.016 |
| 1157   | 0   | 0     | 0      | 1157 | 0   | GET    | /admin/banned            | 0.004 | 0.032 | 8.064   | 0.007 | 0.012 | 0.016 | 0.024 |
| 400066 | 0   | 7128  | 392938 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.010 | 0.376   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.068 | 0.068 | 0.068   | 0.068 | 0.068 | 0.068 | 0.068 |
| 23175  | 0   | 1     | 23174  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 23175  | 0   | 1     | 23174  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 23175  | 0   | 1     | 23174  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 23175  | 0   | 1     | 23174  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 16157  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=20.0 (323140), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1394  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1157  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 7080  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (141600), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 808  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 11704  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (11704), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 586  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 11198  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (11198), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 7832  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (6267), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 16135  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1810  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (18701), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 1810  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1810), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 808  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 1394  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (7086), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 1810  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1810), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 1810  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (18701), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1559  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1559), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1394  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1394), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1157  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 808  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 808  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 238  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (238), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 194  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (194), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 216  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (216), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 186  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (186), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 202  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (202), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 198  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (198), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 174  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (174), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 15612  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 91  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (91), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 808  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (54), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 85  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (85), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 67  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (865), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 39  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (39), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (870), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 65  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (647), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 66  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (719), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (26), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (534), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (365), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.0 (642), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (37), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (506), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (34), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 33  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (522), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 39  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (78), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (189), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (156), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (236), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (4), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (231), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (33), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (40), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.5 (39), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (94), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (16), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (21), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (22), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 15612  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

pprof

image

@izumin5210 izumin5210 pinned this issue Nov 17, 2023
@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

#17 GET /GET /posts(*Template).Execute 後に posts.html 挿入: 639241

CPU は使い切れている
Go : MySQL : Nginx = 2 : 1 : 1 くらい

pprof では (*Template).Execute が支配的ではなくなった

{"pass":true,"score":639241,"success":621804,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 18651  | 0   | 18651 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.040 | 130.504 | 0.007 | 0.012 | 0.016 | 0.020 |
| 13869  | 0   | 13869 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.004 | 0.036 | 79.652  | 0.006 | 0.012 | 0.012 | 0.020 |
| 9437   | 0   | 0     | 9437   | 0    | 0   | POST   | /login                   | 0.000 | 0.032 | 51.640  | 0.005 | 0.012 | 0.012 | 0.016 |
| 8100   | 0   | 8100  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.036 | 50.660  | 0.006 | 0.012 | 0.016 | 0.020 |
| 1380   | 0   | 0     | 690    | 690  | 0   | POST   | /                        | 0.004 | 0.144 | 29.780  | 0.022 | 0.048 | 0.056 | 0.080 |
| 2162   | 0   | 2162  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.048 | 26.312  | 0.012 | 0.020 | 0.024 | 0.032 |
| 997    | 0   | 0     | 997    | 0    | 0   | POST   | /comment                 | 0.008 | 0.084 | 23.052  | 0.023 | 0.032 | 0.036 | 0.060 |
| 3718   | 0   | 3718  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.024 | 15.888  | 0.004 | 0.008 | 0.008 | 0.012 |
| 1483   | 0   | 0     | 1483   | 0    | 0   | POST   | /register                | 0.004 | 0.064 | 14.312  | 0.010 | 0.016 | 0.020 | 0.028 |
| 1483   | 0   | 0     | 0      | 1483 | 0   | GET    | /admin/banned            | 0.004 | 0.024 | 7.840   | 0.005 | 0.012 | 0.012 | 0.020 |
| 1859   | 0   | 0     | 1859   | 0    | 0   | GET    | /logout                  | 0.000 | 0.028 | 7.500   | 0.004 | 0.008 | 0.008 | 0.012 |
| 453214 | 0   | 7931  | 445283 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.009 | 0.462   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.020 | 0.020 | 0.020   | 0.020 | 0.020 | 0.020 | 0.020 |
| 26655  | 0   | 1     | 26654  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 26655  | 0   | 1     | 26654  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 26655  | 0   | 1     | 26654  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 26655  | 0   | 1     | 26654  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 18651  Time=0.00s (8s)  Lock=0.00s (0s)  Rows=20.0 (373020), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1687  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1483  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 8100  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (162000), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 997  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 13869  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (13869), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 690  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 13746  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (13746), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 9437  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (7578), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 18675  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (22555), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 2162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2162), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 997  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 1687  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (8394), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2162), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2162  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (22555), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1920  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1920), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1687  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1687), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1483  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 997  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 997  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 330  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (330), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 277  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (277), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 254  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (254), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 223  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (223), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 177  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (177), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 195  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (195), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 139  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (139), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 181  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (181), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 17566  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (79), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 997  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 119  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (119), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (47), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 85  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (927), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 78  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (776), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (970), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (37), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 65  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (901), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 69  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (615), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 61  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (789), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (25), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 52  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (776), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 50  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (399), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (602), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (37), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 42  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (293), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 56  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (112), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (13), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (144), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.0 (272), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (178), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (55), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (27), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.5 (111), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (80), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (16), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (23), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (21), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17566  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

pprof

image

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

#18 template.Template を起動時に1度だけ読み込む: 645716

スコアはあんまり変わらない
template.Parse で時間使わなくなったのでちょっと健全

{"pass":true,"score":645716,"success":627615,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 19124  | 0   | 19124 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.044 | 119.282 | 0.006 | 0.012 | 0.012 | 0.020 |
| 14276  | 0   | 14276 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.052 | 73.979  | 0.005 | 0.012 | 0.012 | 0.016 |
| 9832   | 0   | 0     | 9832   | 0    | 0   | POST   | /login                   | 0.000 | 0.044 | 48.588  | 0.005 | 0.008 | 0.012 | 0.016 |
| 7960   | 0   | 7960  | 0      | 0    | 0   | GET    | /posts                   | 0.004 | 0.060 | 46.951  | 0.006 | 0.012 | 0.012 | 0.016 |
| 1412   | 0   | 0     | 706    | 706  | 0   | POST   | /                        | 0.000 | 0.160 | 30.971  | 0.022 | 0.048 | 0.064 | 0.084 |
| 2248   | 0   | 2248  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.064 | 26.496  | 0.012 | 0.020 | 0.020 | 0.028 |
| 1027   | 0   | 0     | 1027   | 0    | 0   | POST   | /comment                 | 0.008 | 0.156 | 24.347  | 0.024 | 0.032 | 0.036 | 0.060 |
| 3866   | 0   | 3866  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.028 | 15.084  | 0.004 | 0.008 | 0.008 | 0.012 |
| 1594   | 0   | 0     | 1594   | 0    | 0   | POST   | /register                | 0.004 | 0.096 | 14.915  | 0.009 | 0.016 | 0.016 | 0.032 |
| 1594   | 0   | 0     | 0      | 1594 | 0   | GET    | /admin/banned            | 0.004 | 0.028 | 7.960   | 0.005 | 0.008 | 0.012 | 0.016 |
| 1933   | 0   | 0     | 1933   | 0    | 0   | GET    | /logout                  | 0.000 | 0.028 | 6.844   | 0.004 | 0.008 | 0.008 | 0.012 |
| 454932 | 0   | 8018  | 446914 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.013 | 0.580   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.040 | 0.040 | 0.040   | 0.040 | 0.040 | 0.040 | 0.040 |
| 27261  | 0   | 1     | 27260  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 27261  | 0   | 1     | 27260  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 27261  | 0   | 1     | 27260  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 27261  | 0   | 1     | 27260  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log


Reading mysql slow query log from /var/log/mysql/slow.log
Count: 19124  Time=0.00s (9s)  Lock=0.00s (0s)  Rows=20.0 (382480), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1733  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1594  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 7960  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (159200), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1027  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 706  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 14276  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (14276), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 14353  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=1.0 (14353), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 9832  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (7899), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2248  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (23236), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 19453  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2248  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2248), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1027  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 1733  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (8583), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2248  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2248), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2248  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (23237), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 1733  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1733), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1968  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1968), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1594  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1027  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1027  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 294  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (294), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 298  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (298), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 233  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (233), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 203  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (203), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 242  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (242), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 203  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (203), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 207  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (207), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 143  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (143), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18202  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 141  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (141), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 83  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (83), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1027  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (51), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (1052), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 87  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (952), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (814), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.0 (644), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (982), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (26), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (680), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 56  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.0 (782), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (51), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (453), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (124), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (34), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (492), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 42  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (292), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (150), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (288), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.9 (170), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.9 (197), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (27), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (40), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (80), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (42), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (23), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 18202  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

pprof

image

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

#19 GET /posts/\id+GET /@\w+(*Template).Execute 後に posts.html 挿入: 655682

Go がじわじわ減って MySQL に移ってる

{"pass":true,"score":655682,"success":636627,"fail":0,"messages":[]}
access.logg

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 19504  | 0   | 19504 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 114.124 | 0.006 | 0.012 | 0.012 | 0.016 |
| 15219  | 0   | 15219 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.028 | 69.580  | 0.005 | 0.008 | 0.012 | 0.016 |
| 10321  | 0   | 0     | 10321  | 0    | 0   | POST   | /login                   | 0.000 | 0.028 | 46.748  | 0.005 | 0.008 | 0.012 | 0.016 |
| 7960   | 0   | 7960  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.036 | 43.532  | 0.005 | 0.012 | 0.012 | 0.016 |
| 1490   | 0   | 0     | 745    | 745  | 0   | POST   | /                        | 0.000 | 0.132 | 31.448  | 0.021 | 0.048 | 0.060 | 0.084 |
| 1078   | 0   | 0     | 1078   | 0    | 0   | POST   | /comment                 | 0.008 | 0.116 | 25.304  | 0.023 | 0.032 | 0.036 | 0.056 |
| 2363   | 0   | 2363  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.052 | 24.716  | 0.010 | 0.016 | 0.020 | 0.028 |
| 1696   | 0   | 0     | 1696   | 0    | 0   | POST   | /register                | 0.004 | 0.084 | 15.028  | 0.009 | 0.012 | 0.016 | 0.028 |
| 4038   | 0   | 4038  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.028 | 13.520  | 0.003 | 0.008 | 0.008 | 0.012 |
| 1696   | 0   | 0     | 0      | 1696 | 0   | GET    | /admin/banned            | 0.000 | 0.024 | 7.284   | 0.004 | 0.008 | 0.008 | 0.016 |
| 2019   | 0   | 0     | 2019   | 0    | 0   | GET    | /logout                  | 0.000 | 0.016 | 6.104   | 0.003 | 0.008 | 0.008 | 0.012 |
| 457617 | 0   | 8112  | 449505 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.011 | 0.576   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.032 | 0.032 | 0.032   | 0.032 | 0.032 | 0.032 | 0.032 |
| 28225  | 0   | 1     | 28224  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 28225  | 0   | 1     | 28224  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 28225  | 0   | 1     | 28224  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 28225  | 0   | 1     | 28224  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 19504  Time=0.00s (10s)  Lock=0.00s (0s)  Rows=20.0 (390080), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1823  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1696  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 7960  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (159200), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1078  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 15219  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (15219), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 745  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

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

Count: 10321  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (8302), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2363  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=10.5 (24700), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 20742  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2363  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2363), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1078  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 1823  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (9277), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2363  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.5 (24700), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 2363  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2363), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2047  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2047), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1823  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1823), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1696  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1078  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1078  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 374  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (374), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 244  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (244), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 250  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (250), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 254  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (254), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 251  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (251), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 234  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (234), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 131  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (131), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19443  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 175  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (175), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 72  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (72), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 145  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (145), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1078  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 108  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1180), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (874), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 50  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (50), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 35  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (35), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 67  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (932), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 92  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (1100), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (943), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (707), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (510), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (120), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (43), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (732), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (43), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 36  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (571), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 39  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (273), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (14), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (14), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 22  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (372), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (55), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (180), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.9 (197), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (14), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.9 (151), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (60), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 19443  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

#21 GET / のデータ取得部分を singleflight 化: 675231

一番重かった SELECT クエリの回数が 2/3 程度になった
が、スコアは微増… あんまいい手じゃなかったか

{"pass":true,"score":675231,"success":655485,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 20190  | 0   | 20190 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.052 | 104.530 | 0.005 | 0.008 | 0.012 | 0.016 |
| 16169  | 0   | 16169 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.052 | 64.663  | 0.004 | 0.008 | 0.008 | 0.016 |
| 10704  | 0   | 0     | 10704  | 0    | 0   | POST   | /login                   | 0.004 | 0.036 | 44.204  | 0.004 | 0.008 | 0.012 | 0.016 |
| 8080   | 0   | 8080  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.052 | 40.624  | 0.005 | 0.008 | 0.012 | 0.016 |
| 1512   | 0   | 0     | 756    | 756  | 0   | POST   | /                        | 0.004 | 0.160 | 31.911  | 0.021 | 0.048 | 0.064 | 0.084 |
| 1200   | 0   | 0     | 1200   | 0    | 0   | POST   | /comment                 | 0.004 | 0.156 | 25.827  | 0.022 | 0.028 | 0.032 | 0.052 |
| 2592   | 0   | 2592  | 0      | 0    | 0   | GET    | /@\w+                    | 0.008 | 0.040 | 23.547  | 0.009 | 0.016 | 0.016 | 0.024 |
| 1794   | 0   | 0     | 1794   | 0    | 0   | POST   | /register                | 0.004 | 0.116 | 15.224  | 0.008 | 0.012 | 0.016 | 0.024 |
| 4132   | 0   | 4132  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.044 | 13.780  | 0.003 | 0.008 | 0.008 | 0.012 |
| 1794   | 0   | 0     | 0      | 1794 | 0   | GET    | /admin/banned            | 0.004 | 0.028 | 7.212   | 0.004 | 0.008 | 0.008 | 0.012 |
| 2066   | 0   | 0     | 2066   | 0    | 0   | GET    | /logout                  | 0.004 | 0.016 | 6.455   | 0.003 | 0.008 | 0.008 | 0.012 |
| 468582 | 0   | 8488  | 460094 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.013 | 0.667   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.072 | 0.072 | 0.072   | 0.072 | 0.072 | 0.072 | 0.072 |
| 29495  | 0   | 1     | 29494  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 29495  | 0   | 1     | 29494  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 29495  | 0   | 1     | 29494  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 29495  | 0   | 1     | 29494  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 1956  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1794  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 12888  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=20.0 (257760), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1200  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 8080  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (161600), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 756  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 16169  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (16169), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

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

Count: 10704  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (8638), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2592  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=10.3 (26751), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 17770  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1200  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2592  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2592), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1956  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.1 (10027), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2592  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2592), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2592  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.3 (26751), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 2230  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2230), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 1956  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1956), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1794  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1200  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1200  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 316  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (316), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 296  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (296), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 307  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (307), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 300  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (300), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 239  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (239), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 258  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (258), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 242  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (242), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (134), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17068  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 92  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (92), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1200  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (81), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 126  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (126), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 114  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1246), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 97  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1157), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 94  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.0 (1218), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 68  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (947), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 61  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (61), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 74  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (736), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 84  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (751), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (895), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (31), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 80  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (160), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (479), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 53  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (53), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (650), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (287), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (11), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (19), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.9 (251), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (322), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (7), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (144), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (69), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.0 (171), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (55), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (80), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (42), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (22), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (1), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 17068  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

#23 Nginx の worker_connections ふやしたり keepalive 効かせたり: 740727

わりとあがった。重要なんだなあ…

{"pass":true,"score":740727,"success":718975,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 21741  | 0   | 21741 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.060 | 97.236 | 0.004 | 0.008 | 0.012 | 0.016 |
| 18327  | 0   | 18327 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.056 | 61.420 | 0.003 | 0.008 | 0.008 | 0.012 |
| 11614  | 0   | 0     | 11614  | 0    | 0   | POST   | /login                   | 0.000 | 0.036 | 41.704 | 0.004 | 0.008 | 0.008 | 0.012 |
| 8870   | 0   | 8870  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.032 | 39.376 | 0.004 | 0.008 | 0.012 | 0.016 |
| 1768   | 0   | 0     | 884    | 884  | 0   | POST   | /                        | 0.004 | 0.164 | 29.780 | 0.017 | 0.036 | 0.044 | 0.068 |
| 1236   | 0   | 0     | 1236   | 0    | 0   | POST   | /comment                 | 0.008 | 0.128 | 25.572 | 0.021 | 0.028 | 0.032 | 0.048 |
| 2785   | 0   | 2785  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.048 | 23.780 | 0.009 | 0.016 | 0.016 | 0.020 |
| 1830   | 0   | 0     | 1830   | 0    | 0   | POST   | /register                | 0.004 | 0.084 | 14.468 | 0.008 | 0.012 | 0.016 | 0.024 |
| 4520   | 0   | 4520  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.032 | 13.108 | 0.003 | 0.004 | 0.008 | 0.012 |
| 1830   | 0   | 0     | 0      | 1830 | 0   | GET    | /admin/banned            | 0.004 | 0.032 | 6.776  | 0.004 | 0.008 | 0.008 | 0.012 |
| 2260   | 0   | 0     | 2260   | 0    | 0   | GET    | /logout                  | 0.012 | 0.028 | 5.836  | 0.003 | 0.004 | 0.008 | 0.008 |
| 512238 | 0   | 8992  | 503246 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.008 | 0.620  | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.084 | 0.084 | 0.084  | 0.084 | 0.084 | 0.084 | 0.084 |
| 32833  | 0   | 1     | 32832  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 32833  | 0   | 1     | 32832  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 32833  | 0   | 1     | 32832  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 32833  | 0   | 1     | 32832  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 2120  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 13271  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=20.0 (265420), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1830  Time=0.00s (5s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 8870  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (177400), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1236  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 18327  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (18327), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 884  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

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

Count: 11614  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (9354), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2785  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=10.5 (29137), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 18633  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2785  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2785), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1236  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2120  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.8 (10258), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2785  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.5 (29137), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 2785  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2785), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2413  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2413), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2120  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2120), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1830  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1236  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1236  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 373  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (373), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 277  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (277), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 302  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (302), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 298  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (298), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 293  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (293), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 316  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (316), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 182  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (182), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 206  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (206), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (102), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17791  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 158  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (158), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1  Time=0.05s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1236  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 70  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (70), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 105  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1147), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (62), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1135), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 66  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (525), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 40  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (40), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 64  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (891), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1135), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 85  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (761), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 97  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (194), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (892), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 75  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (743), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (726), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 50  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (50), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (20), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (301), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (12), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (421), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 29  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (173), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (57), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (232), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (9), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (169), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (88), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.8 (99), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.8 (83), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (92), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (16), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (15), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 17791  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 17, 2023

ストレージが枯れたので増やした: 763124

IOPS 増えたりするけど、本質じゃないところに時間は使いたくないので気にしない。

スコアは変わらず。だが、気持ち iowait が増えたような…
時間おいて再起動したらスコア上がった

{"pass":true,"score":763124,"success":741302,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 22461  | 0   | 22461 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.060 | 104.856 | 0.005 | 0.008 | 0.012 | 0.016 |
| 18284  | 0   | 18284 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.060 | 64.756  | 0.004 | 0.008 | 0.008 | 0.012 |
| 11805  | 0   | 0     | 11805  | 0    | 0   | POST   | /login                   | 0.004 | 0.048 | 44.452  | 0.004 | 0.008 | 0.008 | 0.012 |
| 9070   | 0   | 9070  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.052 | 40.772  | 0.004 | 0.008 | 0.012 | 0.016 |
| 1738   | 0   | 0     | 869    | 869  | 0   | POST   | /                        | 0.004 | 0.172 | 31.644  | 0.018 | 0.036 | 0.044 | 0.084 |
| 1192   | 0   | 0     | 1192   | 0    | 0   | POST   | /comment                 | 0.008 | 0.196 | 27.940  | 0.023 | 0.028 | 0.032 | 0.116 |
| 2758   | 0   | 2758  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.052 | 23.892  | 0.009 | 0.016 | 0.016 | 0.020 |
| 1873   | 0   | 0     | 1873   | 0    | 0   | POST   | /register                | 0.004 | 0.116 | 16.860  | 0.009 | 0.012 | 0.016 | 0.048 |
| 4668   | 0   | 4668  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.040 | 13.336  | 0.003 | 0.004 | 0.008 | 0.008 |
| 1873   | 0   | 0     | 0      | 1873 | 0   | GET    | /admin/banned            | 0.004 | 0.028 | 6.796   | 0.004 | 0.008 | 0.008 | 0.012 |
| 2334   | 0   | 0     | 2334   | 0    | 0   | GET    | /logout                  | 0.000 | 0.048 | 6.184   | 0.003 | 0.004 | 0.008 | 0.012 |
| 530415 | 0   | 8961  | 521454 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.009 | 0.574   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.092 | 0.092 | 0.092   | 0.092 | 0.092 | 0.092 | 0.092 |
| 33574  | 0   | 1     | 33573  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 33574  | 0   | 1     | 33573  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 33574  | 0   | 1     | 33573  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 33574  | 0   | 1     | 33573  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 2061  Time=0.00s (10s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1873  Time=0.00s (7s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 13238  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=20.0 (264760), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1192  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 9070  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (181400), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 869  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 18284  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.0 (18284), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

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

Count: 11805  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (9471), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2758  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (28618), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 19244  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2758  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2758), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 1192  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2061  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.8 (9890), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2758  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2758), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2758  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (28619), isuconp[isuconp]@localhost
  SELECT `id` FROM `posts` WHERE `user_id` = N

Count: 2344  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2344), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2061  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2061), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1873  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1192  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1192  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 387  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (387), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 314  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (314), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 284  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (284), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 251  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (251), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 294  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (294), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N)

Count: 264  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (264), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N)

Count: 268  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (268), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N)

Count: 165  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (165), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18223  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 163  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (163), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N)

Count: 1192  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 90  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (90), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.04s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.0 (1231), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 66  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (66), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 115  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1257), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 115  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1372), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 42  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (42), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (785), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (57), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N)

Count: 81  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (725), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 73  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1017), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (158), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (731), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (47), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N)

Count: 53  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (422), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (586), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (14), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 38  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (265), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (387), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (15), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 25  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (150), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (6), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (8), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.9 (233), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (10), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (48), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (40), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (5), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `post_id` IN (N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.7 (56), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (25), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (42), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18223  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

#24 ユーザページの投稿数と被コメント数を1回のクエリで取得: 771337

スコアはあんまり変わらず…
単純にクエリが減るので前に進んだと考える

{"pass":true,"score":771337,"success":749269,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 22774  | 0   | 22774 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.048 | 106.344 | 0.005 | 0.008 | 0.012 | 0.016 |
| 18759  | 0   | 18759 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.048 | 66.000  | 0.004 | 0.008 | 0.008 | 0.012 |
| 11937  | 0   | 0     | 11937  | 0    | 0   | POST   | /login                   | 0.004 | 0.048 | 45.584  | 0.004 | 0.008 | 0.008 | 0.012 |
| 9160   | 0   | 9160  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.048 | 41.444  | 0.005 | 0.008 | 0.012 | 0.016 |
| 1758   | 0   | 0     | 879    | 879  | 0   | POST   | /                        | 0.000 | 0.204 | 31.044  | 0.018 | 0.040 | 0.048 | 0.072 |
| 1269   | 0   | 0     | 1269   | 0    | 0   | POST   | /comment                 | 0.008 | 0.172 | 27.340  | 0.022 | 0.028 | 0.032 | 0.048 |
| 2858   | 0   | 2858  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.044 | 21.648  | 0.008 | 0.012 | 0.016 | 0.020 |
| 1917   | 0   | 0     | 1917   | 0    | 0   | POST   | /register                | 0.004 | 0.112 | 15.552  | 0.008 | 0.012 | 0.016 | 0.024 |
| 4662   | 0   | 4662  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.044 | 13.632  | 0.003 | 0.004 | 0.008 | 0.012 |
| 1917   | 0   | 0     | 0      | 1917 | 0   | GET    | /admin/banned            | 0.000 | 0.020 | 7.172   | 0.004 | 0.008 | 0.008 | 0.012 |
| 2331   | 0   | 0     | 2331   | 0    | 0   | GET    | /logout                  | 0.000 | 0.024 | 6.160   | 0.003 | 0.004 | 0.008 | 0.008 |
| 535561 | 0   | 9158  | 526403 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.006 | 0.545   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.080 | 0.080 | 0.080   | 0.080 | 0.080 | 0.080 | 0.080 |
| 34113  | 0   | 1     | 34112  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34113  | 0   | 1     | 34112  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34113  | 0   | 1     | 34112  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34113  | 0   | 1     | 34112  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 2148  Time=0.00s (8s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 13549  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=20.0 (270980), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1917  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 9160  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (183200), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1269  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 879  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 18759  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.0 (18759), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

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

Count: 11937  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (9606), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2858  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (29769), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 19324  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2858  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2858), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2858  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.4 (29769), isuconp[isuconp]@localhost
  SELECT `id`, `comment_count` FROM `posts` WHERE `user_id` = N

Count: 1269  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2148  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (10124), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2858  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2858), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2461  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2461), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2148  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2148), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1917  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1269  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1269  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 18256  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 1269  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 111  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1214), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 113  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1348), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 86  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (856), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 87  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1122), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 61  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (848), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (190), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 74  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (663), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 43  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.0 (644), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 59  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (471), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (377), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 41  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (650), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 32  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (191), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (440), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 21  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (63), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (266), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (70), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (36), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (94), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (63), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (60), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (23), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (44), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18256  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

isucon@ip-172-31-34-149:~/private_isu/webapp/golang$ git pull origin izumin5210/commented-cnt
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 3), reused 6 (delta 3), pack-reused 0
Unpacking objects: 100% (6/6), 654 bytes | 218.00 KiB/s, done.
From github.com:izumin5210/private-isu-20231111
 * branch            izumin5210/commented-cnt -> FETCH_HEAD
   ce9400c..4415f86  izumin5210/commented-cnt -> origin/izumin5210/commented-cnt
Updating ce9400c..4415f86
Fast-forward
 private_isu/webapp/golang/app.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
isucon@ip-172-31-34-149:~/private_isu/webapp/golang$ ./setup.sh && sudo systemctl restart isu-go && sudo truncate --size 0 /var/log/nginx/access.log && sudo truncate --size 0 /var/log/mysql/slow.log && sudo systemctl restart mysql && sudo systemctl reload nginx
go build -o app
isucon@ip-172-31-34-149:~/private_isu/webapp/golang$ htop
isucon@ip-172-31-34-149:~/private_isu/webapp/golang$ sudo cat /var/log/nginx/access.log | /home/isucon/alp ltsv -r --sort sum -o count,1xx,2xx,3xx,4xx,5xx,method,uri,min,max,sum,avg,p90,p95,p99 -m '/image/\d+.(jpg|png|gif)','/posts/\d+','/@\w+'
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 22691  | 0   | 22691 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.052 | 106.104 | 0.005 | 0.008 | 0.012 | 0.016 |
| 18777  | 0   | 18777 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.052 | 66.220  | 0.004 | 0.008 | 0.008 | 0.012 |
| 11913  | 0   | 0     | 11913  | 0    | 0   | POST   | /login                   | 0.000 | 0.036 | 45.168  | 0.004 | 0.008 | 0.008 | 0.012 |
| 9120   | 0   | 9120  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.040 | 41.196  | 0.005 | 0.008 | 0.012 | 0.016 |
| 1756   | 0   | 0     | 878    | 878  | 0   | POST   | /                        | 0.004 | 0.144 | 31.452  | 0.018 | 0.036 | 0.044 | 0.072 |
| 1243   | 0   | 0     | 1243   | 0    | 0   | POST   | /comment                 | 0.008 | 0.140 | 27.464  | 0.022 | 0.028 | 0.032 | 0.072 |
| 2841   | 0   | 2841  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.028 | 21.760  | 0.008 | 0.012 | 0.016 | 0.020 |
| 1888   | 0   | 0     | 1888   | 0    | 0   | POST   | /register                | 0.004 | 0.112 | 15.860  | 0.008 | 0.012 | 0.016 | 0.032 |
| 4684   | 0   | 4684  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.048 | 13.724  | 0.003 | 0.004 | 0.008 | 0.012 |
| 1888   | 0   | 0     | 0      | 1888 | 0   | GET    | /admin/banned            | 0.004 | 0.036 | 7.112   | 0.004 | 0.008 | 0.008 | 0.012 |
| 2342   | 0   | 0     | 2342   | 0    | 0   | GET    | /logout                  | 0.004 | 0.036 | 6.072   | 0.003 | 0.004 | 0.008 | 0.012 |
| 534910 | 0   | 9095  | 525815 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.011 | 0.580   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.080 | 0.080 | 0.080   | 0.080 | 0.080 | 0.080 | 0.080 |
| 34170  | 0   | 1     | 34169  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34170  | 0   | 1     | 34169  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34170  | 0   | 1     | 34169  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34170  | 0   | 1     | 34169  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
(failed reverse-i-search)`rek': ./setup.sh && sudo systemctl restart isu-go && sudo truncate --size 0 /var/log/nginx/access.log && sudo truncate --size 0 /var/log/mysql/slow.log && sudo systemctl restart mysql && sudo systemctl ^Cload nginx
isucon@ip-172-31-34-149:~/private_isu/webapp/golang$
isucon@ip-172-31-34-149:~/private_isu/webapp/golang$ sudo mysqldumpslow -s t /var/log/mysql/slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 2121  Time=0.00s (8s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 1888  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 13443  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=20.0 (268860), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 9120  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (182400), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 1243  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 18777  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.0 (18777), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 878  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

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

Count: 11913  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (9571), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2841  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=10.4 (29596), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

Count: 19303  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2841  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2841), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2841  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2841), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 1243  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2121  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (10053), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 2841  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2841), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2432  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2432), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2121  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2121), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 1888  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1243  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1243  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 18088  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 1243  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 113  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1350), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 112  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1222), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1058), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 95  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (190), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.0 (757), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 62  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (554), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 58  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (806), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 55  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (819), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 57  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (454), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 40  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (633), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 46  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (322), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 28  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (471), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 26  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (78), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (138), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (266), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (207), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 12  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (60), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (36), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.8 (83), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.5 (43), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (60), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18088  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

MySQL の binlog 切ったり doublewrite とめたり: 791748

my.cnf

[mysqld]
slow_query_log = 1
slow_query_log_file= /var/log/mysql/slow.log
long_query_time = 0
innodb_flush_log_at_trx_commit = 0
disable-log-bin = 1
sync_binlog = 1000
# innodb_buffer_pool_size = 3GB
# innodb_log_file_size = 512M
innodb_flush_method=O_DIRECT_NO_FSYNC
innodb_doublewrite = 0
# max_connections=5000

{"pass":true,"score":791748,"success":767773,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 23954  | 0   | 23954 | 0      | 0    | 0   | GET    | /                        | 0.004 | 0.032 | 116.294 | 0.005 | 0.008 | 0.012 | 0.016 |
| 19139  | 0   | 19139 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.044 | 70.073  | 0.004 | 0.008 | 0.008 | 0.016 |
| 12517  | 0   | 0     | 12517  | 0    | 0   | POST   | /login                   | 0.000 | 0.048 | 49.791  | 0.004 | 0.008 | 0.012 | 0.016 |
| 9430   | 0   | 9430  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.036 | 43.855  | 0.005 | 0.008 | 0.012 | 0.016 |
| 1962   | 0   | 0     | 981    | 981  | 0   | POST   | /                        | 0.004 | 0.080 | 27.328  | 0.014 | 0.028 | 0.036 | 0.064 |
| 3100   | 0   | 3100  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.044 | 25.684  | 0.008 | 0.016 | 0.016 | 0.024 |
| 1491   | 0   | 0     | 1491   | 0    | 0   | POST   | /comment                 | 0.008 | 0.044 | 20.160  | 0.014 | 0.020 | 0.024 | 0.032 |
| 4630   | 0   | 4630  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.028 | 15.375  | 0.003 | 0.008 | 0.008 | 0.012 |
| 2119   | 0   | 0     | 2119   | 0    | 0   | POST   | /register                | 0.004 | 0.036 | 9.551   | 0.005 | 0.008 | 0.012 | 0.016 |
| 2119   | 0   | 0     | 0      | 2119 | 0   | GET    | /admin/banned            | 0.004 | 0.028 | 8.252   | 0.004 | 0.008 | 0.008 | 0.012 |
| 2315   | 0   | 0     | 2315   | 0    | 0   | GET    | /logout                  | 0.004 | 0.020 | 6.548   | 0.003 | 0.004 | 0.008 | 0.012 |
| 548175 | 0   | 9235  | 538940 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.011 | 0.563   | 0.000 | 0.000 | 0.000 | 0.000 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 0.080 | 0.080 | 0.080   | 0.080 | 0.080 | 0.080 | 0.080 |
| 34539  | 0   | 1     | 34538  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34539  | 0   | 1     | 34538  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34539  | 0   | 1     | 34538  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 34539  | 0   | 1     | 34538  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 14159  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=20.0 (283180), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `post_htmls`.`post_id` = `posts`.`id` ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 9430  Time=0.00s (4s)  Lock=0.00s (0s)  Rows=20.0 (188600), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` FORCE INDEX (`created_at`) INNER JOIN `users` ON `users`.`id` = `posts`.`user_id` AND `users`.`del_flg` = N INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`created_at` <= 'S' ORDER BY `posts`.`created_at` DESC LIMIT N

Count: 19139  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (19139), isuconp[isuconp]@localhost
  SELECT `post_htmls`.`html_with_all_comments` FROM `post_htmls` INNER JOIN `users` ON `users`.`id` = `post_htmls`.`user_id` WHERE `post_id` = N AND `del_flg` = N

Count: 3100  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=10.4 (32258), isuconp[isuconp]@localhost
  SELECT `html` FROM `posts` INNER JOIN `post_htmls` ON `posts`.`id` = `post_htmls`.`post_id` WHERE `posts`.`user_id` = N ORDER BY `created_at` DESC

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

Count: 12517  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (10202), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 2472  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`) VALUES (N, N, 'S', 'S') ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S'

Count: 19112  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 1491  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 3100  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3100), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 3100  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3100), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 2472  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (11669), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3100  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3100), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 2852  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2852), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2472  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2472), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2119  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 2119  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1491  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1491  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 981  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1491  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1491  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 17923  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 99  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1276), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 121  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1441), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1266), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 98  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (879), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1053), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 67  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (998), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 117  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (234), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 71  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (986), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 49  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (773), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (478), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 48  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (336), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 29  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (486), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 40  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (120), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 37  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (222), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 14  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.7 (248), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (55), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 13  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (52), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.8 (79), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.8 (113), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.5 (41), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (22), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (23), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17923  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 18, 2023

#27 post_htmls 取得を JOIN なしでできるようにする: 821710

CPU 負荷が少し Go に移った
目測で Go : MySQL : Nginx = 9 : 6 : 5 くらい

{"pass":true,"score":821710,"success":796189,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |   SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+
| 25082  | 0   | 25082 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.024 | 108.508 | 0.004 | 0.008 | 0.012 | 0.016 |
| 20294  | 0   | 20294 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.024 | 68.508  | 0.003 | 0.008 | 0.008 | 0.012 |
| 13266  | 0   | 0     | 13266  | 0    | 0   | POST   | /login                   | 0.000 | 0.032 | 48.616  | 0.004 | 0.008 | 0.008 | 0.012 |
| 9730   | 0   | 9730  | 0      | 0    | 0   | GET    | /posts                   | 0.004 | 0.028 | 40.448  | 0.004 | 0.008 | 0.012 | 0.016 |
| 2076   | 0   | 0     | 1038   | 1038 | 0   | POST   | /                        | 0.000 | 0.076 | 27.492  | 0.013 | 0.028 | 0.036 | 0.056 |
| 3332   | 0   | 3332  | 0      | 0    | 0   | GET    | /@\w+                    | 0.000 | 0.032 | 22.528  | 0.007 | 0.012 | 0.016 | 0.020 |
| 1665   | 0   | 0     | 1665   | 0    | 0   | POST   | /comment                 | 0.004 | 0.048 | 20.672  | 0.012 | 0.020 | 0.024 | 0.028 |
| 4826   | 0   | 4826  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.020 | 15.352  | 0.003 | 0.008 | 0.008 | 0.012 |
| 2286   | 0   | 0     | 2286   | 0    | 0   | POST   | /register                | 0.000 | 0.028 | 9.828   | 0.004 | 0.008 | 0.012 | 0.016 |
| 2286   | 0   | 0     | 0      | 2286 | 0   | GET    | /admin/banned            | 0.000 | 0.024 | 8.480   | 0.004 | 0.008 | 0.008 | 0.016 |
| 2413   | 0   | 0     | 2413   | 0    | 0   | GET    | /logout                  | 0.004 | 0.024 | 7.312   | 0.003 | 0.008 | 0.008 | 0.012 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 1.788 | 1.788 | 1.788   | 1.788 | 1.788 | 1.788 | 1.788 |
| 566200 | 0   | 9376  | 556824 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.010 | 0.561   | 0.000 | 0.000 | 0.000 | 0.000 |
| 36027  | 0   | 1     | 36026  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 36027  | 0   | 1     | 36026  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 36027  | 0   | 1     | 36026  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
| 36027  | 0   | 1     | 36026  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000   | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+---------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 16381  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (327620), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N ORDER BY `post_created_at` DESC LIMIT N

Count: 9730  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=20.0 (194600), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N AND `post_created_at` <= 'S' ORDER BY `post_created_at` DESC LIMIT N

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

Count: 20294  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (20294), isuconp[isuconp]@localhost
  SELECT `html_with_all_comments` FROM `post_htmls` WHERE `post_id` = N AND `user_del_flg` = N

Count: 13266  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.8 (10853), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1  Time=1.66s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N

Count: 1665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2703  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`, `post_created_at`, `user_del_flg`) VALUES (N, N, 'S', 'S', 'S', N) ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S', `post_created_at` = 'S', `user_del_flg` = N

Count: 3332  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3332), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 18931  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 3332  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.5 (35088), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `post_htmls`.`user_id` = N ORDER BY `post_created_at` DESC

Count: 3332  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3332), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2703  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (12694), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3332  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3332), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 3132  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3132), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2703  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2703), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2286  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 2286  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1038  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1665  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 17773  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 1  Time=0.04s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM post_htmls WHERE post_id > N

Count: 1  Time=0.04s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 128  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1526), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 133  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1452), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 153  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (306), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 108  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1394), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 80  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1112), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 111  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1103), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 94  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (840), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 63  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (937), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (858), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 71  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (566), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N WHERE user_id % N = N

Count: 59  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (176), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (357), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 24  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (405), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 29  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (174), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 17  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.9 (304), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (72), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (90), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.9 (170), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (100), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (66), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (63), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (48), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=25.0 (25), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 17773  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

#28 session store を memcached → redis に: 826249

スコアは変わらない
このあとで Redis 使いたいので、その布石

{"pass":true,"score":826249,"success":800306,"fail":0,"messages":[]}

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 18, 2023

#30 / の HTML を事前計算して redis にキャッシュ: 862964

{"pass":true,"score":862964,"success":835040,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 27508  | 0   | 27508 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.028 | 79.964 | 0.003 | 0.008 | 0.008 | 0.012 |
| 21230  | 0   | 21230 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.032 | 61.760 | 0.003 | 0.008 | 0.008 | 0.012 |
| 14472  | 0   | 0     | 14472  | 0    | 0   | POST   | /login                   | 0.000 | 0.024 | 46.492 | 0.003 | 0.008 | 0.008 | 0.012 |
| 9600   | 0   | 9600  | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.024 | 36.296 | 0.004 | 0.008 | 0.008 | 0.012 |
| 2232   | 0   | 0     | 1116   | 1116 | 0   | POST   | /                        | 0.000 | 0.072 | 29.072 | 0.013 | 0.028 | 0.036 | 0.060 |
| 1821   | 0   | 0     | 1821   | 0    | 0   | POST   | /comment                 | 0.004 | 0.044 | 22.572 | 0.012 | 0.020 | 0.024 | 0.028 |
| 3549   | 0   | 3549  | 0      | 0    | 0   | GET    | /@\w+                    | 0.000 | 0.032 | 21.548 | 0.006 | 0.012 | 0.012 | 0.020 |
| 5144   | 0   | 5144  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.016 | 14.300 | 0.003 | 0.004 | 0.008 | 0.008 |
| 2703   | 0   | 0     | 2703   | 0    | 0   | POST   | /register                | 0.004 | 0.024 | 9.772  | 0.004 | 0.008 | 0.008 | 0.012 |
| 2703   | 0   | 0     | 0      | 2703 | 0   | GET    | /admin/banned            | 0.000 | 0.020 | 8.176  | 0.003 | 0.008 | 0.008 | 0.012 |
| 2572   | 0   | 0     | 2572   | 0    | 0   | GET    | /logout                  | 0.000 | 0.024 | 6.624  | 0.003 | 0.004 | 0.008 | 0.008 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 2.356 | 2.356 | 2.356  | 2.356 | 2.356 | 2.356 | 2.356 |
| 590682 | 0   | 9652  | 581030 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.008 | 0.660  | 0.000 | 0.000 | 0.000 | 0.000 |
| 38070  | 0   | 1     | 38069  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 38070  | 0   | 1     | 38069  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 38070  | 0   | 1     | 38069  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 38070  | 0   | 1     | 38069  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 23545  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (23545), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 9600  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=20.0 (192000), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N AND `post_created_at` <= 'S' ORDER BY `post_created_at` DESC LIMIT N

Count: 21230  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (21230), isuconp[isuconp]@localhost
  SELECT `html_with_all_comments` FROM `post_htmls` WHERE `post_id` = N AND `user_del_flg` = N

Count: 14472  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.8 (11900), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1  Time=2.04s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N

Count: 1821  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2937  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`, `post_created_at`, `user_del_flg`) VALUES (N, N, 'S', 'S', 'S', N) ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S', `post_created_at` = 'S', `user_del_flg` = N

Count: 3549  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3549), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 3549  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.5 (37350), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `post_htmls`.`user_id` = N ORDER BY `post_created_at` DESC

Count: 2938  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (58760), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N ORDER BY `post_created_at` DESC LIMIT N

Count: 3549  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3549), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 15766  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 2937  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (13823), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3549  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3549), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 3423  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3423), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2937  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2937), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2703  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 2703  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1821  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1821  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1  Time=0.18s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM post_htmls WHERE post_id > N

Count: 1116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1821  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1821  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 1  Time=0.05s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1  Time=0.05s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 14706  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 134  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1598), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 137  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1493), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 120  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1553), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 173  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (346), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 98  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1365), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 108  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1070), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 82  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (1221), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 104  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (930), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (605), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 61  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (966), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N WHERE user_id % N = N

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (357), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 55  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (165), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 31  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.8 (522), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 40  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (240), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 16  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.5 (280), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (72), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (55), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 6  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.5 (111), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.6 (98), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.8 (83), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 3  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (66), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 14706  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

この時点でアクセスログとスロークエリログを止めたら 891341 になった

{"pass":true,"score":891341,"success":863194,"fail":0,"messages":[]}

@izumin5210
Copy link
Member Author

gzip off;: 994698

Nginx が MySQL よりも忙しそうだったので…

{"pass":true,"score":994698,"success":967455,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 30440  | 0   | 30440 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.036 | 92.720 | 0.003 | 0.008 | 0.008 | 0.012 |
| 22455  | 0   | 22455 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.040 | 73.124 | 0.003 | 0.008 | 0.008 | 0.012 |
| 14655  | 0   | 0     | 14655  | 0    | 0   | POST   | /login                   | 0.004 | 0.032 | 52.816 | 0.004 | 0.008 | 0.008 | 0.012 |
| 11310  | 0   | 11310 | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.032 | 46.284 | 0.004 | 0.008 | 0.012 | 0.016 |
| 2080   | 0   | 0     | 1040   | 1040 | 0   | POST   | /                        | 0.016 | 0.084 | 30.464 | 0.015 | 0.032 | 0.040 | 0.064 |
| 1700   | 0   | 0     | 1700   | 0    | 0   | POST   | /comment                 | 0.004 | 0.044 | 24.036 | 0.014 | 0.024 | 0.028 | 0.032 |
| 3559   | 0   | 3559  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.032 | 23.872 | 0.007 | 0.012 | 0.016 | 0.020 |
| 5538   | 0   | 5538  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.024 | 17.428 | 0.003 | 0.008 | 0.008 | 0.012 |
| 2568   | 0   | 0     | 2568   | 0    | 0   | POST   | /register                | 0.004 | 0.024 | 11.164 | 0.004 | 0.008 | 0.012 | 0.016 |
| 2568   | 0   | 0     | 0      | 2568 | 0   | GET    | /admin/banned            | 0.000 | 0.032 | 9.100  | 0.004 | 0.008 | 0.008 | 0.012 |
| 2769   | 0   | 0     | 2769   | 0    | 0   | GET    | /logout                  | 0.000 | 0.020 | 7.600  | 0.003 | 0.004 | 0.008 | 0.012 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 2.412 | 2.412 | 2.412  | 2.412 | 2.412 | 2.412 | 2.412 |
| 697150 | 0   | 9701  | 687449 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.010 | 0.590  | 0.000 | 0.000 | 0.000 | 0.000 |
| 43098  | 0   | 1     | 43097  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 43098  | 0   | 1     | 43097  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 43098  | 0   | 1     | 43097  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 43098  | 0   | 1     | 43097  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 11310  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (226200), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N AND `post_created_at` <= 'S' ORDER BY `post_created_at` DESC LIMIT N

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

Count: 22455  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=1.0 (22455), isuconp[isuconp]@localhost
  SELECT `html_with_all_comments` FROM `post_htmls` WHERE `post_id` = N AND `user_del_flg` = N

Count: 14655  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.8 (11886), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1  Time=2.05s (2s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N

Count: 1700  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 2740  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`, `post_created_at`, `user_del_flg`) VALUES (N, N, 'S', 'S', 'S', N) ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S', `post_created_at` = 'S', `user_del_flg` = N

Count: 3559  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3559), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 3559  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.6 (37602), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `post_htmls`.`user_id` = N ORDER BY `post_created_at` DESC

Count: 17496  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 3559  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3559), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 2741  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (54820), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N ORDER BY `post_created_at` DESC LIMIT N

Count: 2740  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.9 (13374), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3559  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3559), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 3160  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3160), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 2740  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (2740), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 2568  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 2568  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1700  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1700  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1  Time=0.17s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM post_htmls WHERE post_id > N

Count: 1040  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1700  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1  Time=0.08s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1  Time=0.06s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 1700  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 16669  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 1  Time=0.03s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 136  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1622), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 132  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1439), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1371), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 150  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (300), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1148), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 105  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (936), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 85  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1183), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (1177), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 79  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.9 (627), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.8 (807), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N WHERE user_id % N = N

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (356), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 54  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (162), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 33  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (557), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 21  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.0 (377), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 27  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (162), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (60), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 15  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (75), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 10  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.0 (190), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (105), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (88), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 4  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (80), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 16669  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

izumin5210 commented Nov 18, 2023

#33: layout に埋め込むユーザ情報を redis にキャッシュ: 1024558

1,000,000 突破 🚀

最も回数が多いクエリの一つを Redis に移したが、スコア的には微増(とはいえ2万上がってるんだけど)
雑巾絞りになってきた…

{"pass":true,"score":1024558,"success":994140,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 32289  | 0   | 32289 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.044 | 79.616 | 0.002 | 0.004 | 0.008 | 0.008 |
| 23771  | 0   | 23771 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.004 | 0.044 | 68.980 | 0.003 | 0.008 | 0.008 | 0.012 |
| 16034  | 0   | 0     | 16034  | 0    | 0   | POST   | /login                   | 0.000 | 0.040 | 59.024 | 0.004 | 0.008 | 0.008 | 0.012 |
| 11550  | 0   | 11550 | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.040 | 43.528 | 0.004 | 0.008 | 0.008 | 0.012 |
| 2346   | 0   | 0     | 1173   | 1173 | 0   | POST   | /                        | 0.004 | 0.084 | 30.792 | 0.013 | 0.028 | 0.040 | 0.064 |
| 1944   | 0   | 0     | 1944   | 0    | 0   | POST   | /comment                 | 0.004 | 0.064 | 24.608 | 0.013 | 0.020 | 0.024 | 0.028 |
| 3904   | 0   | 3904  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.044 | 23.276 | 0.006 | 0.012 | 0.012 | 0.016 |
| 5792   | 0   | 5792  | 0      | 0    | 0   | GET    | /login                   | 0.004 | 0.040 | 16.732 | 0.003 | 0.008 | 0.008 | 0.012 |
| 3056   | 0   | 0     | 3056   | 0    | 0   | POST   | /register                | 0.004 | 0.040 | 13.684 | 0.004 | 0.008 | 0.012 | 0.016 |
| 2896   | 0   | 0     | 2896   | 0    | 0   | GET    | /logout                  | 0.004 | 0.020 | 7.572  | 0.003 | 0.004 | 0.008 | 0.008 |
| 3056   | 0   | 0     | 0      | 3056 | 0   | GET    | /admin/banned            | 0.004 | 0.032 | 6.764  | 0.002 | 0.004 | 0.008 | 0.008 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 1.776 | 1.776 | 1.776  | 1.776 | 1.776 | 1.776 | 1.776 |
| 711221 | 0   | 9933  | 701288 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.009 | 0.614  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44501  | 0   | 1     | 44500  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44501  | 0   | 1     | 44500  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44501  | 0   | 1     | 44500  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44501  | 0   | 1     | 44500  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 11550  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (231000), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N AND `post_created_at` <= 'S' ORDER BY `post_created_at` DESC LIMIT N

Count: 23771  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.0 (23771), isuconp[isuconp]@localhost
  SELECT `html_with_all_comments` FROM `post_htmls` WHERE `post_id` = N AND `user_del_flg` = N

Count: 16034  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.8 (13138), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1  Time=1.72s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N

Count: 1944  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 3117  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`, `post_created_at`, `user_del_flg`) VALUES (N, N, 'S', 'S', 'S', N) ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S', `post_created_at` = 'S', `user_del_flg` = N

Count: 3904  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3904), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 3904  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.6 (41286), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `post_htmls`.`user_id` = N ORDER BY `post_created_at` DESC

Count: 3904  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3904), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 3118  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (62360), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N ORDER BY `post_created_at` DESC LIMIT N

Count: 3117  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (14744), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3904  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3904), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 13160  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 3625  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3625), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 3117  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3117), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 3056  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 3056  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1944  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1944  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1173  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1944  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1944  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 12647  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 205  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (410), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 138  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1511), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 125  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.0 (1494), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 119  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1541), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 107  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1492), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 86  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=14.9 (1283), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 110  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1090), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 107  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.9 (956), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 74  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (1175), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 78  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (622), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 72  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (215), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N WHERE user_id % N = N

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM post_htmls WHERE post_id > N

Count: 48  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (809), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 51  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (357), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 23  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.8 (410), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 33  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (198), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 21  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (84), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 18  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (90), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 9  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.0 (171), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (100), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (44), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (42), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=23.0 (46), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=24.0 (24), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

@izumin5210
Copy link
Member Author

#34 GET /login のテンプレを事前に実行: 1026010

ほぼ変わらないけど…

{"pass":true,"score":1026010,"success":995294,"fail":0,"messages":[]}

@izumin5210
Copy link
Member Author

#31 画像書き出しに io.CopyBuffer を利用 + バッファをプール: 1033101

微妙〜〜〜

{"pass":true,"score":1033101,"success":1001737,"fail":0,"messages":[]}
access.log

+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| COUNT  | 1XX |  2XX  |  3XX   | 4XX  | 5XX | METHOD |           URI            |  MIN  |  MAX  |  SUM   |  AVG  |  P90  |  P95  |  P99  |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+
| 32735  | 0   | 32735 | 0      | 0    | 0   | GET    | /                        | 0.000 | 0.024 | 77.522 | 0.002 | 0.004 | 0.008 | 0.008 |
| 24012  | 0   | 24012 | 0      | 0    | 0   | GET    | /posts/\d+               | 0.000 | 0.036 | 68.219 | 0.003 | 0.008 | 0.008 | 0.012 |
| 16609  | 0   | 0     | 16609  | 0    | 0   | POST   | /login                   | 0.000 | 0.028 | 58.335 | 0.004 | 0.008 | 0.008 | 0.012 |
| 11520  | 0   | 11520 | 0      | 0    | 0   | GET    | /posts                   | 0.000 | 0.024 | 42.519 | 0.004 | 0.008 | 0.008 | 0.012 |
| 2414   | 0   | 0     | 1207   | 1207 | 0   | POST   | /                        | 0.004 | 0.076 | 29.571 | 0.012 | 0.024 | 0.032 | 0.060 |
| 1983   | 0   | 0     | 1983   | 0    | 0   | POST   | /comment                 | 0.004 | 0.040 | 24.475 | 0.012 | 0.020 | 0.024 | 0.028 |
| 3962   | 0   | 3962  | 0      | 0    | 0   | GET    | /@\w+                    | 0.004 | 0.028 | 23.419 | 0.006 | 0.012 | 0.012 | 0.016 |
| 3116   | 0   | 0     | 3116   | 0    | 0   | POST   | /register                | 0.004 | 0.024 | 13.927 | 0.004 | 0.008 | 0.012 | 0.016 |
| 6064   | 0   | 6064  | 0      | 0    | 0   | GET    | /login                   | 0.000 | 0.016 | 13.840 | 0.002 | 0.004 | 0.008 | 0.008 |
| 3032   | 0   | 0     | 3032   | 0    | 0   | GET    | /logout                  | 0.000 | 0.016 | 7.644  | 0.003 | 0.004 | 0.008 | 0.008 |
| 3116   | 0   | 0     | 0      | 3116 | 0   | GET    | /admin/banned            | 0.004 | 0.016 | 6.880  | 0.002 | 0.004 | 0.008 | 0.008 |
| 1      | 0   | 1     | 0      | 0    | 0   | GET    | /initialize              | 2.304 | 2.304 | 2.304  | 2.304 | 2.304 | 2.304 | 2.304 |
| 715371 | 0   | 9939  | 705432 | 0    | 0   | GET    | /image/\d+.(jpg|png|gif) | 0.000 | 0.010 | 0.640  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44907  | 0   | 1     | 44906  | 0    | 0   | GET    | /favicon.ico             | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44907  | 0   | 1     | 44906  | 0    | 0   | GET    | /js/timeago.min.js       | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44907  | 0   | 1     | 44906  | 0    | 0   | GET    | /js/main.js              | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
| 44907  | 0   | 1     | 44906  | 0    | 0   | GET    | /css/style.css           | 0.000 | 0.000 | 0.000  | 0.000 | 0.000 | 0.000 | 0.000 |
+--------+-----+-------+--------+------+-----+--------+--------------------------+-------+-------+--------+-------+-------+-------+-------+

slow.log

Reading mysql slow query log from /var/log/mysql/slow.log
Count: 11520  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=20.0 (230400), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N AND `post_created_at` <= 'S' ORDER BY `post_created_at` DESC LIMIT N

Count: 24012  Time=0.00s (3s)  Lock=0.00s (0s)  Rows=1.0 (24012), isuconp[isuconp]@localhost
  SELECT `html_with_all_comments` FROM `post_htmls` WHERE `post_id` = N AND `user_del_flg` = N

Count: 16609  Time=0.00s (2s)  Lock=0.00s (0s)  Rows=0.8 (13577), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE account_name = 'S' AND del_flg = N

Count: 1  Time=1.93s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N

Count: 1983  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `comments` SET `freshness` = `freshness` + N WHERE `post_id` = N

Count: 3190  Time=0.00s (1s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `post_htmls` (`post_id`, `user_id`, `html`, `html_with_all_comments`, `post_created_at`, `user_del_flg`) VALUES (N, N, 'S', 'S', 'S', N) ON DUPLICATE KEY UPDATE `html` = 'S', `html_with_all_comments` = 'S', `post_created_at` = 'S', `user_del_flg` = N

Count: 3962  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3962), isuconp[isuconp]@localhost
  SELECT COUNT(`id`) AS `post_count`, SUM(`comment_count`)  AS `commented_count` FROM `posts` WHERE `user_id` = N

Count: 3962  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.5 (41592), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `post_htmls`.`user_id` = N ORDER BY `post_created_at` DESC

Count: 3191  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (63820), isuconp[isuconp]@localhost
  SELECT `html` FROM `post_htmls` WHERE `user_del_flg` = N ORDER BY `post_created_at` DESC LIMIT N

Count: 3962  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3962), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 3190  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.7 (14864), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` IN (N) ORDER BY `created_at` DESC

Count: 3962  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3962), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `account_name` = 'S' AND `del_flg` = N

Count: 13538  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SET NAMES utf8mb4

Count: 3722  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3722), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N)

Count: 3190  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=1.0 (3190), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at`, `comment_count` FROM `posts` WHERE `id` = N

Count: 3116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `users` (`account_name`, `passhash`) VALUES ('S','S')

Count: 3116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  SELECT N FROM users WHERE `account_name` = 'S'

Count: 1983  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE `posts` SET `comment_count` = `comment_count` + N WHERE `id` = N

Count: 1983  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (N,N,'S')

Count: 1  Time=0.18s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM post_htmls WHERE post_id > N

Count: 1207  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `body`) VALUES (N,'S','S')

Count: 1983  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  COMMIT

Count: 1  Time=0.09s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM comments WHERE id > N

Count: 1983  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  START TRANSACTION

Count: 1  Time=0.06s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM users WHERE id > N

Count: 212  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=2.0 (423), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N)

Count: 13046  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

Count: 122  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=11.9 (1456), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N)

Count: 129  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=10.9 (1410), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N)

Count: 116  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=12.9 (1497), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 106  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.9 (1052), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N)

Count: 97  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=13.9 (1353), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 88  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.0 (1316), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 102  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=9.0 (913), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  DELETE FROM posts WHERE id > N

Count: 75  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=15.9 (1191), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 76  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=8.0 (607), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE post_htmls SET user_del_flg = N WHERE user_id % N = N

Count: 47  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=16.9 (795), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 74  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (222), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N)

Count: 60  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=7.0 (420), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N)

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=17.9 (536), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.01s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N

Count: 34  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=6.0 (204), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N)

Count: 19  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=18.9 (359), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 30  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=4.0 (120), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N)

Count: 20  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=5.0 (100), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N)

Count: 8  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=19.9 (159), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 5  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=21.0 (105), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  UPDATE users SET del_flg = N WHERE id % N = N

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=22.0 (22), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` IN (N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N)

Count: 13046  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  administrator command: Quit

@izumin5210
Copy link
Member Author

おわり!: 1092235

そろそろ別のことやりたいので finish にする

MySQL の設定ちょっといじって、アクセスログ・alp用のログ・スロークエリログをオフにした

+innodb_buffer_pool_size = 3GB
+innodb_log_file_size = 512M
+max_connections=5000
{"pass":true,"score":1092235,"success":1059635,"fail":0,"messages":[]}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant