This is how the official MySQL template calculates the database size (in this example I only use history_uint table but the principle is valid, lines split for clarity):
while the filesystem says:
There is no housekeeper deleting history data from the database.
For the whole database the difference is this:
Can anyone explain this difference?
What would be the correct way to calculate the size of the MySQL (or in this case, MariaDB 10.5.12) database?
I'm asking because until one day in February the MySQL template reported numbers just fine, but after that the reported size was just getting smaller and smaller:

The partitioning task runs at midnight and keeps 10 days of partitions, so every night it purged the old history partitions and on 1st of March it purged the old trends data. Today I rebooted the database server, and now the reported size is growing again, let's see what happens tonight.
Markku
Code:
# echo ' select sum(data_length+index_length)/1024/1024/1024 as "Size in GB" from information_schema.tables where table_schema="zabbix" and table_name="history_uint"; ' | mysql Size in GB 1.454421997070
Code:
# du -sch history_uint* 4.0K history_uint.frm 4.0K history_uint.par 2.3G history_uint#P#p2022_02_27.ibd 2.3G history_uint#P#p2022_02_28.ibd 2.3G history_uint#P#p2022_03_01.ibd 2.2G history_uint#P#p2022_03_02.ibd 2.2G history_uint#P#p2022_03_03.ibd 2.3G history_uint#P#p2022_03_04.ibd 2.2G history_uint#P#p2022_03_05.ibd 2.3G history_uint#P#p2022_03_06.ibd 2.3G history_uint#P#p2022_03_07.ibd 2.3G history_uint#P#p2022_03_08.ibd 1.6G history_uint#P#p2022_03_09.ibd 112K history_uint#P#p2022_03_10.ibd 24G total
For the whole database the difference is this:
Code:
# echo 'select sum(data_length+index_length)/1024/1024/1024 as "Size in GB" from information_schema.tables where table_schema="zabbix";' | mysql Size in GB 16.528808593750 # du -sch /var/lib/mysql/zabbix 50G /var/lib/mysql/zabbix 50G total
What would be the correct way to calculate the size of the MySQL (or in this case, MariaDB 10.5.12) database?
I'm asking because until one day in February the MySQL template reported numbers just fine, but after that the reported size was just getting smaller and smaller:
The partitioning task runs at midnight and keeps 10 days of partitions, so every night it purged the old history partitions and on 1st of March it purged the old trends data. Today I rebooted the database server, and now the reported size is growing again, let's see what happens tonight.
Markku
Comment