Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sakasa authored Jul 3, 2020
1 parent 38ed74d commit f95ab94
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions MySQL/memo.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,37 @@ SQL> SELECT @@autocommit;
SQL> SET AUTOCOMMIT=0; -- OFFにセット
-- SET AUTOCOMMIT=1; -- ONにセット
```

### DBとテーブルのサイズ確認
- DB

mysqlに接続した状態で(DBを選択していなくてもOK)
```
SELECT
table_schema, sum(data_length) /1024/1024 AS mb
FROM
information_schema.tables
GROUP BY
table_schema
ORDER BY
sum(data_length+index_length) DESC;
```

- テーブル

mysqlに接続して対象DBに入っている状態で
```
SELECT
table_name, engine, table_rows AS tbl_rows,
avg_row_length AS rlen,
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;
```
参考:https://qiita.com/ikenji/items/b868877492fee60d85ce

0 comments on commit f95ab94

Please sign in to comment.