Open euglena1215 opened 5 years ago
初期
## 2019-08-25 02:25:21.36 +0000
18 SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N
13 SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = N
6 SELECT * FROM `posts` WHERE `id` = N
2 SELECT `id`, `user_id`, `body`, `created_at`, `mime` FROM `posts` ORDER BY `created_at` DESC
2 SELECT * FROM `users` WHERE `id` = ?
2 SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC
1 SELECT * FROM `posts` WHERE `id` = S
1 SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N
1 INSERT INTO `users` (`account_name`, `passhash`) VALUES (?,?)
1 SELECT * FROM `users` WHERE `id` = N
↑わかること
クエリの回数が異常に少ないかも?
schemaと見比べると良さそう https://github.com/ykamez/pixiv-iscuon/issues/2#issuecomment-524593212
一旦全部はり作戦
一応走らせた
$ myprofiler -user=root
## 2019-08-25 03:01:09.97 +0000
5 SELECT * FROM `posts` WHERE `id` = N
5 SELECT `id`, `user_id`, `body`, `created_at`, `mime` FROM `posts` ORDER BY `created_at` DESC
3 INSERT INTO `users` (`account_name`, `passhash`) VALUES (?,?)
2 INSERT INTO `posts` (`user_id`, `mime`, `imgdata`, `body`) VALUES (?,?,?,?)
1 SELECT * FROM `posts` WHERE `id` = ?
1 SELECT * FROM `users` WHERE `id` = ?
1 SELECT * FROM `comments` WHERE `post_id` = ? ORDER BY `created_at` DESC LIMIT N
1 SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N
1 SELECT * FROM `users` WHERE `id` = N
## 2019-08-25 05:14:18.52 +0000
2 INSERT INTO `posts` (`user_id`, `mime`, `imgdata`, `body`) VALUES (?,?,?,?)
2 INSERT INTO `users` (`account_name`, `passhash`) VALUES (?,?)
2 SELECT `id`, `user_id`, `body`, `created_at`, `mime` FROM `posts` ORDER BY `created_at` DESC
2 SELECT * FROM `comments` WHERE `post_id` = ? ORDER BY `created_at` DESC LIMIT N
1 INSERT INTO `comments` (`post_id`, `user_id`, `comment`) VALUES (?,?,?)
1 SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N
1 SELECT * FROM `posts` WHERE `id` = S
1 SELECT * FROM `users` WHERE `id` = ?
1 SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `created_at` <= S ORDER BY `created_at` DESC
1 SELECT * FROM `users` WHERE `id` = N
ref https://github.com/ykamez/pixiv-iscuon/issues/2