As a Database Administrator(DBA), your job want you to know the most atomic details of databases in your server. It happens for me many times, my boss/ delivery manager asking me, what is the size of a specific database or specific table, in this kind of situation, producing the right data will help make right decision. From my experience, I understood, it is always better to say, I will give you data in few minutes, instead of producing the incorrect data, which I had been doing for a long time.
This post is about identifying the size of a database(s) or table(s). The simple script, I have been using it for quite a long, if not wrong when I started my career as DBA. You could have probably seen this/similar script on other forums as well and there are many other methods too. I am reproducing this handy script here to get work done.
This post is about identifying the size of a database(s) or table(s). The simple script, I have been using it for quite a long, if not wrong when I started my career as DBA. You could have probably seen this/similar script on other forums as well and there are many other methods too. I am reproducing this handy script here to get work done.
Size of a specific table:
select table_name as "Table Name", sum(data_length+index_length)/1024/1024 as "Table Size in MB" from information_schema.tables where table_schema = 'Database Name' and table_name = 'Table Name';
Size of a specific database:
select table_schema as "Database Name",
sum(data_length+index_length)/1024/1024 as "Database Size in MB"
from information_schema.tables
where table_schema = 'Database Name';
Size of all tables in a database with descending order:
select table_name as "Table Name",
sum(data_length+index_length)/1024/1024 as "Table Size in MB"
from information_schema.tables
where table_schema = 'Database Name'
group by table_name
order by 2 desc;
Size of all databases in descending order:
select table_schema as "Database Name",
sum(data_length+index_length)/1024/1024 as "Database Size in MB"
from information_schema.tables
group by table_schema
order by 2 desc;
This script is enough for us to get things done. I am providing here the table description of the information_schema.tables for more understanding. The table description can be displayed by running DESCRIBE command.
mysql> desc information_schema.tables;
+-----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+-------+
| TABLE_CATALOG | varchar(512) | NO | | | |
| TABLE_SCHEMA | varchar(64) | NO | | | |
| TABLE_NAME | varchar(64) | NO | | | |
| TABLE_TYPE | varchar(64) | NO | | | |
| ENGINE | varchar(64) | YES | | NULL | |
| VERSION | bigint(21) unsigned | YES | | NULL | |
| ROW_FORMAT | varchar(10) | YES | | NULL | |
| TABLE_ROWS | bigint(21) unsigned | YES | | NULL | |
| AVG_ROW_LENGTH | bigint(21) unsigned | YES | | NULL | |
| DATA_LENGTH | bigint(21) unsigned | YES | | NULL | |
| MAX_DATA_LENGTH | bigint(21) unsigned | YES | | NULL | |
| INDEX_LENGTH | bigint(21) unsigned | YES | | NULL | |
| DATA_FREE | bigint(21) unsigned | YES | | NULL | |
| AUTO_INCREMENT | bigint(21) unsigned | YES | | NULL | |
| CREATE_TIME | datetime | YES | | NULL | |
| UPDATE_TIME | datetime | YES | | NULL | |
| CHECK_TIME | datetime | YES | | NULL | |
| TABLE_COLLATION | varchar(32) | YES | | NULL | |
| CHECKSUM | bigint(21) unsigned | YES | | NULL | |
| CREATE_OPTIONS | varchar(255) | YES | | NULL | |
| TABLE_COMMENT | varchar(2048) | NO | | | |
+-----------------+---------------------+------+-----+---------+-------+
21 rows in set (0.00 sec)
I hope this post will help you to complete your task quickly. Please write your comments on this post and let me know, if there are other simple methods to achieve this task. Thanks for your time.
Nice blog!! I really got to know many new tips by reading your blog. Thank you so much for detailed information! It is very helpful to me. Kindly continue the work.
ReplyDeleteSpoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching Centre in Chennai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Classes in Mumbai
IELTS Coaching in Mumbai
Great knowledge, do anyone mind merely reference back to it Apartment intercom system upgrade.
ReplyDeleteGreat job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing moblogtech.com
ReplyDeleteJuggling work, home and community lives, parents now rely heavily on communication, information and transportation technology to make their lives faster and more efficient.curso scrum master
ReplyDeleteThe importance of technological innovation in today's competitive economy is very clear, as today the worldwide economy depends on technology and technological innovation to an extraordinary degree.Obsolete electronic components
ReplyDelete, they prompt that innovation is an essential piece of a college understudies life since they need to do must everything on the web from applying for school or college, looking and enrolling for classes, streaming microphone
ReplyDeleteI Like Technology. I'm yielding all the great and fun things that PC based technology has brought into our lives; I'll not face that conflict. In addition to the fact that I would lose any contention against the superb increments technology has made to our lives, I would be battling against myself.vps hosting
ReplyDeleteGreat job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. Big data
ReplyDeleteI wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. Symptoms of Not Drinking Enough Water
ReplyDeleteYou can use the energy sources created by an evolving market to motivate prospects to buy your solution. Persuading people to try out a new technology is an uphill battle. best programming keyboard
ReplyDeleteSo Intel Inside is Intel's core technology which, My Washer is Leaking from the Bottom when integrated into other lesser known brands, has the power to sell the latter to great effect. It might though be cripplingly expensive for the host. Intel will sell your product, but at a price.
ReplyDeletehttps://www.mycestsolution.com/2019/10/proteus-arduino-vsm-library-by-mycest.html?showComment=1591727521026#c2597506754287567555
ReplyDeleteIn addition, I am convinced that innovative ideas in technologies have created a completely new life, ac motor repair which poses new challenges for our country. How we will cope with these tasks depends on the future of our country.
ReplyDeleteNow, smartphones have broadened the scope of communication which is not just limited to making long distance calls. Due to the changes in technology, homes for sale in milton the reliance upon technological gadgets has increased.
ReplyDeleteYou want to use the technology that works the best for your project and will be the most beneficial. Key Replacement Make sure before committing to one company that you ask what technologies the company works in and you should be able to tell from their answer their willingness to work in different environments.
ReplyDeleteMy experience is: ignore technology and "Real Recruiter" or not your business is doomed, combination weigher it will not progress far into the future as a viable entity. You will be replaced.
ReplyDeleteThis is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you. selfie ring light
ReplyDeleteIn the event that you have a SIM card, you don't have to acquire a telephone for each new number or area. Rather you place your SIM card on your telephone and afterward that telephone turns into your cell phone with your own number. atm skimmer for sale
ReplyDeleteSo as to impartially react to this inquiry, 3 articles were inspected. 2 out of the 3 relate how the utilization of technology in the homeroom disappoints understudies while the last one deciphers the contemplations of understudies who feel that technology in the study hall has reacted to their need. best bluetooth headset for online teaching
ReplyDeleteFrom a more extensive perspective, technology influences social orders in the improvement of cutting edge economies, making life more advantageous to more individuals that approach such technology. scanner sales
ReplyDeleteIt is advertising and marketing offers advertisments so as to practical research ahead of placing. In other words to jot down more appropriate area in this way. Website
ReplyDeleteAndroid versus iOS is a genuine illustration of how this functions. Both working frameworks are subordinates of UNIX. Apple utilized their technology to present iOS and increased an early market advantage. mobile tracker app
ReplyDeleteLiên hệ đặt vé tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ tháng nào rẻ nhất
vé máy bay từ mỹ về việt nam mùa dịch
giá vé máy bay từ Vancouver về việt nam
gia ve may bay vietjet tu han quoc ve viet nam
On the off chance that you truly need the full pool insight, at that point you need to figure out how to get a full estimated table. Tablemate
ReplyDeleteI just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
ReplyDeletevé máy bay từ nga về tphcm
giá thuê máy bay từ anh về việt nam
bay từ pháp về việt nam mấy tiếng
bao giờ có chuyến bay từ đức về việt nam
Lịch bay từ Hàn Quốc về Việt Nam hôm nay
vé máy bay giá rẻ tu Nhat Ban ve Viet Nam