Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have fairly large MyISAM table with longtext field in it

Table size is somewhat 16GB.

I need to know if clearing this column in old records helps to keep table small

I can retrieve table wise Data_length using information_schema.tables

Is there a way to find Data_length just for this one column?

share|improve this question
up vote 4 down vote accepted

Here is how you find the sum of the lengths the LONGTEXT column of all rows

SELECT SUM(field_length) TotalFieldLength FROM
(SELECT LENGTH(LongTextColumnName) field_length FROM mydb.mytable) A;

Once you delete the rows you want, just compress the file

You can do it in a single command

OPTIMIZE TABLE mydb.mytable;

or in stages

CREATE TABLE mydb.mytablenew LIKE mydb.mytable;
INSERT INTO mydb.mytablenew SELECT * FROM mydb.mytable;
ALTER TABLE mydb.mytablenew ENABLE KEYS;
ALTER TABLE mydb.mytable RENAME mydb.mytablezap;
ALTER TABLE mydb.mytablenew RENAME mydb.mytable;
DROP TABLE mydb.mytablezap;
ANALYZE TABLE mydb.mytable;

Give it a Try !!!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.