Posts

Showing posts with the label MySQL

MySQL - List blocks

With this select you can see if there a block in your MySQL Database. SELECT     pl.id     ,pl.user     ,pl.state     ,it.trx_id     ,it.trx_mysql_thread_id     ,it.trx_query AS query     ,it.trx_id AS blocking_trx_id     ,it.trx_mysql_thread_id AS blocking_thread     ,it.trx_query AS blocking_query FROM information_schema.processlist AS pl INNER JOIN information_schema.innodb_trx AS it ON pl.id = it.trx_mysql_thread_id INNER JOIN information_schema.innodb_lock_waits AS ilw ON it.trx_id = ilw.requesting_trx_id         AND it.trx_id = ilw.blocking_trx_id

MySQL - List table an index size

Use the select below to list information about tables and indexes in your MySQL database. SELECT COUNT(*) AS TotalTableCount ,table_schema ,CONCAT(ROUND(SUM(table_rows)/1000000,2),'M') AS TotalRowCount ,CONCAT(ROUND(SUM(data_length)/(1024*1024*1024),2),'G') AS TotalTableSize ,CONCAT(ROUND(SUM(index_length)/(1024*1024*1024),2),'G') AS TotalTableIndex ,CONCAT(ROUND(SUM(data_length+index_length)/(1024*1024*1024),2),'G') TotalSize         FROM information_schema.TABLES GROUP BY ENGINE ORDER BY SUM(data_length+index_length) DESC LIMIT 10;

MySQL - List database size

With the select below you can see the size of MySQL databases.   SELECT         @@hostname as `Server`, t.table_schema AS "Database", SUM(t.data_length + t.index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES t where t.table_schema not in ('information_Schema', 'test', 'mysql', 'performance_schema') GROUP BY table_schema ;