EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
Home Data Science Data Science Tutorials MySQL Tutorial MySQL Table Size

MySQL Table Size

By Priya PedamkarPriya Pedamkar

Definition

MySQL table size is determined in multiple ways; we can use various commands to retrieve MySQL table size. The “”how table status””command returns the information about the MySQL table; it also includes the size of the table. The total size of the MySQL table is a combination of index and data length. Add the index length with the data length to retrieve the original size of the MySQL table.

Mysql table size

Key Takeaways

  • Table size is crucial in the performance of a database, as we know that a larger table shows down the performance of the database and it will also increase the time to process the data.
  • We can determine the table size using the amount of data stored, data type, and index of tables.

Introduction to MySQL Table Size

MySQL provides metadata about tables and databases. It will refer to the amount of disk space used to store the data and the indexes the table. The table size is essential for multiple reasons; it includes optimization, disk usage, and performance. The larger table size will lead the slower performance because the MySQL server needs to read more data from the disk and needs to process it. This is true for a large query that scans the whole table of MySQL to process the data.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

To monitor the size of the table is to ensure the availability of disk space on the server that was used efficiently. If the table size is large, we can reduce it by optimizing the data and data types of the column. We can also delete unwanted data from the table. Table size also impacts capacity planning; it indicates the disk space that is required to store the data in the future.

Methods to Check MySQL Table Size

There are three methods used to check the size of the MySQL table.

1. Using phpMyAdmin

To check the size using phpMyAdmin, follow the below steps as follows.

1. Open the phpMyAdmin in the browser. We can open phpMySQL in the browser and install it in our system.

phpMySQL

2. Below, we have enabled the database statistics as follows. To check the size of the table, first, we need to allow the statistics.

statistics of the database

3. After opening the phpMyAdmin, now in this step, we have checked the size of all databases as follows.

size of databases

4. In this step, we have checked the size of all tables as follows.

size of all tables

5. In this step, we have checked the size of single tables as follows.

size of single tables

6. We can also get the size of all databases using SQL command in phpMyAdmin as follows.

SELECT TABLE_SCHEMA AS "DB_Name", SUM(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 2 AS "DB_size" FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;

SQL command in php

7. We can also get the size of all tables using SQL command in phpMyAdmin as follows.

SELECT TABLE_NAME AS "Tab_Name", ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Tab_Size" FROM information_schema.TABLES WHERE table_schema = "test19" order by Tab_Size desc;

Table size

2. Using the Command Line

Below steps show to find the size using the command line as follows.

The pre-requisite is to check the size using the MySQL command line and install the MySQL client and server in our system. To check the MySQL client and server installation, execute the below command.

mysql –version

mysql –version

1. In the first step, login into the MySQL server.

mysql –u root -p

mysql –u root -p

2. After logging in MySQL server, now in this step, we execute the select command to find the size of the specific database as follows. In the below example, we have seen the database size in MB.

SELECT TABLE_SCHEMA AS DB_Name, SUM(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 AS DB_Size FROM information_schema.TABLES WHERE TABLE_SCHEMA="mysql";

database size

3. After getting the size of specific databases, now,, in this step, we execute the select command to find the size of all databases as follows.

SELECT TABLE_SCHEMA AS "DB_Name", SUM(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 2 AS "DB_size" FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;

Mysql table size - select command

4. After getting the size of all databases, now in this step, we are executing the select command to find the size of all tables of specified DB as follows.

SELECT TABLE_NAME AS "Tab_Name", ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Tab_Size" FROM information_schema.TABLES WHERE table_schema = "mysql" order by Tab_Size desc;

executing the select command

3. Using Workbench

Below steps show to find the size using MySQL workbench as follows.

1. In the first step, open the MySQL workbench.

MySQL workbench

2. In this step, we show the MySQL table size by GUI option as follows.

Mysql table size - GUI option

3. We can also find the table size using the SQL query tool in MySQL workbench as follows.

SELECT TABLE_NAME AS "Tab_Name", ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Tab_Size" FROM information_schema.TABLES WHERE table_schema = "mysql" order by Tab_Size desc;

Mysql table size - SQL query tool

List of MySQL Tables ordered by Sizes

We can find the table size by using information_schema.tables. Below example shows to display a list of all tables from the specified schema.

show tables;

Mysql table size - show tables

In the below section, we have retrieved the table size in ascending order. We can retrieve table size in ascending and descending order as follows.

SELECT TABLE_NAME AS "Tab_Name", ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Tab_Size" FROM information_schema.TABLES WHERE table_schema = "mysql" order by Tab_Size ASC;

Mysql table size - ascending & descending

In the below section, we have retrieved the table size in descending order.

SELECT TABLE_NAME AS "Tab_Name", ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Tab_Size" FROM information_schema.TABLES WHERE table_schema = "mysql" order by Tab_Size DESC;

descending order

Conclusion

Understanding the size of MySQL database and table is essential to manage the whole database. The table size impacts query performance. To determine the table size, we use the select command and the and phpMyAdmin tool. We can also use other tools like dbeaver to find the size of the MySQL table.

Recommended Article

We hope that this EDUCBA information on “MySQL table size” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. MySQL Grant All Privileges
  2. ORDER BY Random in MySQL
  3. MySQL Function
  4. MySQL Cheat Sheet
C++ PROGRAMMING Certification Course
38+ Hours of HD Videos
9 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ASP.NET Certification Course
149+ Hours of HD Videos
28 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
SQL - Everything in SQL
253+ Hours of HD Videos
51 Courses
6 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
SOFTWARE TESTING Certification Course
74+ Hour of HD Videos
13 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Popular Course in this category
MYSQL Certification Course
 115+ Hours of HD Videos
18 Courses
3 Mock Tests & Quizzes
  Verifiable Certificate of Completion
  Lifetime Access
4.5
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more