K
K
koliane2018-06-14 14:35:15
MySQL
koliane, 2018-06-14 14:35:15

Table size in MySql does not shrink when clearing values. How to be?

There is a table that stores information on email newsletters for each user (the subject of the letter, the text of the letter, the sending status, etc.). Approximately 30,000 records per day are added to the table. This increases the table by 300 MB per day
In order to reduce the size of the table, I clear the "mail body" field for all records with the "sent" status. The size in this case should decrease significantly. But that doesn't happen. The table size remains the same.
Why is this happening? How to reduce table size when clearing fields?
The table type is Innodb.
PS. Please do not write messages like "it is better to organize the table differently" and similar messages. The question is different, namely, how to reduce the size of the table by clearing the fields of the records?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Igor, 2018-06-14
@koliane

https://dev.mysql.com/doc/refman/8.0/en/optimize-t...

K
Kirill Gorelov, 2018-06-14
@Kirill-Gorelov

The question is different, namely, how to reduce the size of the table by clearing the fields of the records?
Delete either all or half of the table.
Whatever it was, you really need to redo the table a little.
PS. Please do not write messages like "it is better to organize the table differently" and similar messages.
Either you just don't know how to do it, or you're too lazy.
Therefore, you need to choose one thing, leave it as it is, or add another table with the text of the letter.

Z
Zakharov Alexander, 2018-06-14
@AlexZaharow

I looked through the info a little, it says
1. " That ibdata1 isn't shrinking is a particularly ann... "
2. The InnoDB engine does not support size reduction ...
3. There are also binary logs (they get very clogged), they are cleaned by the command " RESET MASTER" (just be careful - they are used for replication if there are several servers).
Those. in fact, you now have a situation for which it was necessary to prepare in advance . Unfortunately. I do not blame you, I myself was not aware of this MySQL trick.

T
tvoyadres, 2020-04-30
@tvoyadres

In general, that is, the solution is simply to copy the old table to the new one, then rename the new one back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question