Imran Omar Bukhsh
Imran Omar Bukhsh

Reputation: 8071

Compressing data stored in mysql

We store full html pages in our table in a field called 'conteny'. Now this table is like an archive and we would be rarely using it. The 'content' field is of type 'longtext' right now and I would like to know which is the best way we could compress and keep this table's data as its taking many gbs of space.

I tried simply using the gzcompress function on the content field in php but that did not work.e.g.

 $content = gzcompress($content,9);

Also tried this but does not work:

update posts_content set content = COMPRESS(content)

Any ideas whats the best way to do it and how?

Another question here Is mysql automatically compressing the database? talks about INNODB but we use MYISAM and could move to INNODB as a final resort.

Thanking you

Upvotes: 0

Views: 2925

Answers (1)

diolemo
diolemo

Reputation: 2671

When using compression the result is binary not text. You shouldn't try to store the result in a text column. A BLOB column should work with the gzcompress method.

Upvotes: 1

Related Questions