soudai / isucon9-qualify

そーだいさんがめちゃめちゃ頑張って予選突破を目指すスレ
0 stars 0 forks source link

dbまとめ #1

Closed soudai closed 3 years ago

soudai commented 5 years ago

やること

ベンチマークを実行後

soudai commented 5 years ago

MySQLのことしか考えてない。 DBのサイズ、レコードを抽出する

SELECT table_name,
       engine,
       table_rows,
       avg_row_length,
       floor((data_length + index_length) / 1024 / 1024) as allMB,
       floor((data_length) / 1024 / 1024)                as dMB,
       floor((index_length) / 1024 / 1024)               as iMB
FROM information_schema.tables
WHERE table_schema = database()
ORDER BY (data_length + index_length) DESC;
soudai commented 5 years ago

スロークエリを全部だす

slow_query_log                = 1
slow_query_log_file           = /var/lib/mysql/mysqld-slow.log
long_query_time               = 0
log-queries-not-using-indexes = 1
kamipo commented 5 years ago
mysql> show tables;
+-----------------------+
| Tables_in_isucari     |
+-----------------------+
| categories            |
| configs               |
| items                 |
| shippings             |
| transaction_evidences |
| users                 |
+-----------------------+
6 rows in set (0.00 sec)

mysql> select count(*) from categories;
+----------+
| count(*) |
+----------+
|       43 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from configs;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|    50035 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from shippings;
+----------+
| count(*) |
+----------+
|    15037 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from transaction_evidences;
+----------+
| count(*) |
+----------+
|    15037 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from users;
+----------+
| count(*) |
+----------+
|     4000 |
+----------+
1 row in set (0.00 sec)
soudai commented 5 years ago
mysql> SELECT table_name,
    ->        engine,
    ->        table_rows,
    ->        avg_row_length,
    ->        floor((data_length + index_length) / 1024 / 1024) as allMB,
    ->        floor((data_length) / 1024 / 1024)                as dMB,
    ->        floor((index_length) / 1024 / 1024)               as iMB
    -> FROM information_schema.tables
    -> WHERE table_schema = database()
    -> ORDER BY (data_length + index_length) DESC;
+-----------------------+--------+------------+----------------+-------+------+------+
| table_name            | engine | table_rows | avg_row_length | allMB | dMB  | iMB  |
+-----------------------+--------+------------+----------------+-------+------+------+
| items                 | InnoDB |      43806 |           2361 |   101 |   98 |    2 |
| transaction_evidences | InnoDB |      13195 |           2349 |    29 |   29 |    0 |
| shippings             | InnoDB |      14848 |            318 |     4 |    4 |    0 |
| users                 | InnoDB |       3993 |            398 |     1 |    1 |    0 |
| configs               | InnoDB |          2 |           8192 |     0 |    0 |    0 |
| categories            | InnoDB |         43 |            381 |     0 |    0 |    0 |
+-----------------------+--------+------------+----------------+-------+------+------+
6 rows in set (0.00 sec)