Skip to content

Commit

Permalink
Updated mysql tips
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsiryk committed Apr 3, 2020
1 parent 59e6a5f commit 18991c0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mysql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
MySQL / SQLite
==============

Get all indicies size::

SELECT database_name, table_name, index_name,
round(stat_value*@@innodb_page_size/1024/1024, 2) size_in_mb
FROM mysql.innodb_index_stats
WHERE stat_name = 'size' AND index_name != 'PRIMARY'
ORDER BY 4 DESC;


::

Expand Down Expand Up @@ -156,6 +164,10 @@ Show size of databases::

SELECT table_schema "database_name", sum( data_length + index_length )/1024/1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema;

Show size of all tables::

SELECT table_schema, table_name, (data_length + index_length + data_free)/1024/1024 AS total_mb, (data_length)/1024/1024 AS data_mb, (index_length)/1024/1024 AS index_mb, (data_free)/1024/1024 AS free_mb, CURDATE() AS today FROM information_schema.tables ORDER BY 3 ASC;


Repair crashed table::

Expand Down

0 comments on commit 18991c0

Please sign in to comment.