Skip to content

frail/mysql-size-estimator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

mysql-size-estimator

mysql-size-estimator is a simple tool to estimate mysql table size for given table schema. It's not 100% accurate nor it could ever be. It's much better to use this tool to give an insight.

The string fields would consume its limits. Assuming you have a utf-8 string field with 10 character limit; estimator would calculate like this field is fully filled with 3 byte characters. (I am planing to make it better and sane soon.)

Install :

git clone https://github.com/frail/mysql-size-estimator.git
cd mysql-size-estimator
python setup.py install

Usages :

Simple usages

or from sql file :

mysql-size-estimator file create1.sql

if you don't have a create script use dummy feature

mysql-size-estimator dummy -c "id INT" -c "user_id INT" -c "name VARCHAR(10) CHARACTER SET latin1" -i "PRIMARY KEY id" -i "KEY idx_name (name)"

if you have specific row counts to do the estimation you can write them aswell

 mysql-size-estimator dummy -c "id INT" -r 1000000 -r 14000000 -r 1700000

Advanced usages

pull data directly from db :

mysql -e 'SHOW CREATE TABLE mysql.user\G' --skip-column-names | awk 'NR > 2' | mysql-size-estimator file -

check out what would change if you add/change an index (names should be unique) :

 ... | mysql-size-estimator file - -i "KEY idx_category(category, created_at)"

if the results seems absurd check out string fields and re-arrange their size on fly. or even change their data type.

... | mysql-size-estimator file - -c "text1 VARCHAR(10)" -c "text2 TEXT(100)"

Important links

Contributing

I would be very happy if you decide to contribute. Check out TODO.txt (my simple todo list) if you want to get an opinion of what I want to achieve. I am also open to ideas.

Please make sure you make the code would be less complicated and have more test coverage with each commit.

Thanks.

About

Mysql Table Size Estimator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages