I have 2 labs where MySQL is installed. DataBases are created and deleted dynamically by certain internal processes. InnoDB is the Engine used.
In one lab, MySQL version 5.0.77 is installed.
The DB directory for each DB is around 230 KB, on average.
select engine from information_schema.tables where table_schema = 'test_1389772840' and table_name = 'test';
+--------+
| engine |
+--------+
| InnoDB |
+--------+
1 row in set **(0.82 sec)**
In the other lab, MySQL version 5.6.11 is installed.
The DB directory for each DB is around 500 MB, on average.
select engine from information_schema.tables where table_schema = 'test_1389586231' and table_name = 'test';
+--------+
| engine |
+--------+
| InnoDB |
+--------+
1 row in set **(0.00 sec)**
So in summary, both labs have similar DataBases and tables, and use same engine, but older version is slow, and disk space requirement is less, while newer version is fast, and disk space is requirement huge.
Is this expected ? Why the slowness ? Why the huge space requirement ? How can query speed and disk usage be brought to good levels ?
I checked MySQL documentation, but it did not help. It suggested optimize table ( here http://dev.mysql.com/doc/refman/5.6/en/optimize-table.html ) but there was no change in disk usage.
I found some compression parameters ( here https://blogs.oracle.com/mysqlinnodb/entry/innodb_compression_improvements_in_mysql ) which I tried configuring:
On 5.0.77:
show variables like '%compr%' ;
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| have_compress | YES |
| slave_compressed_protocol | OFF |
+---------------------------+-------+
BEFORE change of values on 5.6.11:
show variables like '%compr%' ;
+------------------------------------------+-------+
| Variable_name | Value |
+------------------------------------------+-------+
| have_compress | YES |
| innodb_compression_failure_threshold_pct | 5 |
| innodb_compression_level | 6 |
| innodb_compression_pad_pct_max | 50 |
| innodb_log_compressed_pages | ON |
| slave_compressed_protocol | OFF |
+------------------------------------------+-------+
AFTER change of values on 5.6.11:
show variables like '%compr%' ;
+------------------------------------------+-------+
| Variable_name | Value |
+------------------------------------------+-------+
| have_compress | YES |
| innodb_compression_failure_threshold_pct | 0 |
| innodb_compression_level | 9 |
| innodb_compression_pad_pct_max | 0 |
| innodb_log_compressed_pages | OFF |
| slave_compressed_protocol | OFF |
+------------------------------------------+-------+
I will be monitoring the average size over next few days.
Best Answer
One thing must be noted that you probably never realized: The setting of the option innodb_file_per_table will determine how much space is inside each database folder.
First, take a look at the InnoDB Architecture
Note the system tablespace (which was know is named ibdata1 in the OS).
mydb.mytable
, you get the following:/var/lib/mysql/mydb/mytables.frm
mydb.mytable
are inside ibdata1mydb.mytable
, you get the following:/var/lib/mysql/mydb/mytables.frm
mydb.mytable
are stored in/var/lib/mysql/mydb/mytables.ibd
SUMMARY
Without setting innodb_file_per_table and just storing data
.frm
files for its InnoDB tables. Thus, you only have kilobytes of files in each database..frm
and.ibd
files for its InnoDB tables. Thus, you will have megabytes or gigabytes of files in each database.