Different DB sizes in MYSQL and Linux Server

Amal Kumar10 months ago

Hi, While checking size of my DB, when i run sql query to check the size then it shows size as 9.5GB but when i run command to check size of DB folder in my Linux Server then it shows it as 15GB. Can anyone help me regarding this?

Traccar DB size in MYSQL-:

+--------------------+---------------------+
| Database_Name      | Database Size in MB |
+--------------------+---------------------+
| information_schema   |              0.0000 |
| mysql                          |              2.7344 |
| performance_schema |              0.0000 |
| sys                              |              0.0156 |
| traccardb                 |           9507.2344 |
+--------------------+---------------------+

Traccar DB size in Linux Server-:

15G     /var/lib/mysql/traccardb
Eduardo S9 months ago

I think it could be because RAW data (data in files) have indexes and metadata that MySQL needs to interpret and order correctly the information (maybe could have redundant data that it needs to guarantee integrity of information).
And when you access to data inside MySQL, metadata and possible redundant information is not considered in database size because that are not part of information, but are part of technical requirements for correct operation of MySQL itself. From my understanding, that could be the reason.

According to ChatGPT, that size difference is because : not used space in internal blocks of information, indexing of information, fragmentation, version history (i didn't considered that one), binlog (what i said about integrity of information), and reserved file space for future needs (very possible).

Greets.