saza-ku / private-isu-2023-public

0 stars 0 forks source link

10220740 #16

Open saza-ku opened 1 year ago

saza-ku commented 1 year ago

isucon1

alp

+-------+--------+-----------+-------+-------+-------+-------+-------+
| COUNT | METHOD |    URI    |  MIN  |  MAX  |  SUM  |  AVG  |  P99  |
+-------+--------+-----------+-------+-------+-------+-------+-------+
| 2     | GET    | /         | 0.016 | 0.024 | 0.040 | 0.020 | 0.024 |
| 2     | POST   | /login    | 0.008 | 0.012 | 0.020 | 0.010 | 0.012 |
| 8     | GET    | /image/.+ | 0.000 | 0.004 | 0.012 | 0.002 | 0.004 |
| 2     | GET    | /login    | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+--------+-----------+-------+-------+-------+-------+-------+

slow query

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

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

Count: 40  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=3.0 (120), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT 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` = N

Count: 2  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (40), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `not_banned_posts` ORDER BY `created_at` DESC LIMIT N

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

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

Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  #

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

explain

Reading from STDIN ...

# 140ms user time, 40ms system time, 36.90M rss, 50.16M vsz
# Current date: Sun Oct 22 19:41:38 2023
# Hostname: private-isu
# Files: STDIN
# Overall: 263 total, 12 unique, 3.55 QPS, 0.00x concurrency _____________
# Time range: 2023-10-22T10:40:24 to 2023-10-22T10:41:38
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Exec time           43ms     3us     3ms   164us   316us   262us   113us
# Lock time          283us       0    10us     1us     1us       0     1us
# Rows sent            377       0      20    1.43    2.90    1.73    0.99
# Rows examine         769       0      44    2.92   10.84    4.75    0.99
# Query size        12.81k      17     195   49.88   80.10   19.81   36.69

# Profile
# Rank Query ID                        Response time Calls R/Call V/M   It
# ==== =============================== ============= ===== ====== ===== ==
#    1 0x396201721CD58410E070DA9421...  0.0167 38.7%   161 0.0001  0.00 SELECT users
#    2 0x19759A5557089FD5B718D440CB...  0.0106 24.5%    12 0.0009  0.00 SELECT posts
#    3 0x624863D30DAC59FA1684928219...  0.0060 13.9%    40 0.0002  0.00 SELECT comments
#    4 0x422390B42D4DD86C7539A5F45E...  0.0053 12.3%    40 0.0001  0.00 SELECT comments
# MISC 0xMISC                           0.0045 10.5%    10 0.0005   0.0 <8 ITEMS>

# Query 1: 2.30 QPS, 0.00x concurrency, ID 0x396201721CD58410E070DA9421CA8C8D at byte 30539
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-22T10:40:24 to 2023-10-22T10:41:34
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         61     161
# Exec time     38    17ms    58us   986us   103us   138us    76us   108us
# Lock time     53   152us       0     9us       0     1us       0     1us
# Rows sent     42     161       1       1       1       1       0       1
# Rows examine  20     161       1       1       1       1       0       1
# Query size    46   5.95k      36      38   37.85   36.69    0.24   36.69
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us  ##############################################################
# 100us  ################################################################
#   1ms  #
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'users'\G
#    SHOW CREATE TABLE `users`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT * FROM `users` WHERE `id` = 476\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: users
#    partitions: NULL
#          type: const
# possible_keys: PRIMARY
#           key: PRIMARY
#       key_len: 4
#           ref: const
#          rows: 1
#      filtered: 100.00
#         Extra: NULL

# Query 2: 0.17 QPS, 0.00x concurrency, ID 0x19759A5557089FD5B718D440CBBB5C55 at byte 30781
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-22T10:40:24 to 2023-10-22T10:41:35
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          4      12
# Exec time     24    11ms   272us     2ms   880us     2ms   609us   490us
# Lock time     10    31us     1us     4us     2us     3us     1us     2us
# Rows sent      3      12       1       1       1       1       0       1
# Rows examine   1      12       1       1       1       1       0       1
# Query size     3     470      39      40   39.17   38.53       0   38.53
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us
# 100us  ################################################################
#   1ms  #############################################
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'posts'\G
#    SHOW CREATE TABLE `posts`\G
# EXPLAIN 
SELECT * FROM `posts` WHERE `id` = 10000\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: posts
#    partitions: NULL
#          type: const
# possible_keys: PRIMARY
#           key: PRIMARY
#       key_len: 4
#           ref: const
#          rows: 1
#      filtered: 100.00
#         Extra: NULL

# Query 3: 0.57 QPS, 0.00x concurrency, ID 0x624863D30DAC59FA16849282195BE09F at byte 20391
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-22T10:40:24 to 2023-10-22T10:41:34
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         15      40
# Exec time     13     6ms    95us   219us   150us   214us    45us   176us
# Lock time     13    39us       0     2us       0     1us       0     1us
# Rows sent     31     120       3       3       3       3       0       3
# Rows examine  15     120       3       3       3       3       0       3
# Query size    25   3.21k      82      83   82.05   80.10       0   80.10
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us  #######
# 100us  ################################################################
#   1ms
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'comments'\G
#    SHOW CREATE TABLE `comments`\G
# EXPLAIN 
SELECT * FROM `comments` WHERE `post_id` = 9986 ORDER BY `created_at` DESC LIMIT 3\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: comments
#    partitions: NULL
#          type: ref
# possible_keys: comments_post_id_index
#           key: comments_post_id_index
#       key_len: 4
#           ref: const
#          rows: 10
#      filtered: 100.00
#         Extra: NULL

# Query 4: 0.57 QPS, 0.00x concurrency, ID 0x422390B42D4DD86C7539A5F45EB76A80 at byte 319
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-22T10:40:24 to 2023-10-22T10:41:34
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         15      40
# Exec time     12     5ms    87us   283us   133us   176us    40us   144us
# Lock time     16    46us       0    10us     1us     1us     1us     1us
# Rows sent     10      40       1       1       1       1       0       1
# Rows examine  49     384       5      18    9.60   13.83    3.23    9.83
# Query size    19   2.54k      65      66   65.05   62.76    0.50   62.76
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us  ######################################
# 100us  ################################################################
#   1ms
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'comments'\G
#    SHOW CREATE TABLE `comments`\G
# EXPLAIN 
SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = 10000\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: comments
#    partitions: NULL
#          type: ref
# possible_keys: comments_post_id_index
#           key: comments_post_id_index
#       key_len: 4
#           ref: const
#          rows: 11
#      filtered: 100.00
#         Extra: Using index

netdata

http://localhost:19991/#menu_apps_submenu_cpu;after=1697971220637;before=1697971297877