Example of how to check the capacity of MySQL database table

Example of how to check the capacity of MySQL database table

This article introduces the command statements for checking the capacity of database tables in MySQL, and provides complete query statements and examples for easy learning and use.

1. View the capacity of all databases

select 
table_schema as 'database',
sum(table_rows) as 'Number of records',
sum(truncate(data_length/1024/1024, 2)) as 'Data capacity (MB)',
sum(truncate(index_length/1024/1024, 2)) as 'Index capacity (MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

2. View the capacity of all database tables

select 
table_schema as 'database',
table_name as 'table name',
table_rows as 'number of records',
truncate(data_length/1024/1024, 2) as 'Data capacity (MB)',
truncate(index_length/1024/1024, 2) as 'Index capacity (MB)'
from information_schema.tables
order by data_length desc, index_length desc;

3. Check the capacity of the specified database

Example: Check the capacity of the mysql database

select 
table_schema as 'database',
sum(table_rows) as 'Number of records',
sum(truncate(data_length/1024/1024, 2)) as 'Data capacity (MB)',
sum(truncate(index_length/1024/1024, 2)) as 'Index capacity (MB)'
from information_schema.tables
where table_schema='mysql'; 

這里寫圖片描述

4. Check the capacity of each table in the specified database

Example: Check the capacity of each table in the MySQL database

select 
table_schema as 'database',
table_name as 'table name',
table_rows as 'number of records',
truncate(data_length/1024/1024, 2) as 'Data capacity (MB)',
truncate(index_length/1024/1024, 2) as 'Index capacity (MB)'
from information_schema.tables
where table_schema='mysql'
order by data_length desc, index_length desc; 

這里寫圖片描述

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of MySQL database binlog cleanup command
  • MySQL Database Iron Laws (Summary)
  • How to compare two database table structures in mysql
  • Method of using MySQL system database for performance load diagnosis
  • mysql create database, add users, user authorization practical method

<<:  Native js to achieve puzzle effect

>>:  When setting up Jenkins in Docker environment, the console log shows garbled Chinese characters when building tasks

Recommend

MySQL uses find_in_set() function to implement where in() order sorting

This article introduces a tutorial about how to u...

How to use ElementUI pagination component Pagination in Vue

The use of ElementUI paging component Pagination ...

Detailed tutorial on using VMware WorkStation with Docker for Windows

Table of contents 1. Introduction 2. Install Dock...

JavaScript Design Pattern Command Pattern

The command pattern is a behavioral design patter...

How to write transparent CSS for images using filters

How to write transparent CSS for images using filt...

Summary of MySQL injection bypass filtering techniques

First, let’s look at the GIF operation: Case 1: S...

MySQL 8.0.18 uses clone plugin to rebuild MGR implementation

Assume that a node in the three-node MGR is abnor...

Set an icon for the website to be displayed on the far left of the browser tab

What is the purpose of this sentence? Copy code Th...

In-depth analysis of MySQL data type DECIMAL

Preface: When we need to store decimals and have ...

Vue's detailed code for implementing the shuttle box function

Vue - implement the shuttle box function, the eff...

Install Linux using VMware virtual machine (CentOS7 image)

1. VMware download and install Link: https://www....

CSS Transition expands and collapses elements by changing the Height

A common development need is that we want to coll...