MarcosBL

Aprendiz de todo, maestro de nada

Consultas MySQL útiles

Las 10 bases de datos más grandes del servidor

[mysql]
SELECT
count(*) TABLES,
table_schema,concat(round(sum(table_rows)/1000000,2),’M’) rows,
concat(round(sum(data_length)/(1024*1024*1024),2),’G’) DATA,
concat(round(sum(index_length)/(1024*1024*1024),2),’G’) idx,
concat(round(sum(data_length+index_length)/(1024*1024*1024),2),’G’) total_size,
round(sum(index_length)/sum(data_length),2) idxfrac
FROM information_schema.TABLES
GROUP BY table_schema
ORDER BY sum(data_length+index_length) DESC LIMIT 10;
[/mysql]

Número total de tablas, registros, tamaño de datos y tamaño de índices en nuestro servidor

[mysql]
SELECT count(*) TABLES,
concat(round(sum(table_rows)/1000000,2),’M’) rows,
concat(round(sum(data_length)/(1024*1024*1024),2),’G’) DATA,
concat(round(sum(index_length)/(1024*1024*1024),2),’G’) idx,
concat(round(sum(data_length+index_length)/(1024*1024*1024),2),’G’) total_size,
round(sum(index_length)/sum(data_length),2) idxfrac
FROM information_schema.TABLES;
[/mysql]

Los 10 motores de almacenamiento más utilizados

[mysql]
SELECT ENGINE , count( * )
TABLES , concat( round( sum( table_rows ) /1000000, 2 ) , ‘M’ )
ROWS , concat( round( sum( data_length ) / ( 1024 *1024 *1024 ) , 2 ) , ‘G’ )
DATA , concat( round( sum( index_length ) / ( 1024 *1024 *1024 ) , 2 ) , ‘G’ ) idx, concat( round( sum( data_length + index_length ) / ( 1024 *1024 *1024 ) , 2 ) , ‘G’ ) total_size, round( sum( index_length ) / sum( data_length ) , 2 ) idxfrac
FROM information_schema.TABLES
GROUP BY ENGINE
ORDER BY sum( data_length + index_length ) DESC
LIMIT 10 ;
[/mysql]

Via MySQL Performance Blog

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *