saza-ku / private-isu-2023-public

0 stars 0 forks source link

10220821 #19

Open saza-ku opened 1 year ago

saza-ku commented 1 year ago

isucon1

alp

+-------+--------+---------------+-------+-------+-------+-------+-------+
| COUNT | METHOD |      URI      |  MIN  |  MAX  |  SUM  |  AVG  |  P99  |
+-------+--------+---------------+-------+-------+-------+-------+-------+
| 7     | POST   | /login        | 0.008 | 0.024 | 0.080 | 0.011 | 0.024 |
| 11    | GET    | /             | 0.000 | 0.004 | 0.020 | 0.002 | 0.004 |
| 1     | GET    | /@.+          | 0.020 | 0.020 | 0.020 | 0.020 | 0.020 |
| 1     | POST   | /register     | 0.012 | 0.012 | 0.012 | 0.012 | 0.012 |
| 2     | GET    | /login        | 0.000 | 0.004 | 0.004 | 0.002 | 0.004 |
| 1     | POST   | /             | 0.004 | 0.004 | 0.004 | 0.004 | 0.004 |
| 1     | GET    | /admin/banned | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
+-------+--------+---------------+-------+-------+-------+-------+-------+

slow query

Count: 1  Time=0.02s (0s)  Lock=0.00s (0s)  Rows=7.0 (7), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `not_banned_posts` WHERE `user_id` = N ORDER BY `created_at` DESC LIMIT N

Count: 1  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: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (220), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `not_banned_posts` ORDER BY `created_at` DESC LIMIT N

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

Count: 11  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=20.0 (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)

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` = N

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

Count: 7  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.9 (6), 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=1.0 (1), 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=1.0 (1), isuconp[isuconp]@localhost
  SELECT * FROM users WHERE id IN (N, N, N, N, N, N, N)

explain

Reading from STDIN ...

# 170ms user time, 0 system time, 36.88M rss, 50.16M vsz
# Current date: Sun Oct 22 20:23:12 2023
# Hostname: private-isu
# Files: STDIN
# Overall: 71 total, 10 unique, 2.63 QPS, 0.00x concurrency ______________
# Time range: 2023-10-22T11:21:56 to 2023-10-22T11:22:23
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Exec time           36ms   109us    16ms   507us   384us     2ms   176us
# Lock time          143us     1us    11us     2us     4us     1us     1us
# Rows sent            516       0      20    7.27   19.46    8.35    0.99
# Rows examine      10.63k       0   9.77k  153.35   42.48   1.10k    2.90
# Query size         5.81k      36     216   83.73  124.25   33.42   80.10

# Profile
# Rank Query ID                         Response time Calls R/Call V/M   I
# ==== ================================ ============= ===== ====== ===== =
#    1 0x6CDBE4EF88BE5164D1AE8FD28B0...  0.0162 44.9%     1 0.0162  0.00 SELECT not_banned_posts
#    2 0x26489ECBE26887E480CA8067F97...  0.0050 13.8%     1 0.0050  0.00 INSERT users
#    3 0xF2625110D4E24D1518A32E275BF...  0.0045 12.5%    11 0.0004  0.00 SELECT not_banned_posts
#    4 0x396201721CD58410E070DA9421C...  0.0027  7.5%    13 0.0002  0.00 SELECT users
# MISC 0xMISC                            0.0076 21.2%    45 0.0002   0.0 <6 ITEMS>

# Query 1: 0 QPS, 0x concurrency, ID 0x6CDBE4EF88BE5164D1AE8FD28B0BAAFA at byte 1998
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-10-22T11:21:56
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          1       1
# Exec time     44    16ms    16ms    16ms    16ms    16ms       0    16ms
# Lock time      1     2us     2us     2us     2us     2us       0     2us
# Rows sent      1       7       7       7       7       7       0       7
# Rows examine  91   9.77k   9.77k   9.77k   9.77k   9.77k       0   9.77k
# Query size     2     134     134     134     134     134       0     134
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms
#  10ms  ################################################################
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'not_banned_posts'\G
#    SHOW CREATE TABLE `not_banned_posts`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `not_banned_posts` WHERE `user_id` = 631 ORDER BY `created_at` DESC LIMIT 20\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
# *************************** 2. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: posts
#    partitions: NULL
#          type: index
# possible_keys: NULL
#           key: posts_created_at_index
#       key_len: 4
#           ref: NULL
#          rows: 20
#      filtered: 10.00
#         Extra: Using where

# Query 2: 0 QPS, 0x concurrency, ID 0x26489ECBE26887E480CA8067F971EA04 at byte 11360
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2023-10-22T11:21:56
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          1       1
# Exec time     13     5ms     5ms     5ms     5ms     5ms       0     5ms
# Lock time      1     2us     2us     2us     2us     2us       0     2us
# Rows sent      0       0       0       0       0       0       0       0
# Rows examine   0       0       0       0       0       0       0       0
# Query size     3     216     216     216     216     216       0     216
# 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
INSERT INTO `users` (`account_name`, `passhash`) VALUES ('9OaSQGSWq91Zt8erDR2yDfgWq','b765b7bce9296392bcb0783f3c73506d96958e72e3c1a711ce86adfdef1b1a8edfa834686966195f0da45995fec85d07b764c2116658eaa2427ac3f98a060b24')\G

# Query 3: 0.41 QPS, 0.00x concurrency, ID 0xF2625110D4E24D1518A32E275BFD42EE at byte 512
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-22T11:21:56 to 2023-10-22T11:22:23
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         15      11
# Exec time     12     5ms   279us     1ms   410us   384us   216us   375us
# Lock time     19    28us     1us    10us     2us     1us     2us     1us
# Rows sent     42     220      20      20      20      20       0      20
# Rows examine   4     484      44      44      44      44       0      44
# Query size    20   1.20k     112     112     112     112       0     112
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us
# 100us  ################################################################
#   1ms  ######
#  10ms
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'not_banned_posts'\G
#    SHOW CREATE TABLE `not_banned_posts`\G
# EXPLAIN 
SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `not_banned_posts` ORDER BY `created_at` DESC LIMIT 20\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: posts
#    partitions: NULL
#          type: index
# possible_keys: NULL
#           key: posts_created_at_index
#       key_len: 4
#           ref: NULL
#          rows: 199
#      filtered: 100.00
#         Extra: NULL
# *************************** 2. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: users
#    partitions: NULL
#          type: eq_ref
# possible_keys: PRIMARY
#           key: PRIMARY
#       key_len: 4
#           ref: isuconp.posts.user_id
#          rows: 1
#      filtered: 10.00
#         Extra: Using where

# Query 4: 0.48 QPS, 0.00x concurrency, ID 0x396201721CD58410E070DA9421CA8C8D at byte 16136
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-22T11:21:56 to 2023-10-22T11:22:23
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         18      13
# Exec time      7     3ms   117us   318us   209us   316us    88us   205us
# Lock time     34    49us     1us    11us     3us     8us     2us     2us
# Rows sent      2      13       1       1       1       1       0       1
# Rows examine   0      13       1       1       1       1       0       1
# Query size     8     483      36      39   37.15   36.69    1.07   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 
SELECT * FROM `users` WHERE `id` = 1\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

netdata

http://localhost:19991/#menu_apps_submenu_cpu;after=1697973716221;before=1697973792577